Closed zhenya4880 closed 1 year ago
You are absolutely correct @zhenya4880, thanks for spotting this. I must have confused the sleep()
function with the sleep
command when I wrote this... Embarrassing to say the least. Nonetheless, I am grateful you found it! 👍😊
I'll update the code and notify Packt Publishing to update the book.
By the way, sleep(0)
is a nice hack, even though it's a hack and not recommended.
I have updated the errata and the code with sleep(0)
. Thank you for pointing this out 😊
Function
sleep()
has an integer argument. See man 3 sleep.Calling
sleep(0.1)
is equivalent to callingsleep(0)
. It will definitely not give you a 100ms delay.Please, use
nanosleep()
to get a delay of 100 ms or writesleep(0)
"to avoid draining the system resources".By the way, calling a
sleep(0)
in most cases is not a good idea