Created
August 29, 2020 10:21
-
-
Save cs-fedy/8ce5bd6cba5a233442038697b5afd9d4 to your computer and use it in GitHub Desktop.
process creation using posix in c.
This file contains hidden or 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
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/wait.h> | |
int main() { | |
int x, y; | |
x = fork(); | |
if (x == 0) { | |
printf("I'm the child %d of %d\n", getpid(), getppid()); | |
exit(3); | |
} else if (x == -1) { | |
printf("error!!\n"); | |
} else { | |
y=wait(NULL); | |
printf("hello world it is me the father of %d and the child of %d\n", y, getppid()); | |
printf("==== the end ====\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment