i need to check something with you
what would you say this program would output (from the head, without compiling :))
continue reading if you got the answerCode:#include <sys/types.h> #include <stdio.h> int main(){ pid_t pid; pid = fork(); if (pid == 0) { printf("A"); fork(); printf("B"); } else if (pid > 0){ wait(NULL); printf("C"); } }
i'd like to know what you'll say, because that was a question on my exam.
i answered ABBC and correct answer was ABABC
but then i tested in cygwin and got ABBC and sometimes ABCB, but in linux the result was indeed ABABC
is this a bug in cygwin, or it is a legitimate behaviour? if it's not a bug, how can i prove that to my professor and get my points ? :)


Reply With Quote



Bookmarks