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.
精彩评论