Possible Duplicate:
fork() and output
by running:
#include<stdio.h>
int main()
{
fork();
printf("b");
if (fork() == 0) {
write(1, "a", 1);
}else{
write(1, "c", 1);
}
return 0;
}
I got cbcabbab, could someone explain the output to me? And if possible, is there a tool to see the running procedure step by step?
Try running it again, you’ll probably get a different output.
As for a tool to see the procedure step by step, I think
strace -fmight help a bit: