Created
February 15, 2015 14:24
-
-
Save mtmr/a0d584cebfecaca20d80 to your computer and use it in GitHub Desktop.
printpid.c
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
/* 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