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
greater than 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
following errno
error conditions are defined for this function:
EBADF
ENOSYS
ENOTTY
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 SIGTTOU
signal. The exception is if the calling process itself is ignoring or
blocking SIGTTOU
signals, in which case the operation is
performed and no signal is sent.
If successful, tcsetpgrp
returns 0
. A return value of
-1
indicates an error. The following errno
error
conditions are defined for this function:
EBADF
EINVAL
ENOSYS
ENOTTY
EPERM
(pid_t) -1
and the global variable errno
is set to the following value:
EBADF
ENOTTY
Go to the first, previous, next, last section, table of contents.