cameronbprince has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I have coded a script that loops over MP3's in a given directory. The script runs an external command, mp3_check on each file with IPC::Open3, parses it's output, then adds the data to an Oracle table with DBI/DBD.
The problem with this is the mp3_check command sometimes hangs on problem files. What I would like to do is setup a timer of some sort then run the command. If the child process doesn't complete before the timer expires, I'd like to kill the process and continue with the loop over the files.
Here is the code I've got now to call the external program and gather it's output:
Could anyone give me ideas as to how to setup a timer of say 5 seconds on this, then kill it if the timer expires?
Thanks,
Cameron
I have coded a script that loops over MP3's in a given directory. The script runs an external command, mp3_check on each file with IPC::Open3, parses it's output, then adds the data to an Oracle table with DBI/DBD.
The problem with this is the mp3_check command sometimes hangs on problem files. What I would like to do is setup a timer of some sort then run the command. If the child process doesn't complete before the timer expires, I'd like to kill the process and continue with the loop over the files.
Here is the code I've got now to call the external program and gather it's output:
use IPC::Open3; my $pid = open3(*IN, *OUT, *ERR, $command); waitpid $pid, 0; close(IN); my @outlines = <OUT>;
Could anyone give me ideas as to how to setup a timer of say 5 seconds on this, then kill it if the timer expires?
Thanks,
Cameron
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Timing External Program Execution
by tadman (Prior) on Oct 20, 2002 at 04:27 UTC | |
by agentv (Friar) on Oct 22, 2002 at 20:04 UTC | |
Re: Timing External Program Execution
by Zaxo (Archbishop) on Oct 20, 2002 at 03:21 UTC | |
Re: Timing External Program Execution
by Aristotle (Chancellor) on Oct 20, 2002 at 02:31 UTC | |
by bart (Canon) on Oct 21, 2002 at 11:48 UTC | |
Re: Timing External Program Execution
by IlyaM (Parson) on Oct 20, 2002 at 15:03 UTC | |
Re: Timing External Program Execution
by Anonymous Monk on Oct 22, 2002 at 16:41 UTC |
Back to
Seekers of Perl Wisdom