src/parallel: Fixed --filter-hosts. Bug due to --joblog - not working.

This commit is contained in:
Ole Tange 2013-06-26 16:07:14 +02:00
parent 21a77662ab
commit 14b15f3d43
2 changed files with 20 additions and 15 deletions

View file

@ -39,9 +39,7 @@ if(not $ENV{SHELL}) {
::warning("\$SHELL not set. Using /bin/sh.\n"); ::warning("\$SHELL not set. Using /bin/sh.\n");
$ENV{SHELL} = "/bin/sh"; $ENV{SHELL} = "/bin/sh";
} }
%Global::original_sig = %SIG; save_sig_stdin_stdout_stderr();
$SIG{TERM} = sub {}; # Dummy until jobs really start
open $Global::original_stderr, ">&STDERR" or ::die_bug("Can't dup STDERR: $!");
parse_options(); parse_options();
my $number_of_args; my $number_of_args;
@ -641,7 +639,7 @@ sub get_options_from_array {
sub parse_options { sub parse_options {
# Returns: N/A # Returns: N/A
# Defaults: # Defaults:
$Global::version = 20130622; $Global::version = 20130626;
$Global::progname = 'parallel'; $Global::progname = 'parallel';
$Global::infinity = 2**31; $Global::infinity = 2**31;
$Global::debug = 0; $Global::debug = 0;
@ -967,18 +965,20 @@ sub open_joblog {
::wait_and_exit(255); ::wait_and_exit(255);
} }
} else { } else {
if($opt::joblog eq "-") {
# Use STDOUT as joblog
$Global::joblog = $Global::original_stdout
} elsif(not open($Global::joblog, ">", $opt::joblog)) {
# Overwrite the joblog # Overwrite the joblog
if(not open($Global::joblog, ">", $opt::joblog)) {
::error("Cannot write to --joblog $opt::joblog.\n"); ::error("Cannot write to --joblog $opt::joblog.\n");
::wait_and_exit(255); ::wait_and_exit(255);
} else { }
print $Global::joblog print $Global::joblog
join("\t", "Seq", "Host", "Starttime", "Runtime", join("\t", "Seq", "Host", "Starttime", "Runtime",
"Send", "Receive", "Exitval", "Signal", "Command" "Send", "Receive", "Exitval", "Signal", "Command"
). "\n"; ). "\n";
} }
} }
}
} }
sub read_options { sub read_options {
@ -1268,15 +1268,20 @@ sub __RUNNING_THE_JOBS_AND_PRINTING_PROGRESS__ {}
# $Global::total_running = total number of running jobs # $Global::total_running = total number of running jobs
# $Global::total_started = total jobs started # $Global::total_started = total jobs started
sub init_run_jobs { sub save_sig_stdin_stdout_stderr {
# Remember the original STDOUT and STDERR # Remember the original signal handler, STDIN, STDOUT and STDERR
# Returns: N/A # Returns: N/A
%Global::original_sig = %SIG;
$SIG{TERM} = sub {}; # Dummy until jobs really start
open $Global::original_stdout, ">&", "STDOUT" or open $Global::original_stdout, ">&", "STDOUT" or
::die_bug("Can't dup STDOUT: $!"); ::die_bug("Can't dup STDOUT: $!");
open $Global::original_stderr, ">&", "STDERR" or open $Global::original_stderr, ">&", "STDERR" or
::die_bug("Can't dup STDERR: $!"); ::die_bug("Can't dup STDERR: $!");
open $Global::original_stdin, "<&", "STDIN" or open $Global::original_stdin, "<&", "STDIN" or
::die_bug("Can't dup STDIN: $!"); ::die_bug("Can't dup STDIN: $!");
}
sub init_run_jobs {
$Global::total_running = 0; $Global::total_running = 0;
$Global::total_started = 0; $Global::total_started = 0;
$Global::tty_taken = 0; $Global::tty_taken = 0;

View file

@ -1377,7 +1377,7 @@ seconds it will get killed with SIGTERM, followed by SIGTERM 200 ms
later, followed by SIGKILL 200 ms later. later, followed by SIGKILL 200 ms later.
If I<val> is followed by a % then the timeout will dynamically be If I<val> is followed by a % then the timeout will dynamically be
computed as a percentage of the smoothed average runtime. Only values computed as a percentage of the median average runtime. Only values
> 100% will make sense. > 100% will make sense.