LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how to do waitpid() using a multi-threaded server? (https://www.linuxquestions.org/questions/linux-software-2/how-to-do-waitpid-using-a-multi-threaded-server-312437/)

Thinking 04-12-2005 11:03 AM

how to do waitpid() using a multi-threaded server?
 
hiho@ll

i'm running a multi-threaded server, which forks it's children
but my problem is, if the child exits it's a zombie process

in the server i'm using accept to wait for connections
so i don't realy have the time to do waitpid()

how can i terminate my childs without having a problem of missing a connection from a client?
is there a way to do this event-based
if a child exits, i do waitpid
??

thx@ll

foo_bar_foo 04-13-2005 09:50 PM

you can use wait3 or wait4 and pass the WNOHANG flag to them or better
when a child process ends Linux sends the parent a SIGCHILD signal
so all you have to do is handle SIGCHILD


All times are GMT -5. The time now is 05:18 PM.