Node:Process Group Functions, Next:Terminal Access Functions, Previous:Identifying the Terminal, Up:Functions for Job Control
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.
pid_t setsid (void) | Function |
The setsid function 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. The
|
pid_t getsid (pid_t pid) | Function |
The In case of error
|
The 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 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
_POSIX_SOURCE
or _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.
pid_t getpgrp (void) | POSIX.1 Function |
The POSIX.1 definition of getpgrp returns the process group ID of
the calling process.
|
pid_t getpgrp (pid_t pid) | BSD Function |
The BSD definition of getpgrp returns the process group ID of the
process pid. You can supply a value of 0 for the pid
argument to get information about the calling process.
|
int getpgid (pid_t pid) | System V Function |
In case of error
|
int setpgid (pid_t pid, pid_t pgid) | Function |
The setpgid function 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 Job Control is Optional, for more information. If the operation is successful,
|
int setpgrp (pid_t pid, pid_t pgid) | Function |
This is the BSD Unix name for setpgid . Both functions do exactly
the same thing.
|