[CLUE-Tech] perl fork

Dan Harris dan at drivefaster.net
Thu Jul 1 15:17:01 MDT 2004


Here's one approach:

my $command = 'long running command';
my $pid = system( $command );

while ( -f "/proc/$pid" ) {
    # still running
    # your code to decide if it should fail or wait
    sleep( 1 ); # sleep 1 second
}


On 7/1/04 2:59 PM, "Jason S. Friedman" <jason at powerpull.net> wrote:

> I'm wanting to execute a shell command from within a Perl
> program and fail if it does not return with a specified
> number of seconds.
> 
> It's okay (in fact, preferable) if the system call
> continues to run, I just want the Perl wrapper program to
> fail so that I can alert an operator that something might
> be wrong.
> 
> How?
> 
> I've got this far:
> $command = "/usr/bin/long_running_exec";
> system( $command );
> $exit_status = $CHILD_ERROR>>8;
> _______________________________________________
> CLUE-Tech mailing list
> Post messages to: CLUE-Tech at clue.denver.co.us
> Unsubscribe or manage your options:
> http://clue.denver.co.us/mailman/listinfo/clue-tech





More information about the clue-tech mailing list