getpid.2 (2010 09)
g
getpid(2) getpid(2)
NAME
getpid(), getpgid(), getpgrp(), getpgrp2(), getppid() - get process, process group and parent process ID.
SYNOPSIS
#include <unistd.h>
pid_t getpgid (pid_t pid);
pid_t getpgrp(void);
pid_t getpgrp2(pid_t pid);
pid_t getpid(void);
pid_t getppid(void);
DESCRIPTION
These functions return process, process group and parent process IDs, as follows:
getpgid() Process group ID of the specified process. If pid is zero, the call applies to the
calling process. Same result as
getpgrp2().
getpgrp() Process group ID of the calling process.
getpgrp2() Process group ID of the specified process. If pid is zero, the call applies to the
calling process. Same result as
getpgid().
getpid() Process ID of the calling process.
getppid() Parent process ID of the calling process. If the parent process is the initializa-
tion process (known as
init), the call returns 1.
Security Restrictions
The
getpgrp2 system call is subject to compartmental restrictions. See compartments (5) for more infor-
mation about compartmentalization on systems that support that feature.
Compartmental restrictions can be overridden if the process possesses the
COMMALLOWED privilege
(PRIV_COMMALLOWED). Processes owned by the superuser may not have this privilege. Processes
owned by any user may have this privilege, depending on system configuration. See privileges (5) for
more information about privileged access on systems that support fine-grained privileges.
RETURN VALUE
The functions return the following values:
n Successful completion. n is a nonnegative process ID, as described above.
-1 Failure: getpgid() and getgrp2() only. errno is set to indicate the error.
ERRORS
If
getpgid() or getpgrp2() fails, errno is set to one of the following values:
[EPERM] The current process and pid are not in the same session (see setsid (2)).
[ESRCH] No process can be found corresponding to that specified by pid .
AUTHOR
getpid(), getppid(), getpgrp(), and getpgrp2() were developed by HP, AT&T, and the
University of California, Berkeley.
SEE ALSO
exec(2), fork(2), setpgid(2), setsid(2), signal(5).
STANDARDS CONFORMANCE
getpid(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
getpgrp(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
getppid(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1