Node:Terminal Access Functions, Previous:Process Group Functions, Up:Functions for Job Control
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.
pid_t tcgetpgrp (int filedes) | Function |
This function returns the process group ID of the foreground process
group associated with the terminal open on descriptor filedes.
If there is no foreground process group, the return value is a number
greater than In case of an error, a value of
|
int tcsetpgrp (int filedes, pid_t pgid) | Function |
This function is used to set a terminal's foreground process group ID.
The argument filedes is a descriptor which specifies the terminal;
pgid specifies the process group. The calling process must be a
member of the same session as pgid and must have the same
controlling terminal.
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 If successful,
|
pid_t tcgetsid (int fildes) | Function |
This function is used to obtain the process group ID of the session
for which the terminal specified by fildes is the controlling terminal.
If the call is successful the group ID is returned. Otherwise the
return value is (pid_t) -1 and the global variable errno
is set to the following value:
|