[Linux manuál]
Návod, kniha: POSIX Programmer's Manual
int setpgid(pid_t pid, pid_t
pgid );
setpgid: nastavit ID skupiny procesů pro řízení úlohy
Originální popis anglicky: setpgid - set process group ID for job controlNávod, kniha: POSIX Programmer's Manual
STRUČNĚ
#include <unistd.h>POPIS / INSTRUKCE
The setpgid() function shall 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 shall not change. Upon successful completion, the process group ID of the process with a process ID that matches pid shall be set to pgid. As a special case, if pid is 0, the process ID of the calling process shall be used. Also, if pgid is 0, the process ID of the indicated process shall be used.NÁVRATOVÁ HODNOTA
Upon successful completion, setpgid() shall return 0; otherwise, -1 shall be returned and errno shall be set to indicate the error.CHYBY / ERRORY
The setpgid() function shall 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.
- EPERM
- 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.
- EPERM
- 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.
PŘÍKLADY POUŽITÍ
None.APPLICATION USAGE
None.RATIONALE
The setpgid() function shall group processes together for the purpose of signaling, placement in foreground or background, and other job control actions. The setpgid() function is similar to the setpgrp() function of 4.2 BSD, except that 4.2 BSD allowed the specified new process group to assume any value. This presents certain security problems and is more flexible than necessary to support job control. To provide tighter security, setpgid() only allows the calling process to join a process group already in use inside its session or create a new process group whose process group ID was equal to its process ID. When a job control shell spawns a new job, the processes in the job must be placed into a new process group via setpgid(). There are two timing constraints involved in this action:- 1.
- The new process must be placed in the new process group before the appropriate program is launched via one of the exec functions.
- 2.
- The new process must be placed in the new process group before the shell can correctly send signals to the new process group.
FUTURE DIRECTIONS
None.SOUVISEJÍCÍ
exec() , getpgrp() , setsid() , tcsetpgrp() , the Base Definitions volume of IEEE Std 1003.1-2001, <sys/types.h>, <unistd.h>COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .| 2003 | IEEE/The Open Group |