in reply to Re: How do you get PID of a program called using system call?
in thread How do you get PID of a program called using system call?
If fork() was not able to fork, it will return undef and if exec() is not able to run the program it will return.
Not catching the exec is potentially the most dangerous as the child process then continues in the loop, just the same as the parent. In this cas you would end up filling the process table.my $pid = fork(); if ($pid) { push @pids, $pid; } elsif (defined $pid) { exec($cmd); die "Cannot exec '$cmd': $!\n"; } else { die "Cannot fork: $!\n" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: How do you get PID of a program called using system call?
by blakem (Monsignor) on Oct 08, 2001 at 23:36 UTC |