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.
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.
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