开发者

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

开发者 https://www.devze.com 2023-03-21 09:29 出处:网络
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.

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

精彩评论

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