(
source)
1 /*------------------------------------------------------------------------
2 |
3 | File: fork02a.c
4 |
5 | Description: Another simple program creating a child process with fork()
6 | and printing the return value from fork(). But if the return is
7 | not 0 the process 'sleeps' for 1 second before printing.
8 |
9 |
10 | Usage: fork02a
11 |
12 | Created: 5 Jan 15
13 | Author: glancast
14 | Modifications:
15 |
16 +-----------------------------------------------------------------------*/
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <unistd.h> // for fork
20
21 int main(int argc, char* argv[])
22 {
23 int pid1;
24 int pid2;
25
26 pid1 = fork();
27 pid2 = fork();
28 printf("pid = %d\n", pid);
29
30 return 0;
31 }