setpgid()

set process group 

Function


SYNOPSIS

#include <sys/types.h>

#include <unistd.h>

int setpgid(pid_t pid, pid_t pgid);


DESCRIPTION

The setpgid() function is used to either 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 does not change. Upon successful completion, the process group ID of the process with a process ID that matches pid is set to pgid. As a special case, if pid is zero, the process ID of the calling process is used. Also, if pgid is zero, the group ID of the indicated process is used.


PARAMETERS

pid 

Is the process to set. If zero, the current process ID is used.

pgid 

Is the new process group ID. If zero, the process group ID of pid is used.


RETURN VALUES

If successful, setpgid() returns a value of zero. On failure, it returns a value of -1 and sets errno to one of the following values:

EACCES 

The value of pid matches the process ID of a child process of the calling process, and the child process has successfully executed one of the exec() functions.

EINVAL 

The value of pgid is less than 0 or is greater than or equal to PID_MAX.

EPERM 

pgid does not match the process ID of the process indicated by the pid parameter, and there is no process with a process group ID that matches pgid in the same session as the calling process.

The process that pid indicates is a session leader.

The value of pid is valid but matches the process ID of a child process of the calling process, and the child process is not in the same session as the calling process.

ESRCH 

The value of pid does not match the process ID of the calling process or of a child process of the calling process.


CONFORMANCE

POSIX.1 (1996)


MULTITHREAD SAFETY LEVEL

Async-signal-safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
execl(), execle(), execlp(), execv(), execve(), execvp(), fork(), getpgid(), getpid(), getsid(), setpgrp(), setsid(), tcsetpgrp()


PTC MKS Toolkit 10.3 Documentation Build 39.