DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

getpid(S)


getpid, getpgrp, getppid, getpgid -- get process, process group, and parent process IDs

Synopsis

   #include <sys/types.h>
   #include <unistd.h>
   

pid_t getpid(void);

pid_t getpgrp(void);

pid_t getppid(void);

pid_t getpgid(pid_t 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.

Return values

On success, getpgid returns a process group ID. On failure, getpgid returns (pid_t) -1 and sets errno to identify the error.

Errors

In the following conditions, getpgid fails and sets errno to:

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 process from the calling process.

ESRCH
There is no process with a process ID equal to pid.

References

exec(S), fork(S), getsid(S), intro(S), setpgid(S), setpgrp(S), setsid(S), signal(S)

Notices

Considerations for threads programming

These ID numbers are attributes of the containing process and are shared by sibling threads.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005