Skip to content

Instantly share code, notes, and snippets.

Created Jan 21, 2013
What would you like to do?
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment