in reply to Multi threaded server [fork]
This seems like strange behavior to me. I think what you need to do is call waitpid($child, 0); This should cause the parent process to continue to work. I think this would have been better done with threads, however, but that's just my opinion.
Here's an example of forking that I found on the net:
I think you're definitely going to need to use the signals.#!/usr/bin/perl use strict; use warnings; use POSIX ':sys_wait_h'; if (fork) { # parent print "[Parent]\n"; until (waitpid(-1, &WNOHANG)) { print "waiting...\n"; sleep 1; } print "[Parent End]\n"; } else { # child print "[Child]\n"; sleep 10; my $i = 1; print "[Child End]\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Multi threaded server [fork]
by Deda (Novice) on Aug 07, 2003 at 08:04 UTC |