[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Aug 23 21:14:29 1993 
Subject:How to spawn an independent sub-process from Pop-11? 
From:"A.Sloman" 
Volume-ID:930823.06 

I wonder if anyone else has encountered this. I want a Pop11 procedure
to be able to spawn an xterm process which then runs some program
(e.g. pop11, eliza, top, etc.) in the xterm window. And I want to be
able to do it from inside VED.

I have two problems.

(a) If I spawn the process from inside VED it starts up with the
wrong terminal setting. In particular "stty crt" is not set so that
character deletion does not echo properly.

(b) The spawned process is sensitive to interrupts typed to the
original window, so if you type CTRL-C to the original, the
spawned xterm window dies.

Here's my first attempt to be able to give the command "ENTER eliza"
to run eliza in a new window (merely an illustrative example).

define ved_eliza;
    sysobey('xterm -e eliza &')
enddefine;

1. Unfortunately, when it starts up,  the terminal setting is wrong for
an xterm window and I get Delete characters echoed as "^?".

If, in the original pop11 process, I do ENTER pop, to get the pop11
toplevel prompt, and then run ved_eliza(); the terminal setting
in the new window is right.

So it has something to do with the original being run while ved is
active. Presumably the xterm inherits the terminal settings of the
parent.

So I thought I would change the terminal setting from raw to cooked,
and give a slight delay (which turned out to be essential):


define ved_eliza;
    vedscreencooked();              ;;; i.e. terminal echoing properly
    sysobey('xterm -e eliza &')
    syssleep(100);                  ;;; wait one second
enddefine;

Then indeed ENTER eliza spawns a new xterm window with eliza, and with
proper echoing of delete. But it's not an acceptable solution because I
can't tell how long the interval for syssleep should be, as that will
depend on loading on the machine.

Another solution is to write a file that starts with "stty crt", and run
that in the background via sysobey, or compose a complete command to
give as argument to sysobey

Unfortunately there's no way to give xterm the "stty" command to run in
its new window. The "-tm" flag can be used to set particular control
characters, not but echoing.

2. Worse, although I have found work-arounds, such as use of syssleep,
to the problem of terminal setting being wrong, I have not found how to
stop the xterm process being killed as soon as I type CTRL-C in the
original window. I have tried using nohup, but to no avail.

Any ideas, or is it simply impossible to use sysobey to spawn a
background process that is not interruptable simply by typing
CTRL-C in the original window?

Thanks
Aaron