Here are descriptions of the functions for manipulating process groups. Your program should include the header files `sys/types.h' and `unistd.h' to use these functions.
setsidfunction creates a new session. The calling process becomes the session leader, and is put in a new process group whose process group ID is the same as the process ID of that process. There are initially no other processes in the new process group, and no other process groups in the new session.
This function also makes the calling process have no controlling terminal.
setsid function returns the new process group ID of the
calling process if successful. A return value of
-1 indicates an
error. The following
errno error conditions are defined for this
getpgrp function has two definitions: one derived from BSD
Unix, and one from the POSIX.1 standard. The feature test macros you
have selected (see section Feature Test Macros) determine which definition
you get. Specifically, you get the BSD version if you define
_BSD_SOURCE; otherwise, you get the POSIX version if you define
_GNU_SOURCE. Programs written for old
BSD systems will not include `unistd.h', which defines
getpgrp specially under
_BSD_SOURCE. You must link such
programs with the
-lbsd-compat option to get the BSD definition.
getpgrpreturns the process group ID of the calling process.
getpgrpreturns the process group ID of the process pid. You can supply a value of
0for the pid argument to get information about the calling process.
setpgidfunction puts the process pid into the process group pgid. As a special case, either pid or pgid can be zero to indicate the process ID of the calling process.
This function fails on a system that does not support job control. See section Job Control is Optional, for more information.
If the operation is successful,
setpgid returns zero. Otherwise
-1. The following
errno error conditions are
defined for this function:
execfunction since it was forked.
setpgid. Both functions do exactly the same thing.
Go to the first, previous, next, last section, table of contents.