xxyzz / ostep-hw

Operating Systems: Three Easy Pieces(OSTEP) homework and project solutions
GNU General Public License v3.0
763 stars 179 forks source link

Does Chapter 05 Homework 3.c have a bug? #7

Closed chenlangping closed 3 years ago

chenlangping commented 3 years ago

English is not my native language; please excuse typing errors.

First, I want to thank you for this amazing repo which helps me a lot.

In Chapter 5 Homework 3.c

....
else if (rc == 0) {
    kill(parent_pid, SIGCONT);
    printf("hello\n");
}
....

We send a signal to the parent process, then we use printf. I think if the OS decides to switch to the parent process after kill but before printf, the screen will show goodbye first. So I think you should put printf before kill.

I run your code on Ubuntu 16.04.7 LTS, gcc version is 5.4.0 20160609, it sometimes prints hello first, sometimes prints goodbye first.

xxyzz commented 3 years ago

Thanks!