From 14b15f3d43b827e0a09ae13ec05d23d018296ff8 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Wed, 26 Jun 2013 16:07:14 +0200 Subject: [PATCH] src/parallel: Fixed --filter-hosts. Bug due to --joblog - not working. --- src/parallel | 33 +++++++++++++++++++-------------- src/parallel.pod | 2 +- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/parallel b/src/parallel index d3908a4f..0685cc50 100755 --- a/src/parallel +++ b/src/parallel @@ -39,9 +39,7 @@ if(not $ENV{SHELL}) { ::warning("\$SHELL not set. Using /bin/sh.\n"); $ENV{SHELL} = "/bin/sh"; } -%Global::original_sig = %SIG; -$SIG{TERM} = sub {}; # Dummy until jobs really start -open $Global::original_stderr, ">&STDERR" or ::die_bug("Can't dup STDERR: $!"); +save_sig_stdin_stdout_stderr(); parse_options(); my $number_of_args; @@ -641,7 +639,7 @@ sub get_options_from_array { sub parse_options { # Returns: N/A # Defaults: - $Global::version = 20130622; + $Global::version = 20130626; $Global::progname = 'parallel'; $Global::infinity = 2**31; $Global::debug = 0; @@ -967,16 +965,18 @@ sub open_joblog { ::wait_and_exit(255); } } else { - # Overwrite the joblog - if(not open($Global::joblog, ">", $opt::joblog)) { + if($opt::joblog eq "-") { + # Use STDOUT as joblog + $Global::joblog = $Global::original_stdout + } elsif(not open($Global::joblog, ">", $opt::joblog)) { + # Overwrite the joblog ::error("Cannot write to --joblog $opt::joblog.\n"); ::wait_and_exit(255); - } else { - print $Global::joblog - join("\t", "Seq", "Host", "Starttime", "Runtime", - "Send", "Receive", "Exitval", "Signal", "Command" - ). "\n"; } + print $Global::joblog + join("\t", "Seq", "Host", "Starttime", "Runtime", + "Send", "Receive", "Exitval", "Signal", "Command" + ). "\n"; } } } @@ -1268,15 +1268,20 @@ sub __RUNNING_THE_JOBS_AND_PRINTING_PROGRESS__ {} # $Global::total_running = total number of running jobs # $Global::total_started = total jobs started -sub init_run_jobs { - # Remember the original STDOUT and STDERR +sub save_sig_stdin_stdout_stderr { + # Remember the original signal handler, STDIN, STDOUT and STDERR # Returns: N/A + %Global::original_sig = %SIG; + $SIG{TERM} = sub {}; # Dummy until jobs really start open $Global::original_stdout, ">&", "STDOUT" or ::die_bug("Can't dup STDOUT: $!"); open $Global::original_stderr, ">&", "STDERR" or ::die_bug("Can't dup STDERR: $!"); open $Global::original_stdin, "<&", "STDIN" or ::die_bug("Can't dup STDIN: $!"); +} + +sub init_run_jobs { $Global::total_running = 0; $Global::total_started = 0; $Global::tty_taken = 0; @@ -2789,7 +2794,7 @@ sub simultaneous_sshlogin_limit { # Choose the minimal my $ssh_limit = ::min($self->simultaneous_sshlogin($wanted_processes), - $self->simultaneous_sshlogin($wanted_processes)); + $self->simultaneous_sshlogin($wanted_processes)); if($ssh_limit < $wanted_processes) { my $serverlogin = $self->serverlogin(); ::warning("ssh to $serverlogin only allows ", diff --git a/src/parallel.pod b/src/parallel.pod index a07c7cf0..fb2fbda0 100644 --- a/src/parallel.pod +++ b/src/parallel.pod @@ -1377,7 +1377,7 @@ seconds it will get killed with SIGTERM, followed by SIGTERM 200 ms later, followed by SIGKILL 200 ms later. If I 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.