getpid(2) getpid(2)
NAME [Toc] [Back]
getpid(), getpgid(), getpgrp(), getpgrp2(), getppid() - get process,
process group and parent process ID.
SYNOPSIS [Toc] [Back]
#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 [Toc] [Back]
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 [Toc] [Back]
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 [Toc] [Back]
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)).
Hewlett-Packard Company - 1 - HP-UX 11i Version 2: August 2003
getpid(2) getpid(2)
[ESRCH] No process can be found corresponding to that
specified by pid.
AUTHOR [Toc] [Back]
getpid(), getppid(), getpgrp(), and getpgrp2() were developed by HP,
AT&T, and the University of California, Berkeley.
SEE ALSO [Toc] [Back]
exec(2), fork(2), setpgid(2), setsid(2), signal(5).
STANDARDS CONFORMANCE [Toc] [Back]
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
Hewlett-Packard Company - 2 - HP-UX 11i Version 2: August 2003 [ Back ] |