Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I don't understand this following code:
defined(my $pid=fork) or die $!; unless($pid){ exec 'date'; die $!; } waitpid($pid,0);
when using fork,the fork function returns pid, which is non-zero number and true value. I don't know why I should use defined function in here. But without defined, this code just immediately die
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using defined on fork
by Corion (Patriarch) on Dec 13, 2014 at 08:48 UTC |