Skip to content

Commit

Permalink
Add --no-info-on-success option
Browse files Browse the repository at this point in the history
Suppress printing usage statistics if the process has finished without
intervention.
  • Loading branch information
pshved committed Jan 27, 2012
1 parent 2833fb3 commit 26b3942
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ Advanced options:
controlled process hanged up, and terminated it. This option disables this
functionality.

* `--no-info-on-success` - disable printing usage statistics if the
controlled process has been successfully terminated.

More options may be read in the script itself. More documentation will be
added in the future releases!

Expand Down
8 changes: 6 additions & 2 deletions timeout
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ my $frequency = 10;
my $debug = '';
# Whether we do not do this term-kill stuff, and just kill processes at once
my $just_kill = '';
# Suppress printing stats when there was no resource violation
my $info_on_success = 1;

GetOptions(
'timelimit|t=i'=>\$timelimit,
Expand All @@ -60,6 +62,7 @@ GetOptions(
'watchfor|w=s'=>\$watchfor,
'debug!'=>\$debug,
'just-kill'=>\$just_kill,
'info-on-success!'=>\$info_on_success,
) or usage;

@ARGV or usage;
Expand Down Expand Up @@ -179,7 +182,8 @@ while ($status eq 'wait'){
}
}

#print_uinfo('FINISHED',$uinfo);
# 'FINISHED' string has a special meaning in print_uinfo!
print_uinfo('FINISHED',$uinfo) if $info_on_success;
exit $box_status;

#-----------------------------------------------
Expand Down Expand Up @@ -408,7 +412,7 @@ sub print_uinfo
my $reason = shift;
# Print generic information to STDERR
my $ticks = $timeinfo->{ticks_stale} || 0;
printf STDERR "${id_str}%s CPU %.2f MEM %d MAXMEM %d STALE %d\n", $reason, $timeinfo->{total}, $meminfo, $maxmem, ceil($ticks/$frequency);
printf STDERR "${id_str}%s CPU %.2f MEM %d MAXMEM %d STALE %d\n", $reason, $timeinfo->{total}, $meminfo, $maxmem, ceil($ticks/$frequency) if ($reason ne 'FINISHED') || $info_on_success;

if (defined $output){
open(FIL,">>", $output) or die "Can't open output file: $!\n";
Expand Down

0 comments on commit 26b3942

Please sign in to comment.