c++ - kill after sleep -


i couldnt make program sleep() after using kill(pid,sigterm) can ?

the code i'm using:

kill(pid_of_process_to_be_killed,sigterm); sleep(5); --> not working sleep(5); --> working 

the solution is:

kill(pid_of_process_to_be_killed,sigterm); sleep(sleep(5)); 

but why first sleep after kill return 0 ?

your sleep() call may terminating due receiving signal. check return value. if it's positive, might want sleep() again on value. http://www.manpagez.com/man/3/sleep/:

if sleep() function returns because requested time has elapsed, value returned zero. if sleep() function returns due delivery of signal, value returned unslept amount (the requested time minus time slept) in seconds


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -