njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1 | |
| 2 | #include <unistd.h> |
| 3 | #include <sys/types.h> |
fitzhardinge | 0996fa6 | 2004-01-06 21:46:02 +0000 | [diff] [blame] | 4 | #include <sys/wait.h> |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 5 | #include <stdio.h> |
| 6 | |
| 7 | int main(void) |
| 8 | { |
| 9 | pid_t pid; |
| 10 | |
| 11 | pid = fork (); |
| 12 | |
njn | 9198008 | 2002-09-27 10:38:20 +0000 | [diff] [blame] | 13 | /* Sometimes child goes first (non-zero), sometimes parent (zero). This |
| 14 | printing means we can detect if we correctly get a zero result and a |
| 15 | non-zero result (--> three 'X's printed), but the output doesn't depend |
| 16 | on the order. */ |
| 17 | |
| 18 | printf("%s", pid==0 ? "X" : "XX"); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 19 | |
fitzhardinge | 0996fa6 | 2004-01-06 21:46:02 +0000 | [diff] [blame] | 20 | if (pid != 0) |
| 21 | waitpid(pid, NULL, 0); |
| 22 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 23 | return 0; |
| 24 | } |