diff --git a/src/parallel b/src/parallel index 67e6e284..9db52954 100755 --- a/src/parallel +++ b/src/parallel @@ -156,7 +156,7 @@ if($Global::semaphore) { $SIG{TERM} = \&start_no_new_jobs; start_more_jobs(); if($::opt_pipe) { - spreadstdin(); + spreadstdin(@fhlist); } reap_if_needed(); ::debug("Start draining\n"); @@ -177,6 +177,7 @@ sub __PIPE_MODE__ {} sub spreadstdin { # read a record # Spawn a job and print the record to it. + my @fhlist = @_; # Filehandles to read from (Defaults to STDIN) my $record; my $buf = ""; my $header = ""; @@ -220,7 +221,8 @@ sub spreadstdin { my $recendrecstart = $recend.$recstart; # Force the while-loop once if everything was read by header reading my $force_one_time_through = 0; - while(!$force_one_time_through++ or read(STDIN,substr($buf,length $buf,0),$::opt_blocksize)) { + for my $in (@fhlist) { + while(!$force_one_time_through++ or read($in,substr($buf,length $buf,0),$::opt_blocksize)) { # substr above = append to $buf reap_if_needed(); # Re-enable reaping after read() (Bug#33352) if($::opt_r) { @@ -269,13 +271,15 @@ sub spreadstdin { } } } - do_not_reap(); # Disable reaping before read(STDIN) (Bug#33352) + do_not_reap(); # Disable reaping before read($in) (Bug#33352) } +} + # If there is anything left in the buffer write it substr($buf,0,0) = $header; write_record_to_pipe(\$buf,$recstart,$recend); - ::debug("Done reading STDIN\n"); + ::debug("Done reading input\n"); flush_and_close_pipes(); ::debug("Done flushing to children\n"); $Global::start_no_new_jobs = 1; diff --git a/testsuite/tests-to-run/test60.sh b/testsuite/tests-to-run/test60.sh index 4bc442bc..8a48b9dc 100644 --- a/testsuite/tests-to-run/test60.sh +++ b/testsuite/tests-to-run/test60.sh @@ -43,4 +43,8 @@ echo '### Test --wd .'; ssh $SSHLOGIN2 mkdir -p mydir; mkdir -p $HOME/mydir; cd $HOME/mydir; parallel --workdir . -S $SSHLOGIN2 ::: pwd + +echo '### bug #35544: --pipe would read from :::: (-a)'; + parallel -j1 --pipe echo foo\;cat ::: a b c :::: <(seq 3) <(seq 4 6) + EOF diff --git a/testsuite/wanted-results/test60 b/testsuite/wanted-results/test60 index 3ae34e86..2480891d 100644 --- a/testsuite/wanted-results/test60 +++ b/testsuite/wanted-results/test60 @@ -70,3 +70,16 @@ vm1 /home/parallel/mydir ### Test --wd . /home/parallel/mydir +### bug #35544: --pipe would read from :::: (-a) +foo +a +b +c +foo +1 +2 +3 +foo +4 +5 +6