How to fool interactive applications into running in the background

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Mon Aug 20 00:06:05 AEST 1990


In article <1990Aug14.180215.2913 at cs.utk.edu> richards at utkcs2.cs.utk.edu (Jon T Richardson) writes:
> I was wondering if there was a way to process KILL files and bring
> the .newsrc up to date in the background.  I sometimes spend an inordinate 
> amount of time (as much as 5 minutes) waiting for rn to kill articles
> and skip unavailable ones.  Surely there is some tool out there that
> does this.

You could take Jon Kamens' advice and use a shell script; or you could
use Brad Templeton's Newsclip package. But this problem is much more
general. ``Various newsreaders and editors refuse to process anything in
the background, but they take forever for initial processing. How can I
do something else while they start up?''

The answer is pty 3.0. I usually do

  % pty -T rn &

rn gets stuck under a pty and doesn't see that it's in the background,
so it continues processing as if it were in the foreground.

-T means to leave the original tty alone, so that control characters,
backgrounding, and so on affect sess rather than rn.

At some point rn finishes processing and stops waiting for input. pty,
which understands job control perfectly, stops too and waits for me. I
fg and continue with rn. That's it!

Sometimes I want control characters to be passed through to the program
under pty. In this case I do pty -sT (or sess -T), which sets up a
disconnectable session. Then, when I want to get back in, I kill the job
rather than foregrounding it. Then % sess reconnect p7 (or whatever tty)
gets me back in.

Another side effect of pty -T rn & is that output comes onto my screen
as it's produced---I don't have stty tostop set. This is the behavior I
usually want. However, when I'm starting vi on a long file, I don't want
its output interfering with whatever else I'm doing. So I use

  % sess sh -c 'sessname;disconnect;vi foo'

This starts a session, prints its name, immediately disconnects it, and
then starts vi running under the session. I check vi with ps; when it
goes idle, I reconnect, and it's as if I hadn't used pty at all.

Followups to comp.unix.questions.

---Dan
pty 3.0 c.s.unix submission: ask brnstnd at nyu.edu.



More information about the Comp.unix.questions mailing list