Hi all,
I'm making a client server program in Linux. I use fork() to create a child process of the server to handle a new client. When a client disconnects it should kill the child process. At the moment the program is able to kill the fist client(server) that connects, after that one they become zombie processes.
Heres how I've done it:
void handleSIGCHLD() {
int stat;
/*This should kill zombie processes*/
while(waitpid(-1, &stat, WNOHANG) > 0);
}
and put this at the start of main()
signal(SIGCHLD, handleSIGCHLD);