These are the functions for reading or setting the foreground process group of a terminal. You should include the header files `sys/types.h' and `unistd.h' in your application to use these functions.
Although these functions take a file descriptor argument to specify the terminal device, the foreground job is associated with the terminal file itself and not a particular open file descriptor.
If there is no foreground process group, the return value is a number
1 that does not match the process group ID of any
existing process group. This can happen if all of the processes in the
job that was formerly the foreground job have terminated, and no other
job has yet been moved into the foreground.
In case of an error, a value of
-1 is returned. The
errno error conditions are defined for this function:
For terminal access purposes, this function is treated as output. If it
is called from a background process on its controlling terminal,
normally all processes in the process group are sent a
signal. The exception is if the calling process itself is ignoring or
SIGTTOU signals, in which case the operation is
performed and no signal is sent.
0. A return value of
-1 indicates an error. The following
conditions are defined for this function:
Go to the first, previous, next, last section, table of contents.