os-70-350

os-70-350 Commit Details


Date:2013-12-08 21:54:16 (11 years 8 months ago)
Author:Natalie Adams
Branch:master
Commit:61c88be577cf11039dd5a2ffa0eb7d4c156e6f5f
Parents: 6b8dad3d23bf27231eff188b41c1ba5a59d8a1f1
Message:adding fork example

Changes:

File differences

fork-example/main.c
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
32
33
34
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
pid_t pid;
printf("begin\n");
/* fork a child process */
pid = fork();
printf("pid = %i\n", pid);
if (pid < 0) { /* error occurred */
fprintf(stderr, "Fork Failed");
return 1;
}
else if (pid == 0) { /* child process */
execlp("/bin/ls", "ls", NULL);
}
else { /* parent process */
/* parent will wait for the child to complete */
wait(NULL);
printf("Child Complete");
}
return 0;
/* output:
begin
pid = 15905
pid = 0
[ list of files ]
*/
}

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.49256s using 14 queries.