limit_run
来自「mysql+ha. 实现高可用性 http://code.google.com」· 代码 · 共 36 行
TXT
36 行
#!/usr/bin/env perluse strict;if (scalar(@ARGV) < 2) { print "ERROR: Usage: $0 <limit_seconds> <some command>\n\n"; exit(101);}my $timeout = shift(@ARGV);my @command = @ARGV;my $time = time();$SIG{ALRM} = \&Timeout;alarm($timeout);system(@command);alarm(0);# Analyze resultsif ($? == -1) { print "ERROR: Failed to execute: $!\n"; exit(102);} elsif ($? & 127) { printf "ERROR: Child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; exit(103);}exit($? >> 8);#------------------------------sub Timeout { print "ERROR: Execution timed out (" . (time() - $time) ." sec)!\n"; exit(100);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?