Created
February 14, 2012 10:15
-
-
Save pung96/1825511 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
#=============================================================================== | |
# | |
# FILE: intime.pl | |
# | |
# USAGE: ./intime.pl | |
# | |
# DESCRIPTION: | |
# | |
# OPTIONS: --- | |
# REQUIREMENTS: --- | |
# BUGS: --- | |
# NOTES: --- | |
# AUTHOR: Beomsu Chang (bschang), [email protected] | |
# COMPANY: | |
# VERSION: 1.0 | |
# CREATED: 02/14/2012 11:46:48 | |
# REVISION: --- | |
#=============================================================================== | |
use strict; | |
use warnings; | |
my $timelimit = shift @ARGV; | |
my ( @command ) = @ARGV; | |
my @com = split ' ',join ' ',@command; | |
eval { | |
local $SIG{ALRM} = sub { die "alarm\n" }; # NB \n required | |
alarm $timelimit; | |
print join ' ',@com; | |
system @com; | |
alarm 0; | |
}; | |
if ($@) { | |
# timed out | |
print "\n\n##########################################################\n"; | |
print STDERR "error: Timeout after $timelimit seconds requesting \n"; | |
print "##########################################################\n"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment