What "isatty"?

Stephen Pope scp at raven.lanl.gov
Tue May 23 09:20:24 AEST 1989


Well, as long as we're on the subject, I'm curious in general how
a process can know whether it is in the foreground or background.
We've got a program that does non-blocking reads on all sorts of
file handles, including stdin (this is a means for interactive
input only; you would not feed it a disk file or the like).
It would be very useful to know whether we were in foreground
(and should thus look for input from the keyboard) or background
(and thus should not expect any).  Trying to use isatty() is
not an answer - as we'd like the program, in a given instantiation,
to be moved from fg to bg and back using the usual job control,
and maybe left running after the user logs out the controlling terminal.

How is this best done?

Stephen Pope
Santa Fe Institute
scp at sfi.santafe.edu



More information about the Comp.unix.wizards mailing list