Parent Process ID

Table of contents:

Every process has an associated parent process ID ( PPID ). The parent process is the process that forked (generated) the child process. The ID of the parent process can be obtained by using the system call getppid (Table 2.2).

Table 2.2. Summary of the getppid System Call.

Include File(s)


Manual Section



Pid_t getppid( void );




Sets errno

The parent process ID



Like the getpid system call, getppid does not require an argument. If it is successful, it will return the PID number of the parent process. The getppid call will fail, returning a value of -1 and setting errno to EPERM (1) if the calling process does not have the proper access permissions.

The following code segment displays the PPID:

cout << "My Parent Process ID is " << getppid( ) << endl;

Unfortunately, there is no system call that allows a parent process to determine the PIDs of all its child processes. If such information is needed, the parent process should save the returned child PID value from the fork system call as each child process is created.


The manual page entry for the getppid system call does not specifically indicate what is returned by getppid if the parent process is no longer present when the getppid call is made. Write a program that displays the value returned by getppid when such an event occurs (the parent predeceases the child). How did you assure that the parent process was not present when the child process made its getppid call?

Programs and Processes

Processing Environment

Using Processes

Primitive Communications


Message Queues


Shared Memory

Remote Procedure Calls



Appendix A. Using Linux Manual Pages

Appendix B. UNIX Error Messages

Appendix C. RPC Syntax Diagrams

Appendix D. Profiling Programs

Interprocess Communication in Linux
Interprocess Communications in Linux: The Nooks and Crannies
ISBN: 0130460427
EAN: 2147483647
Year: 2001
Pages: 136 © 2008-2020.
If you may any questions please contact us: