The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

setpgid - set process group ID for job control

 SYNOPSIS



#include <sys/types.h>
#include <unistd.h>

int setpgid(pid_t pid, pid_t pgid);

 DESCRIPTION

The setpgid() function is used either to join an existing process group or create a new process group within the session of the calling process. The process group ID of a session leader will not change. Upon successful completion, the process group ID of the process with a process ID that matches pid will be set to pgid. As a special case, if pid is 0, the process ID of the calling process will be used. Also, if pgid is 0, the process group ID of the indicated process will be used.

 RETURN VALUE

Upon successful completion, setpgid() returns 0. Otherwise -1 is returned and errno is set to indicate the error.

 ERRORS

The setpgid() function will fail if:
[EACCES]
The value of the pid argument 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 the pgid argument is less than 0, or is not a value supported by the implementation.
[EPERM]
The process indicated by the pid argument is a session leader. The value of the pid argument 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. The value of the pgid argument is valid but does not match the process ID of the process indicated by the pid argument and there is no process with a process group ID that matches the value of the pgid argument in the same session as the calling process.
[ESRCH]
The value of the pid argument does not match the process ID of the calling process or of a child process of the calling process.

 EXAMPLES

None.

 APPLICATION USAGE

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

exec, getpgrp(), setsid(), tcsetpgrp(), <sys/types.h>, <unistd.h>.

DERIVATION

Derived from the POSIX.1-1988 standard.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]