Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
script3r
GitHub Repository: script3r/os161
Path: blob/master/user/testbin/pt2/pt2.c
734 views
1
#include <unistd.h>
2
#include <sys/wait.h>
3
#include <stdio.h>
4
#include <stdlib.h>
5
6
int main( int argc, char *argv[] ) {
7
pid_t pid = -1;
8
pid_t mypid = -1;
9
10
(void)argc;
11
(void)argv;
12
13
mypid = getpid();
14
pid = fork();
15
if( pid == 0 ) {
16
mypid = getpid();
17
printf( "I'm the child." );
18
}
19
else {
20
printf( "I'm the parent. %d\n", mypid );
21
}
22
23
return 0;
24
}
25
26