in reply to Objects and forking
I guess you only wrote it like this in this example, but just for reference, I've seen too many people ignoring errors. You should test the return value of the fork() better. It's a nonzero number in the parent, zero in the child and undef if the fork() failed!:
or if you want it to look more like your code:my $pid = fork(); die "Ouch, can't fork: $^En\" unless defined $pid; unless ($pid) { ... }
unless (my $pid = fork()) { die "Ouch, can't fork: $^En\" unless defined $pid; ... }
Jenda
Always code as if the guy who ends up maintaining your code
will be a violent psychopath who knows where you live.
-- Rick Osborne
Edit by castaway: Closed small tag in signature
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Objects and forking
by gnu@perl (Pilgrim) on Jul 11, 2003 at 13:35 UTC |