| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
|---|---|
| 2 | |
| 3 | #include <stdio.h> |
| 4 | #include <sys/wait.h> |
| 5 | #include <unistd.h> |
| 6 | |
| 7 | #define WAITMSG "pid %d, fork returned %d\n" |
| 8 | |
| 9 | int main(void) |
| 10 | { |
| 11 | setbuf(stream: stdout, NULL); |
| 12 | for (int n = 0; n < 10; n++) |
| 13 | { |
| 14 | pid_t pid = fork(); |
| 15 | if (pid) |
| 16 | printf(WAITMSG, getpid(), pid); |
| 17 | } |
| 18 | return 0; |
| 19 | } |
| 20 |