getpid(2)getpid(2)NAMEgetpid(), getpgid(), getpgrp(), getpgrp2(), getppid() - get process,
process group and parent process ID.
SYNOPSISDESCRIPTION
These functions return process, process group and parent process IDs,
as follows:
Process group ID of the specified process.
If pid is zero, the call applies to the
calling process. Same result as
Process group ID of the calling process.
Process group ID of the specified process.
If pid is zero, the call applies to the
calling process. Same result as
Process ID of the calling process.
Parent process ID of the calling process.
If the parent process is the initialization
process (known as the call returns 1.
Security Restrictions
The system call is subject to compartmental restrictions. See compartā
ments(5) for more information about compartmentalization on systems
that support that feature.
Compartmental restrictions can be overridden if the process possesses
the 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:
Successful completion.
n is a nonnegative process ID, as described above.
Failure:
and only. is set to indicate the error.
ERRORS
If or fails, 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
and were developed by HP, AT&T, and the University of California,
Berkeley.
SEE ALSOexec(2), fork(2), setpgid(2), setsid(2), signal(5).
STANDARDS CONFORMANCEgetpid(2)