Skip to content

Instantly share code, notes, and snippets.

@nicdoye

nicdoye/getpid.c

Created Jan 21, 2013
Embed
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);
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.