how to suspend a process

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Tue Feb 19 08:14:15 AEST 1991


In article <9999 at dog.ee.lbl.gov> torek at elf.ee.lbl.gov (Chris Torek) writes:
  [ summary of one way to handle TSTP ]

Yeah. It's actually sort of funny watching programs which don't know how
to deal with this: give rn some ^Zs and bgs and it goes into never-never
land. Start it in the background and you're in really deep trouble.

But this begs the question of why the default signal handler operations
aren't available as atomic syscalls in the first place. stop(), tstp(),
ttin(), ttou(), and abrt() (preferably with a filename) are trivial to
add to the kernel, would eliminate the need for several signal-handling
kludges, and would make any character-mode program a lot cleaner.

> If the reason you are catching signals is that you modify a tty state
> (e.g., use CBREAK/not-ICANON mode), you should be careful to pick up
> the new state after the stop.

This is a matter of opinion. Some people believe that the shell should
handle all tty mode changes, including restoring modes after a stop or
termination. Then the shell alone can decide whether to pick up the new
state or not. This too would make the system a lot cleaner: programmers
would not have to repeat the same tty mode munging and signal handling
code in every application. Writing a no-echo, character-mode program
wouldn't require ioctl() or signal() or anything else.

(Of course, the programmer could just run pty -pEc foo to run foo under
a no-echo, character-mode pseudo-tty. Since pty groks job control, foo
doesn't need to handle signals either. But I won't pretend that this is
the right solution. It should not require an extra program and tty just
to do something that the shell should do automatically.)

---Dan



More information about the Comp.unix.questions mailing list