Open System Services System Calls Reference Manual (G06.25+, H06.03+)
setpgid(2) OSS System Calls Reference Manual
NAME
setpgid - Sets the process group ID for job control
LIBRARY
G-series native OSS processes: system library
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <unistd.h>
int setpgid(
pid_t pid,
pid_t pgid);
PARAMETERS
pid Specifies the process whose process group ID is to be changed.
pgid Specifies the new process group ID.
DESCRIPTION
The setpgid() function is used either to join an existing process group or to create a new process
group within the session of the calling process. The process group ID of a session leader will not
change.
The process group ID of the process designated by the pid parameter is set to the value of the
pgid parameter. If pid is 0 (zero), the process ID of the calling process is used. If pgid is 0
(zero), the process ID of the indicated process is used.
Use From the Guardian Environment
Calls to setpgid() from Guardian processes are not successful. Such calls return an errno value
of [ENOTOSS].
RETURN VALUES
Upon successful completion, the value 0 (zero) is returned. If the call was unsuccessful and ini-
tiated by an OSS process, the value -1 is returned and errno is set to indicate the error. If unsuc-
cessful and initiated by a Guardian process, Guardian trap number 5 is set.
ERRORS
If any of the following conditions occurs, the setpgid() function sets errno to the corresponding
value:
[EACCES] The value of the pid parameter matches the process ID of a child process of the
calling process, and the child process has successfully executed one of the exec,
tdm_exec,ortdm_spawn set of functions.
[EINVAL] One of the following conditions exists:
• The value of the pgid parameter is less than 0 (zero).
• The value of the pgid parameter is not a valid OSS process ID.
• Either the pgid or pid parameter is out of range.
[ENOTOSS] The calling process is not an OSS process. The requested operation is not sup-
ported from the Guardian environment.
7−34 Hewlett-Packard Company 527186-003