Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rdemeter
GitHub Repository: rdemeter/so
Path: blob/master/lab3/ex1_fork.c
221 views
1
#include <stdio.h>
2
#include <sys/types.h>
3
#include <unistd.h>
4
#include <stdlib.h>
5
6
int main()
7
{
8
pid_t pid;
9
switch (pid = fork())
10
{
11
case -1: /* fork failed */
12
printf("fork failed\n");
13
exit(-1);
14
case 0: /* child starts executing here */
15
default: /* parent starts executing here */
16
printf("created process with pid %d\n", getpid());
17
}
18
getchar();
19
}
20
21