-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.c
More file actions
29 lines (28 loc) · 744 Bytes
/
Copy pathprocess.c
File metadata and controls
29 lines (28 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
#include<sys/wait.h>
#include<stdlib.h>
void main()
{
pid_t childpid= fork();
if(childpid==0)
{
printf("The child process is created succesfully and is in the child process");
printf("\nParent id : %d\n",getppid());
printf("Child id : %d\n",getpid());
}
if(childpid>0)
{
printf("The child process is created succesfully and is in the parent process");
printf("\nParent id: %d\n",getpid());
printf("Child id: %d\n",childpid);
wait(NULL);
printf("The child process is terminated and the parent process is changed from its waiting state to running state\n");
}
if(childpid<0)
{
printf("The child process is not created \n");
}
exit(0);
}