in reply to Re^4: Handling sockets in a server
in thread Handling sockets in a server

Hopefully someone can answer questions 3 and 4. Here they are again. I didn't copy my example code but it is in the orginial post. Thanks

3. If the child process is executing a command like system("echo Hello");, I need to reap child processes before closing the forked child process so as not to leave "zombies" right? Or is my handling that via capturing the CHLD signal ($SIG{'CHLD'} = 'IGNORE';) before I even start up the socket sufficient? I wasn't sure I needed to do one of these:

while ( my $child_process = waitpid(-1,WNOHANG) > 0 ) { }

before I close the child each time.

4. In Perl 5.6.1, after each accepted connection do I need to reset STDERR and STDOUT that I set prior creating the socket? Previously in Perl 5.005_02 I was having to reset these with each new connection. If that's the same, can someone tell me why?

Shannon Kerr

Replies are listed 'Best First'.
Re^6: Handling sockets in a server
by skerr1 (Sexton) on Oct 26, 2005 at 00:24 UTC

    Is there anyone that can help out with questions 3 and 4 in the original post of this thread 501889. Thanks!

    Shannon Kerr

      For 3, the answer is my handling via $SIG{'CHLD'} is sufficient, if done properly. I wanted the parent process to check the return value of each child process, and wanted the child processes of the parent to just reap their child processes, so the function called when receiving the child signal had to handle the reaping differently for the parent than the children.

      For 4, yes, you have to reset the STDERR and STDOUT if you want them redirected in the child processes.

      Shannon Kerr