Home | History | Annotate | Download | only in tests
      1 
      2 #include <unistd.h>
      3 #include <sys/types.h>
      4 #include <sys/wait.h>
      5 #include <stdio.h>
      6 
      7 int main(void)
      8 {
      9   pid_t pid;
     10 
     11   pid = fork ();
     12 
     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");
     19 
     20   if (pid != 0)
     21      waitpid(pid, NULL, 0);
     22 
     23   return 0;
     24 }
     25