开发者

where to place wait_pid function to prevent zoombie processes in Linux?

I'm following OpenSSL multi-threaded server example but this example creates zoombie processes. I researched and found that I should do a waitpid() for each forked process. But I'm not able to figure out where to place waitpid(pid, NULL, 0); I placed it just before end of while-loop but it then just waits for immediate processe开发者_StackOverflows which was forked rather than waiting for all the processes. Can someone please guide where and how to perform waitpid() call. Thanks!


You should build up an array of pids that the parent has spawned and then loop through them and call waitpid on each one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜