Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

setpgrp(2)

getpgrp(2)

getuid(2)

termio(7)

exec(2)

fork(2)

intro(2)

getpid(2)

kill(2)

signal(2)

setpgid(2)

NAME

setpgid − set process group

SYNOPSIS

#include <sys/types.h>
 
int setpgid (pid,pgid)
pid_t pid;
pid_t pgid;

DESCRIPTION

The setpgid() service is used to either 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 cannot be changed.  Upon successful completion, the process group ID of the process with a process ID that matched pid shall be set to pgid.  As a special case, if pid is zero, the process ID of the calling process shall be used.  Also, if pgid is zero, the process ID of the indicated process shall be used. 

The value of the pgid argument must match the process ID of the process indicated by the pid argument or must match the value of another process ID in the same session as the process indicated by the pid argument. 

A process may set its own process group if it is not a session leader. 

A process may set the process group of another process if that process is a child process, the child process is in the same session, and the child process has not successfully executed one of the exec functions. 

Process groups are used for distribution of signals, and by terminals to arbitrate requests for their input: processes which have the same process group as the terminal are foreground and may read, while others will block with a signal if they attempt to read. 

RETURN VALUE

If an error occurs, the value −1 is returned, and a more precise error code is placed in the global variable errno.  If the call succeeds then a value of zero is returned. 

ERRORS

setpgid will fail and the process group will not be altered if one of the following occur:

[EACCESS] The value if 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 not a valid value. 

[EPERM] The process indicated by the pid argument is a session leader. 
 
The value of the pid argument 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. 
 
The value of the pgid argument 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. 

SEE ALSO

setpgrp(2), getpgrp(2), getuid(2), termio(7), exec(2), fork(2), intro(2), getpid(2), kill(2), signal(2). 

CX/UX Programmer’s Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026