Skip to content

Instantly share code, notes, and snippets.

@mtmr
Created February 15, 2015 14:24
Show Gist options
  • Save mtmr/a0d584cebfecaca20d80 to your computer and use it in GitHub Desktop.
Save mtmr/a0d584cebfecaca20d80 to your computer and use it in GitHub Desktop.
printpid.c
/* Copyright 2001 */
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main(void) {
printf("%ld %ld", (long)getpid(), (long)getppid());
pid_t pid = fork();
if(pid == 0)
{
printf("Hello World %ld", (long)getpid());
execl("/bin/ls", "-a",(char *)0);
}
else
if(pid == -1)
printf("Failed");
else
printf("HEllo Small world %ld", (long)getpid());
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment