get the parent process ID
#include <sys/types.h> #include <unistd.h> pid_t getppid( void );
The getppid() function allows the calling process to find out its parent's identity.
The calling process's parent's process ID.
/* * Print the parent's process ID. */ #include <stdio.h> #include <sys/types.h> #include <unistd.h> void main() { printf( "My parent is %d\n", getppid() ); }
POSIX 1003.1
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |