Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

System Functions (s and S) setpgrp(2)
NAME
setpgrp - Sets the process group ID
LIBRARY
G-series native OSS processes: system library
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
pid_t setpgrp(void);
DESCRIPTION
The setpgrp() function creates a new session when the calling process is not a process group
leader. The calling process then becomes the session leader of this session and the process
leader of a new process group, and it has no controlling terminal. The process group ID of the
calling process is set equal to its OSS process ID. The calling process becomes the only process
in the new process group and the only process in the new session.
If the calling process is already a session group leader, the call fails and errno is set to
[EPERM].
Use From the Guardian Environment
Calls to setpgrp() from Guardian processes are not successful. Such calls return an errno value
of [ENOTOSS].
NOTES
The setpgrp() function is equivalent to the setsid() function.
RETURN VALUES
Upon successful completion, the value of the new process group ID is returned. If the call was
unsuccessful and initiated by an OSS process, the value -1 is returned and errno is set to indicate
the error. If unsuccessful and initiated by a Guardian process, Guardian trap number 5 is set.
ERRORS
If any of these conditions occurs, the setpgrp() function sets errno to the corresponding value:
[ENOTOSS] The calling process is not an OSS process. The requested operation is not sup-
ported from the Guardian environment.
[EPERM] One of these conditions exists:
The calling process is already the process group leader.
The process group ID of a process other than the calling process matches
the OSS process ID of the calling process.
RELATED INFORMATION
Functions: setpgid(2), setsid(2).
STANDARDS CONFORMANCE
The following errno values are HP extensions to the XPG4 Version 2 specification:
The errno values [ENOTOSS] and [EPERM] can be returned.
527186-023 Hewlett-Packard Company 763