new FormProcess source code
This commit is contained in:
21
Practice_05/forkProcess.c
Normal file
21
Practice_05/forkProcess.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
int pid;
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if(pid < 0){
|
||||||
|
printf("Error\n");
|
||||||
|
exit(-1);
|
||||||
|
}else if(pid == 0){
|
||||||
|
printf("Child\n");
|
||||||
|
exit(0);
|
||||||
|
}else{
|
||||||
|
printf("Parent\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user