1825803 Members
2468 Online
109687 Solutions
New Discussion

Re: Backgrounding emacs

 
Neil O'Brien
Advisor

Backgrounding emacs

Hi,

I know that HP-UX console grabs the foreground process, so how do I background a job, for example emacs or xemacs so I can call it something like xemacs -i& and get an iconifiable window?
22 REPLIES 22
harry d brown jr
Honored Contributor

Re: Backgrounding emacs

What kind of server and what kind of console - serial or graphic? if graphic, then maybe you want to start a cde session?

live free or die
harry
Live Free or Die
Roger Baptiste
Honored Contributor

Re: Backgrounding emacs

hi,

if you are able to use CDE on the console(graphical), then you should be able to
background emacs, like any other process.

Some more info on what sort of console, the type of system (workstation? or servertype)
would help in suggesting solutions.

-raj
Take it easy.
Neil O'Brien
Advisor

Re: Backgrounding emacs

oops, sorry. Actually, it's a CDE via exceed. The box is a rackmount. HP-UX 11.00, in a korn shell.
Wodisch
Honored Contributor

Re: Backgrounding emacs

Hello,

make sure your $DISPLAY is set where you start the "emacs".
If you start your session with the CDE-login screen it is set automatically, but if you use the (silly - my private opinion) way of the "TELNET" client startup, then it is NOT set properly, so the programs try to start using the STDIN, and when they try to read from there, they are frozen until they are move to the "foreground" - which can never happen that way...

Just my ???0.02,
Wodisch
Roger Baptiste
Honored Contributor

Re: Backgrounding emacs

Neil,

do #echo $DISPLAY

to check your display settings from the window you are trying to run emacs. If the DISPLAY is set to the system hostname , it should work fine, otherwise you can set it as:
HOSTNAME='hostname'
DISPLAY=$HOSTNAME:0.0
export HOSTNAME DISPLAY

If your exceed session is running from a PC on the network, then you would need to set the DISPLAY to the IP address of the PC.

HTH
raj
Take it easy.
Neil O'Brien
Advisor

Re: Backgrounding emacs

thanks, but this is not the answer. I already have the HOSTNAME and DISPLAY env vars set to the HP and my PC names respectively (the name of the PC is defined in /etc/hosts in order to use the XDMCP broadcast so it resolves by name).
Wodisch
Honored Contributor

Re: Backgrounding emacs

Hello again,

it seems we do not understand what your problem is... So, please tell us what you mean with "grab" and "console".
Perhaps by listing the steps/commands you tried, and their output/behaviour.

Curious,
Wodisch
Alex Glennie
Honored Contributor

Re: Backgrounding emacs

He's trying to provide a better editing environment than vi, and as there are
extensions to emacs for languages etc that's why I was trying. It's not a
big deal, if there is another editor you do support for provides text
highlighting, colouring, syntax checking etc that includes Java support then
I can try that.

This is a general kind of question however, because I ran into equal
problems running dynamo, with that though, as there is command line output,
by using nohup I can avoid the problem.

As a general question though, I have tried cshell, bourne shell and no joy
but I just worked out where the problem is, although not specifically why.

I enabled the dt logging, and see this:

Stty: : Not a typewriter (repeats 3 times)
/usr/bin/ksh: a: unknown test operator

and the .profile has 3 lines

stty erase '^h'
stty intr '^c'
stty kill '^u'

which cause the first error, (yes the ticks are right, it's just outlook
trying to be clever), and the next line that the test fails on (my guess
anyway) is:

if [ ! "$DT" -a 'tty' !- "/dev/console" ]

this shell was copied from Solaris, as it appears to work I assumed it was
fine, but now I guess it does have some problem. I can send the
.kshrc/.profile and .dtprofile to avoid outlook weirdness.

ps I know because it's landed at my door :( any help appreciated still by both Kevin or I ... I'm still looking into it ....
Roger Baptiste
Honored Contributor

Re: Backgrounding emacs

<>

*LOL* That's a seamless merging of ITRC forum posts and the support centre functions ;-)

-raj
Take it easy.
Alex Glennie
Honored Contributor

Re: Backgrounding emacs

Tell me about it I get several of these per week .... you just can't escape :(
Wodisch
Honored Contributor

Re: Backgrounding emacs

Hello Neil and Alex,

who's "Kevin"??? :-)

Well, first, you still haven't answered my questions :-( but I'll give it another shot, anyway:
1) that line is wrong:
*** if [ ! "$DT" -a 'tty' !- "/dev/console" ]
as there is no operator "!-" - I guess it should read "!=", right?
2) since that would not freeze good ol' emacs ("Escape Meta Alternate Control Shift" or "Eight Megabytes And Constantly Swapping" as we called in the dark ages of UN*X), there must be some shell command-line started, which in turn tries to start the X-client, and, of course, is frozen when trying to read from SDTIN...
So, please tell us ALL the scripts/commands used to start that emacs, from the X-Windows startup scripts of the session, over the profile-scripts, to the Window-Manager scripts, which may be involved.

Just my ???0.02,
Wodisch
PS: Kevin - home alone??
Neil O'Brien
Advisor

Re: Backgrounding emacs

Hi,

OK, I've been in contact with Alex, he was having a bad hair day, must have confused me with some other Kevin! There is no Kevin, just Neil.

Anyway, the problem occurs with ksh, csh, bash and sh, but but csh/sh and bash are just defaults I don't have any extra scripts for those. The !- is !=. it was a typo on my behalf.


The only command used to start emacs is "emacs -i&" or just emacs& I tried xemacs on another HP, but the same problem. I think there is something simple in my configuration which is stopping the command line. I've included my .kshrc and .profile, the .dtprofile is unchanged except uncommenting DTSOURCEPROFILE to enable the shell initialisation. I've also attached the .dt/errorlog, it definitely does not like the stty erase '^H' lines, and the first test (if [ ! "$DT" ....), it's just called kshrc but all three are attached.

The X-Windows, exceed parts are just standard as far as I know. I'm using v6.2.0.0 of exceed, use the XDMCP to connect as a user to the HP, login as a regular user with CDE. I can give other versions etc as needed. The machine is running HP-UX 11.00. Emacs is v20.7

I'm going to create another user and see if I have a problem with that without the extra korn shell stuff.
Alex Glennie
Honored Contributor

Re: Backgrounding emacs

il,

OK here's what I've found : hpux 11.00 / H/W B180L

installed emacs 20.7, created new user with ksh as login shell
cd /opt/emacs/bin and run either emacs -i& or emacs-20.7 -i & works, I get an iconifiable
window with a gnu's head in it, running emacs without the -i option with or without an & also
works ie I still get an iconifiable window but it has no gnu's head.

Conclusion : patch levels, exceed or user customisation are playing a part here.

Advise : I can when I get time check the behaviour of the Exceed client out for you tomorrow.
I can use your .profile and kshrc files too but suggest you try creating a new user
with minimum customisation to their kshrc and .profiles and also detail the patch level
of this system as previously requested and any new results which occur from these actions.

More tomorrow.

Regards,

Alex
Neil O'Brien
Advisor

Re: Backgrounding emacs

Ah ha! So I found a reply Alex made yesterday to someone else where he suggests running dr_dt to analyse the system. So I tried it, no errors, but 5 warnings, some are just permissions things which are probably not a big deal, however, I don't have /var/adm/inetd.sec which I suspect may be a bigger deal.

Alex suggested that the file should contain:

dtspc allow
spc allow
mserve allow

Is this all the file should contain? I searched 4 HP's here and none have this file.
Alex Glennie
Honored Contributor

Re: Backgrounding emacs

try in /usr/newconfig/etc ?
Alex Glennie
Honored Contributor

Re: Backgrounding emacs

I've yet to look at your patch levels .... but Exceed vers 6.2 works fine
with a ksh user logged into CDE using your .profile and kshrc file .... not much
left other than patches or something you haven't told me ;)
Neil O'Brien
Advisor

Re: Backgrounding emacs

no. can't find that file either. I'm also wondering about /usr/dt/config/Xconfig which has
the Dtlogin*Grabserver commented out. Should I create a copy in /etc/dt/config and uncomment this line?

Neil O'Brien
Advisor

Re: Backgrounding emacs

ahem, sorry, made a typo, I really do have an inetd.conf. I'll try using that!

Neil O'Brien
Advisor

Re: Backgrounding emacs

OK, no joy there, now to ensure I have all the patches needed. Grrr, this is frustrating, it's not a big deal if I use emacs or not, it's just the concept of backgrounding processes!
Neil O'Brien
Advisor

Re: Backgrounding emacs

well I went for a binary distribution which may give a clue as it will not install without Xaw3d, JPEG, libpng, tiff, xpm and zlib pacjkages first. Now if only I could convince tiff and emacs that JPEG really is there - well that's what SAM tells me anyway.

sigh.
Neil O'Brien
Advisor

Re: Backgrounding emacs

Sometimes, you look for an esoteric answer when it's really quite simple!

The problem with jpeg was I had the wrong one. So now I've installed my emacs-21.1 binary version, ran it, and voila, I've finally got it to work!

There is some warning about a missed lisp library but I can work on that.

Now why was I doing all this again?
Neil O'Brien
Advisor

Re: Backgrounding emacs

more on this....

One of our unix gurus emailed me this:

susp in stty does tsusp signal generation, same thing. So it does look
good from here. Next thing to look at is whether or not the shell is
properly setting up process groups and, particularly, the pgrp of the tty.
I don't know an easy way to check the pgrp of the tty other than writing a
program (BSD sps does it, but it's unlikely you have that program). Now,
just about everything except the old old /bin/sh does that right (and
/bin/sh is just /bin/ksh in HP/UX if I remember right so even that should
work) ... if it can. But there is a case in which it can't.

It's particularly likely that the pgrp stuff is wrong since posix has some
whacked limitations on who can set the tty pgrp. In BSD (where process
groups evolved) any process with access to the tty could set the pgrp. In
posix they changed it so only a process in the same tty session could
change it. If the tty session isn't properly set up then the shell can't
change the pgrp of the tty and signal generation will fail just like you're
seeing. The job of setting that up falls to the terminal program, so if
you're seeing it with one terminal program and not another that could
explain it.

This is typically verifiable with some simple code:
int main()
{
int sid = getsid();
int ppgrp = getpgrp(getppid());
int pgrp = getpgrp();
int tty_pgrp = tcgetpgrp();

/* look to see if parent process is session root */
if (ppgrp != sid) {
printf ("shell pgrp is not the same as session ID\n");
printf ("sid = %d\n", sid);
printf ("ppgrp = %d\n", ppgrp);
}
else
printf ("shell pgrp looks OK\n");


/* look to see if this pid is is in foreground pid on the tty */
if (pgrp != tty_pgrp)
printf ("process isn't the foreground process(expected pgrp %d, got %d)\n", pgrp, tty_pgrp);
else
printf ("tty pgrp looks ok\n");

}

>Ok, got this:
>
>shell pgrp is not the same as session ID
>sid = -1
>ppgrp = 19387
>process isn't the foreground process(expected pgrp 19387, got -1)

Well, that means it's totally broken -- nobody set the session ID when the
pty was set up, and if it's not set then the shell can't do the tty
foreground process configuration and if that's not done then tty-generated
signals don't work (which is what you're seeing).

The only way this happens is if the terminal program neglected to do it or
failed in the attempt. The latter is fairly likely, actually, since a lot
of terminal programs got their start on BSD-derived systems. Those
programs would work under Solaris but will not work under a purer POSIX
system like HP/UX.

My first suggestion would be to try a different terminal program. Failing
that there's a kind of bootstrap way to do it (have the shell exec a
program that sets things up correctly, then have the program re-exec the
shell) but I've not done it in a loooong time, and it varies by OS and even
version of OS, so I can't do that off the top of my head.


so maybe someone here has a better idea of why I am getting these results, and better yet, how to fix them?