Skip to content

Instantly share code, notes, and snippets.

@nicdoye
Created January 21, 2013 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicdoye/4585369 to your computer and use it in GitHub Desktop.
Save nicdoye/4585369 to your computer and use it in GitHub Desktop.
Quick demo of getpid (and getppid)
#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