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.
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
We send a signal to the parent process, then we use
printf
. I think if the OS decides to switch to the parent process afterkill
but beforeprintf
, the screen will showgoodbye
first. So I think you should putprintf
beforekill
.I run your code on Ubuntu 16.04.7 LTS, gcc version is 5.4.0 20160609, it sometimes prints
hello
first, sometimes printsgoodbye
first.