setpgid()--Set Process Group ID for Job Control
Syntax
#include <sys/types.h>
#include <unistd.h>
int setpgid(pid_t pid, pid_t pgid);
Service Program Name: QP0WSRV1
Default Public Authority: *USE
Threadsafe: Yes
The setpgid() function is used to either join an existing
process group or create a new process group within the session of the calling
process.
See the Usage Notes for considerations in using
setpgid().
Parameters
- pid
- (Input) The process ID of the process whose process group ID is to be
changed. When pid has a value of zero, the process group ID of the
calling process is changed.
- pgid
- (Input) The process group ID to be assigned to the process whose process ID
matches pid. The value of pgid must be within the range of
zero through the maximum signed integer. When pgid/em> has a value of zero,
the process group ID is set to the process ID of the process indicated by
pid.
Authorities
The process calling setpgid() must have the appropriate
authority to the process being changed. A process is allowed to access the
process group ID for a process if at least one of the following conditions is
true:
- The process is calling setpgid() for its own process.
- The process has *JOBCTL special authority defined in the process user
profile or in a current adopted user profile.
- The process is the parent of the process (the process being examined has a
parent process ID equal to the process ID of the process calling
setpgid()).
- The real or effective user ID of the process matches the real or effective
user ID of the process calling setpgid()).
Return Value
0 |
setpgid() was successful. |
-1 |
setpgid() was not successful.
The errno variable is set to indicate the error. |
Error Conditions
If setpgid() is not successful, errno usually
indicates one of the following errors. Under some conditions, errno could
indicate an error other than that listed here.
- [EINVAL]
-
The value specified for the argument is not correct.
A function was passed incorrect argument values, or an operation was
attempted on an object and the operation specified is not supported for that
type of object.
An argument value is not valid, out of range, or NULL.
- [EPERM]
-
Operation not permitted.
You must have appropriate privileges or be the owner of the object or other
resource to do the requested operation.
- [ESRCH]
-
No item could be found that matches the specified value.
- i5/OS does not support sessions. Until session support is available on
i5/OS, the restriction that the process group must be within the session of
the calling process will not be enforced.
- The setpgid() function fails if a nonzero process group ID
is specified and that process group does not exist. If this occurs, the return
value is set to -1 and errno is set to [EPERM].
Related Information
API introduced: V3R6