mirror of
https://github.com/ioacademy-jikim/debugging
synced 2025-06-08 08:26:14 +00:00
25 lines
481 B
C
25 lines
481 B
C
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/wait.h>
|
|
#include <stdio.h>
|
|
|
|
int main(void)
|
|
{
|
|
pid_t pid;
|
|
|
|
pid = fork ();
|
|
|
|
/* Sometimes child goes first (non-zero), sometimes parent (zero). This
|
|
printing means we can detect if we correctly get a zero result and a
|
|
non-zero result (--> three 'X's printed), but the output doesn't depend
|
|
on the order. */
|
|
|
|
printf("%s", pid==0 ? "X" : "XX");
|
|
|
|
if (pid != 0)
|
|
waitpid(pid, NULL, 0);
|
|
|
|
return 0;
|
|
}
|