[Israel.pm] Problem timing-out a system command when script runs in the background
Yuval Yaari
yuval at windax.com
Sun Aug 29 01:31:52 PDT 2004
Hi,
Sorry if the subject isn't descriptive enough.
I wrote a script that extracts archives (zip, tar, gz, bz2, etc) recursivly.
I had a problem with zip files that have a password, so I just used the
famous alarm trick (read: hack) to time it out.
The code is something like:
eval {
alarm(600);
system('unzip', 'flags', $file);
alarm(0);
# Also check for return code, etc
};
if ($@) {
# Move the file away
alarm(0);
}
The problem is, that it won't work when I run the script in the background
(using nohup or just adding an & in the end of the command line).
I'm not sure why it might happen, but your ideas are more than welcome :)
Also, if anyone has a solution for checking if a zip file is password
protected, and/or timing it out better - let me know.
Thanks,
--Yuval
More information about the Perl
mailing list