-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.c
More file actions
31 lines (27 loc) · 725 Bytes
/
Copy pathstring.c
File metadata and controls
31 lines (27 loc) · 725 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
30
31
/*Create a new process using a fork system call. The child process should print the string
“PCCSL407” and the parent process should print the string “Operating Systems Lab”.
Use a wait system call to ensure that the output displayed is “PCCSL407 Operating
Systems Lab” */
#include<stdio.h>
#include<unistd.h>
#include<sys/wait.h>
int main()
{
pid_t pid;
pid = fork();
if(pid == 0)
{
printf("PCCSL4O7 ");
}
else if(pid > 0)
{
wait(NULL);
printf("Operating Systems Lab\n");
}
else
{
printf("Error occured!\n");
return -1;
}
return 0;
}