gtpc2m3x | C/C++ Language Support User's Guide |
This function permits a process to obtain the process identifier (ID) of its parent process.
Format
#include <unistd.h> pid_t getppid(void);
Normal Return
The getppid function is always successful.
If the calling process was created by the tpf_fork function and the parent process still exists at the time of the getppid function call, this function returns the process ID of the parent process. Otherwise, this function returns a value of 1.
Error Return
Not applicable.
Programming Considerations
None.
Examples
The following example shows how to print the parent process ID.
#include <stdio.h> #include <unistd.h>
·
·
·
printf("Parent PID = %d\n", getppid()); {
Related Information