forky.c
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <err.h>
|
||||
|
||||
int forky(){
|
||||
|
||||
pid_t pid = fork();
|
||||
|
||||
if (pid < 0) return -1;
|
||||
else if (pid == 0){
|
||||
printf("I am the child!\n");
|
||||
exit(0);
|
||||
}
|
||||
else{
|
||||
printf("I am the parent!\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
int main(){
|
||||
|
||||
int res = forky();
|
||||
printf("%d\n", res);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user