Created
January 21, 2013 11:16
-
-
Save nicdoye/4585369 to your computer and use it in GitHub Desktop.
Quick demo of getpid (and getppid)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/types.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
int main ( int argc, char *argv[] ) | |
{ | |
pid_t p; | |
pid_t pp; | |
p = getpid(); | |
pp = getppid(); | |
/* Cheap and cheerful, Linux only: pid_t is an int */ | |
printf("Pid: %d\nParent Pid: %d\n", (int) p, (int) pp); | |
exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment