getpid(2) getpid(2)
NAME
getpid, getpgrp, getppid, getpgid - get process IDs
SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
pidt getpid(void);
pidt getpgrp(void);
pidt getppid(void);
pidt getpgid(pidt pid);
DESCRIPTION
getpid() returns the process ID of the calling process.
getpgrp() returns the process group ID of the calling process.
getppid() returns the parent process ID of the calling process.
getpgid() returns the process group ID of the process whose process ID
is equal to pid, or the process group ID of the calling process, if
pid is equal to zero.
ERRORS
The following error code descriptions are function-specific. You will
find a general description in introprm2(2) or in errno(5).
getpgid() will fail if one or more of the following apply:
EPERM The process whose process ID is equal to pid is not in the
same session as the calling process, and the implementation
does not allow access to the process group ID of that pro-
cess from the calling process.
ESRCH There is no process with a process ID equal to pid.
The getpgid() function may fail if:
EINVAL The value of the pid argument is invalid.
RESULT
Upon successful completion, getpgid() returns a process group ID. Oth-
erwise, a value of (pidt)-1 is returned and errno is set to indicate
the error.
SEE ALSO
exec(2), fork(2), getpid(2), getsid(2), setpgid(2), setsid(2),
setpgrp(2), signal(2), unistd(4), types(5).
Page 1 Reliant UNIX 5.44 Printed 11/98