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:
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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.