/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- main
1 /*
2 * onefork - simple test of fork
3 *
4 * relies only on fork, console write, and _exit
5 *
6 * parent prints "P", child prints "C", both exit
7 *
8 */
9
10 #include <unistd.h>
11 #include <string.h>
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <err.h>
15
16 int
17 main(int argc, char *argv[])
18 {
19 (void)argc;
20 (void)argv;
21 pid_t pid;
22 pid = fork();
23 if (pid < 0) {
24 warn("fork");
25 }
26 else if (pid == 0) {
27 /* child */
28 putchar('C');
29 putchar('\n');
30 }
31 else {
32 /* parent */
33 putchar('P');
34 putchar('\n');
35 }
36 return(0);
37 }