From 3461b32dea57a7b398edf7745c845f241f91c86e Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Thu, 17 Feb 2022 11:31:25 +0100 Subject: [PATCH] sem: --fg exit code = exit code from command. --- 10seconds_install | 16 +- src/parallel | 26 +- src/parallel.pod | 684 ++++++++++++++++++++------------ testsuite/tests-to-run/sem01.sh | 22 + testsuite/wanted-results/sem01 | 192 +++++++++ 5 files changed, 676 insertions(+), 264 deletions(-) diff --git a/10seconds_install b/10seconds_install index 87fadb95..9f1d2c69 100644 --- a/10seconds_install +++ b/10seconds_install @@ -72,7 +72,7 @@ run() { if gpg --list-keys 0xFFFFFFF1 && gpg --list-keys 0x88888888 ; then echo Keys fetched # OK - return 0 + return 0 else keyservers="keyserver.ubuntu.com pgp.surf.nl @@ -86,14 +86,14 @@ run() { return 0 fi done - echo - echo "Cannot fetch keyID 0x88888888, so the signature cannot be checked." + echo + echo "Cannot fetch keyID 0x88888888, so the signature cannot be checked." return 1 fi else - # GnuPG not installed + # GnuPG not installed echo - echo "GnuPG (gpg) is not installed so the signature cannot be checked." + echo "GnuPG (gpg) is not installed so the signature cannot be checked." return 1 fi } @@ -109,7 +109,7 @@ run() { # GnuPG signature failed echo echo "The signature on $latest.tar.bz2 is wrong. This may indicate that a criminal has changed the code." - echo "THIS IS BAD AND THE CODE WILL NOT BE INSTALLED." + echo "THIS IS BAD AND THE CODE WILL NOT BE INSTALLED." echo echo "See http://git.savannah.gnu.org/cgit/parallel.git/tree/README for other installation methods." exit 1 @@ -121,7 +121,7 @@ run() { echo "Continue anyway? (y/n)" read YN > "$HOME"/.bashrc + echo 'PATH=$PATH:$HOME/bin' >> "$HOME"/.bashrc echo 'setenv PATH ${PATH}:${HOME}/bin' >> "$HOME"/.cshrc fi diff --git a/src/parallel b/src/parallel index 9ea69033..60c956b2 100755 --- a/src/parallel +++ b/src/parallel @@ -115,7 +115,16 @@ sub halt() { } wait_and_exit($Global::halt_exitstatus); } else { - wait_and_exit(min(undef_as_zero($Global::exitstatus),101)); + if($Global::semaphore) { + # --semaphore runs a single job: + # Use exit value of that + wait_and_exit($Global::halt_exitstatus); + } else { + # 0 = all jobs succeeded + # 1-100 = n jobs failed + # 101 = >100 jobs failed + wait_and_exit(min(undef_as_zero($Global::exitstatus),101)); + } } } @@ -2296,7 +2305,7 @@ sub check_invalid_option_combinations() { sub init_globals() { # Defaults: - $Global::version = 20220122; + $Global::version = 20220202; $Global::progname = 'parallel'; $::name = "GNU Parallel"; $Global::infinity = 2**31; @@ -9978,7 +9987,7 @@ sub start($) { eval{ setpgrp(0,0) }; eval{ setpriority(0,0,$opt::nice) }; exec($Global::shell,"-c",$command) - || ::die_bug("open3-$stdin_fh $command"); + || ::die_bug("open3-$stdin_fh ".substr($command,0,200)); } }; return $pid; @@ -10134,7 +10143,7 @@ sub start($) { }; close $devtty_fh; $job->set_virgin(0); - } elsif($opt::semaphore) { + } elsif($Global::semaphore) { # Allow sem to read from stdin $pid = open3_setpgrp("<&STDIN",$stdout_fh,$stderr_fh,$command); $job->set_virgin(0); @@ -11081,6 +11090,13 @@ sub set_exitsignal($$) { # Returns: N/A my $job = shift; my $limit; + if($Global::semaphore) { + # Emulate Bash's +128 if there is a signal + $Global::halt_exitstatus = + ($job->exitstatus() + or + $job->exitsignal() ? $job->exitsignal() + 128 : 0); + } if($job->exitstatus() or $job->exitsignal()) { # Job failed $Global::exitstatus++; @@ -12412,7 +12428,7 @@ sub tmux_length($) { ::debug("tmux","tmux-out ",@out); chomp @out; # The arguments is given 3 times on the command line - # and the wrapping is around 30 chars + # and the tmux wrapping is around 30 chars # (29 for tmux1.9, 33 for tmux1.8) my $tmux_len = ::max(@out); $len = ::min($len,int($tmux_len/4-33)); diff --git a/src/parallel.pod b/src/parallel.pod index 2e2c6424..7ab850c0 100644 --- a/src/parallel.pod +++ b/src/parallel.pod @@ -81,8 +81,8 @@ you for it. =head3 How-to -You can find a lot of Bs of use after the list of B -in B (Use B). That will +You can find a lot of Bs of use after the list of +B in B (Use B). That will give you an idea of what GNU B is capable of, and you may find a solution you can simply adapt to your situation. @@ -109,7 +109,9 @@ change GNU B. =item I -Command to execute. If I or the following arguments contain +Command to execute. + +If I or the following arguments contain replacement strings (such as B<{}>) every instance will be substituted with the input. @@ -155,8 +157,8 @@ This replacement string will be replaced by the input with the extension removed. If the input line contains B<.> after the last B, the last B<.> until the end of the string will be removed and B<{.}> will be replaced with the remaining. E.g. I becomes -I, I becomes I, I -becomes I, I remains I. If the +I, I becomes I, +I becomes I, I remains I. If the input line does not contain B<.> it will remain unchanged. The replacement string B<{.}> can be changed with B<--er>. @@ -195,8 +197,8 @@ To understand replacement strings see B<{}>. Basename of input line without extension. This replacement string will be replaced by the input with the -directory and extension part removed. It is a combination of B<{/}> -and B<{.}>. +directory and extension part removed. B<{/.}> is a combination of +B<{/}> and B<{.}>. The replacement string B<{/.}> can be changed with B<--basenameextensionreplace>. @@ -271,7 +273,9 @@ B<{>I/.B<}> =item B<{>I.B<}> Argument from input source I or the I'th argument without -extension. It is a combination of B<{>IB<}> and B<{.}>. +extension. + +B<{>I.B<}> is a combination of B<{>IB<}> and B<{.}>. This positional replacement string will be replaced by the input from input source I (when used with B<-a> or B<::::>) or with the @@ -284,7 +288,8 @@ To understand positional replacement strings see B<{>IB<}>. =item B<{>I/B<}> Basename of argument from input source I or the I'th argument. -It is a combination of B<{>IB<}> and B<{/}>. + +B<{>I/B<}> is a combination of B<{>IB<}> and B<{/}>. This positional replacement string will be replaced by the input from input source I (when used with B<-a> or B<::::>) or with the @@ -297,7 +302,8 @@ To understand positional replacement strings see B<{>IB<}>. =item B<{>I//B<}> Dirname of argument from input source I or the I'th argument. -It is a combination of B<{>IB<}> and B<{//}>. + +B<{>I//B<}> is a combination of B<{>IB<}> and B<{//}>. This positional replacement string will be replaced by the dir of the input from input source I (when used with B<-a> or B<::::>) or with @@ -309,7 +315,9 @@ To understand positional replacement strings see B<{>IB<}>. =item B<{>I/.B<}> Basename of argument from input source I or the I'th argument -without extension. It is a combination of B<{>IB<}>, B<{/}>, and +without extension. + +B<{>I/.B<}> is a combination of B<{>IB<}>, B<{/}>, and B<{.}>. This positional replacement string will be replaced by the input from @@ -380,12 +388,20 @@ skip this job (see also B<--filter>) =item Z<> B +=item Z<> B + +=item Z<> B + =item Z<> B =item Z<> B =item Z<> B +=item Z<> B + +=item Z<> B + time functions =back @@ -401,17 +417,19 @@ See also: B<--rpl> B<--parens> =item B<{=>I IB<=}> -Positional equivalent to B<{=perl expression=}>. To understand -positional replacement strings see B<{>IB<}>. +Positional equivalent to B<{=perl expression=}>. + +To understand positional replacement strings see B<{>IB<}>. See also: B<{=perl expression=}> B<{>IB<}> =item B<:::> I -Use arguments from the command line as input source instead of stdin -(standard input). Unlike other options for GNU B B<:::> is -placed after the I and before the arguments. +Use arguments on the command line as input source. + +Unlike other options for GNU B B<:::> is placed after the +I and before the arguments. The following are equivalent: @@ -431,7 +449,7 @@ generated. E.g. ::: 1 2 ::: a b c will result in the combinations (1,a) (1,b) (1,c) (2,a) (2,b) (2,c). This is useful for replacing nested for-loops. -B<:::> and B<::::> can be mixed. So these are equivalent: +B<:::>, B<::::>, and B<-a> can be mixed. So these are equivalent: parallel echo {1} {2} {3} ::: 6 7 ::: 4 5 ::: 1 2 3 parallel echo {1} {2} {3} :::: <(seq 6 7) <(seq 4 5) \ @@ -445,7 +463,7 @@ B<:::> and B<::::> can be mixed. So these are equivalent: seq 4 5 | parallel echo {1} {2} {3} :::: <(seq 6 7) - \ ::: 1 2 3 -See also: B<--arg-sep> +See also: B<--arg-sep> B<-a> B<::::> B<:::+> B<::::+> B<--link> =item B<:::+> I @@ -459,6 +477,8 @@ Example: parallel echo ::: a b c :::+ 1 2 3 ::: X Y :::+ 11 22 +See also: B<::::+> B<--link> + =item B<::::> I @@ -476,16 +496,20 @@ Like B<::::> but linked like B<--link> to the previous input source. Contrary to B<--link>, values do not wrap: The shortest input source determines the length. +See also: B<-a> B<:::+> B<--link> + =item B<--null> =item B<-0> -Use NUL as delimiter. Normally input lines will end in \n -(newline). If they end in \0 (NUL), then use this option. It is useful -for processing arguments that may contain \n (newline). +Use NUL as delimiter. -Shortcut for B<-d '\0'>. +Normally input lines will end in \n (newline). If they end in \0 +(NUL), then use this option. It is useful for processing arguments +that may contain \n (newline). + +Shorthand for B<-d '\0'>. See also: B<-d> @@ -494,33 +518,37 @@ See also: B<-d> =item B<-a> I -Use I as input source. If you use this option, stdin -(standard input) is given to the first process run. Otherwise, stdin -(standard input) is redirected from /dev/null. +Use I as input source. + +If you use this option, stdin (standard input) is given to the first +process run. Otherwise, stdin (standard input) is redirected from +/dev/null. If multiple B<-a> are given, each I will be treated as an input source, and all combinations of input sources will be -generated. E.g. The file B contains B<1 2>, the file B -contains B. B<-a foo> B<-a bar> will result in the combinations +generated. E.g. The file B contains B<1 2>, the file +B contains B. B<-a foo> B<-a bar> will result in the combinations (1,a) (1,b) (1,c) (2,a) (2,b) (2,c). This is useful for replacing nested for-loops. -See also: B<--link> B<{>IB<}> +See also: B<--link> B<{>IB<}> B<::::> B<::::+> B<:::> =item B<--arg-file-sep> I Use I instead of B<::::> as separator string between command -and argument files. Useful if B<::::> is used for something else by the -command. +and argument files. + +Useful if B<::::> is used for something else by the command. See also: B<::::> =item B<--arg-sep> I -Use I instead of B<:::> as separator string. Useful if B<:::> -is used for something else by the command. +Use I instead of B<:::> as separator string. + +Useful if B<:::> is used for something else by the command. Also useful if you command uses B<:::> but you still want to read arguments from stdin (standard input): Simply change B<--arg-sep> to a @@ -531,8 +559,10 @@ See also: B<:::> =item B<--bar> -Show progress as a progress bar. In the bar is shown: % of jobs -completed, estimated seconds left, and number of jobs started. +Show progress as a progress bar. + +In the bar is shown: % of jobs completed, estimated seconds left, and +number of jobs started. It is compatible with B: @@ -540,15 +570,20 @@ It is compatible with B: 2> >(perl -pe 'BEGIN{$/="\r";$|=1};s/\r/\n/g' | zenity --progress --auto-kill) | wc + =item B<--basefile> I =item B<--bf> I -I will be transferred to each sshlogin before a job is -started. It will be removed if B<--cleanup> is active. The file may be -a script to run or some common base data needed for the job. -Multiple B<--bf> can be specified to transfer more basefiles. The -I will be transferred the same way as B<--transferfile>. +I will be transferred to each sshlogin before first job is +started. + +It will be removed if B<--cleanup> is active. The file may be a script +to run or some common base data needed for the job. Multiple +B<--bf> can be specified to transfer more basefiles. The I will be +transferred the same way as B<--transferfile>. + +See also: B<--sshlogin> B<--transfer> B<--return> B<--cleanup> =item B<--basenamereplace> I @@ -558,6 +593,8 @@ I will be transferred the same way as B<--transferfile>. Use the replacement string I instead of B<{/}> for basename of input line. +See also: B<{/}> + =item B<--basenameextensionreplace> I @@ -565,6 +602,8 @@ basename of input line. Use the replacement string I instead of B<{/.}> for basename of input line without extension. +See also: B<{/.}> + =item B<--bin> I @@ -591,16 +630,19 @@ I is small (<10), slower if it is big (>100). B<--bin> requires B<--pipe> and a fixed numeric value for B<--jobs>. -See the section: SPREADING BLOCKS OF DATA. - -See also: B<--group-by> B<--roundrobin> B<--shard> +See also: SPREADING BLOCKS OF DATA B<--group-by> B<--roundrobin> +B<--shard> =item B<--bg> -Run command in background thus GNU B will not wait for -completion of the command before exiting. This is the default if -B<--semaphore> is set. +Run command in background. + +GNU B will normally wait for the completion of a job. With +B<--bg> GNU B will not wait for completion of the command +before exiting. + +This is the default if B<--semaphore> is set. Implies B<--semaphore>. @@ -632,17 +674,18 @@ EUR, you have done your part to finance future development and should feel free to use B<--will-cite> in scripts. If you do not want to help financing future development by letting -other users see the citation notice or by paying, then please use -another tool instead of GNU B. You can find some of the -alternatives in B. +other users see the citation notice or by paying, then please consider +using another tool instead of GNU B. You can find some of +the alternatives in B. =item B<--block> I =item B<--block-size> I -Size of block in bytes to read at a time. The I can be postfixed -with K, M, G, T, P, k, m, g, t, or p (see UNIT PREFIX). +Size of block in bytes to read at a time. + +The I can be postfixed with K, M, G, T, P, k, m, g, t, or p. GNU B tries to meet the block size but can be off by the length of one record. For performance reasons I should be bigger @@ -661,39 +704,45 @@ this will run 10*5 = 50 jobs in total: This is an efficient alternative to B<--roundrobin> because data is never read by GNU B, but you can still have very few -jobslots process a large amount of data. +jobslots process large amounts of data. -See B<--pipe> and B<--pipepart> for use of this. +See also: UNIT PREFIX B<-N> B<--pipe> B<--pipepart> B<--roundrobin> =item B<--blocktimeout> I =item B<--bt> I -Time out for reading block when using B<--pipe>. If it takes longer -than I to read a full block, use the partial block read so -far. +Timeout for reading block when using B<--pipe>. -I is in seconds, but can be postfixed with s, m, h, or d -(see the section TIME POSTFIXES). +If it takes longer than I to read a full block, use the +partial block read so far. + +I is in seconds, but can be postfixed with s, m, h, or d. + +See also: TIME POSTFIXES B<--pipe> =item B<--cat> -Create a temporary file with content. Normally B<--pipe>/B<--pipepart> -will give data to the program on stdin (standard input). With B<--cat> -GNU B will create a temporary file with the name in B<{}>, so -you can do: B. +Create a temporary file with content. + +Normally B<--pipe>/B<--pipepart> will give data to the program on +stdin (standard input). With B<--cat> GNU B will create a +temporary file with the name in B<{}>, so you can do: B. Implies B<--pipe> unless B<--pipepart> is used. -See also: B<--fifo> +See also: B<--pipe> B<--pipepart> B<--fifo> =item B<--cleanup> -Remove transferred files. B<--cleanup> will remove the transferred -files on the remote computer after processing is done. +Remove transferred files. + +B<--cleanup> will remove the transferred files on the remote computer +after processing is done. find log -name '*gz' | parallel \ --sshlogin server.example.com --transferfile {} \ @@ -710,17 +759,22 @@ computer containing the file will be removed if they are empty. B<--cleanup> is ignored when not used with B<--transferfile> or B<--return>. +See also: B<--basefile> B<--transfer> B<--sshlogin> B<--return> +B<--cleanup> + =item B<--colsep> I =item B<-C> I -Column separator. The input will be treated as a table with I -separating the columns. The n'th column can be accessed using -B<{>IB<}> or B<{>I.B<}>. E.g. B<{3}> is the 3rd column. +Column separator. + +The input will be treated as a table with I separating the +columns. The n'th column can be accessed using B<{>IB<}> or +B<{>I.B<}>. E.g. B<{3}> is the 3rd column. If there are more input sources, each input source will be separated, -but the columns from each input source will be linked (see B<--link>). +but the columns from each input source will be linked. parallel --colsep '-' echo {4} {3} {2} {1} \ ::: A-B C-D ::: e-f g-h @@ -731,6 +785,8 @@ B<--trim n>. I is a Perl Regular Expression: https://perldoc.perl.org/perlre.html +See also: B<--csv> B<{>IB<}> B<--trim> B<--link> + =item B<--compress> @@ -751,20 +807,27 @@ See also: B<--compress-program> =item B<--decompress-program> I -Use I for (de)compressing temporary files. It is assumed that I will decompress stdin (standard input) to stdout (standard -output) unless B<--decompress-program> is given. +Use I for (de)compressing temporary files. + +It is assumed that I will decompress stdin (standard input) +to stdout (standard output) unless B<--decompress-program> is given. + +See also: B<--compress> =item B<--csv> -Treat input as CSV-format. B<--colsep> sets the field delimiter. It -works very much like B<--colsep> except it deals correctly with -quoting: +Treat input as CSV-format. + +B<--colsep> sets the field delimiter. It works very much like +B<--colsep> except it deals correctly with quoting. Compare: echo '"1 big, 2 small","2""x4"" plank",12.34' | parallel --csv echo {1} of {2} at {3} + echo '"1 big, 2 small","2""x4"" plank",12.34' | + parallel --colsep ',' echo {1} of {2} at {3} + Even quoted newlines are parsed correctly: (echo '"Start of field 1 with newline' @@ -773,6 +836,8 @@ Even quoted newlines are parsed correctly: When used with B<--pipe> only pass full CSV-records. +See also: B<--csv> B<--pipe> + =item B<--ctag> I @@ -797,12 +862,14 @@ See also: B<--ctag> B<--tagstring> Delay starting next job by I. GNU B will pause I after starting each -job. I is in seconds, but can be postfixed with s, m, h, or d -(see the section TIME POSTFIXES). +job. I is in seconds, but can be postfixed with s, m, h, or d. -If you append 'auto' to I (e.g. 13m3sauto) GNU B will -automatically try to find the optimal value: If a job fails, I -is doubled. If a job succeeds, I is decreased by 10%. +If you append 'auto' to I (e.g. 13m3sauto) GNU +B will automatically try to find the optimal value: If a job fails, +I is increased by 30%. If a job succeeds, I is +decreased by 10%. + +See also: TIME POSTFIXES B<--retries> =item B<--delimiter> I @@ -814,7 +881,8 @@ Input items are terminated by I. The specified delimiter may be characters, C-style character escapes such as \n, or octal or hexadecimal escape codes. Octal and hexadecimal escape codes are understood as for the printf command. -Multibyte characters are not supported. + +See also: B<--colsep> =item B<--dirnamereplace> I @@ -824,39 +892,51 @@ Multibyte characters are not supported. Use the replacement string I instead of B<{//}> for dirname of input line. +See also: B<{//}> + =item B<--dry-run> Print the job to run on stdout (standard output), but do not run the -job. Use B<-v -v> to include the wrapping that GNU B -generates (for remote jobs, B<--tmux>, B<--nice>, B<--pipe>, -B<--pipepart>, B<--fifo> and B<--cat>). Do not count on this -literally, though, as the job may be scheduled on another computer or -the local computer if : is in the list. +job. + +Use B<-v -v> to include the wrapping that GNU B generates +(for remote jobs, B<--tmux>, B<--nice>, B<--pipe>, B<--pipepart>, +B<--fifo> and B<--cat>). Do not count on this literally, though, as +the job may be scheduled on another computer or the local computer if +: is in the list. + +See also: B<-v> =item B<-E> I -Set the end of file string to I. If the end of file string -occurs as a line of input, the rest of the input is not read. If -neither B<-E> nor B<-e> is used, no end of file string is used. +Set the end of file string to I. + +If the end of file string occurs as a line of input, the rest of the +input is not read. If neither B<-E> nor B<-e> is used, no end of file +string is used. =item B<--eof>[=I] =item B<-e>[I] -This option is a synonym for the B<-E> option. Use B<-E> instead, -because it is POSIX compliant for B while this option is not. -If I is omitted, there is no end of file string. If neither -B<-E> nor B<-e> is used, no end of file string is used. +This option is a synonym for the B<-E> option. + +Use B<-E> instead, because it is POSIX compliant for B while +this option is not. If I is omitted, there is no end of file +string. If neither B<-E> nor B<-e> is used, no end of file string is +used. =item B<--embed> -Embed GNU B in a shell script. If you need to distribute your -script to someone who does not want to install GNU B you can -embed GNU B in your own shell script: +Embed GNU B in a shell script. + +If you need to distribute your script to someone who does not want to +install GNU B you can embed GNU B in your own +shell script: parallel --embed > new_script @@ -866,12 +946,13 @@ on B, B, B, B, B, and B. =item B<--env> I -Copy environment variable I. This will copy I to the -environment that the command is run in. This is especially useful for -remote execution. +Copy environment variable I. + +This will copy I to the environment that the command is run +in. This is especially useful for remote execution. In Bash I can also be a Bash function - just remember to B the function, see B. +-f> the function. The variable '_' is special. It will copy all exported environment variables except for the ones mentioned in ~/.parallel/ignored_vars. @@ -879,14 +960,17 @@ variables except for the ones mentioned in ~/.parallel/ignored_vars. To copy the full environment (both exported and not exported variables, arrays, and functions) use B. -See also: B<--record-env> B<--session> +See also: B<--record-env> B<--session> B<--sshlogin> B +B =item B<--eta> -Show the estimated number of seconds before finishing. This forces GNU -B to read all jobs before starting to find the number of -jobs. GNU B normally only reads the next job to run. +Show the estimated number of seconds before finishing. + +This forces GNU B to read all jobs before starting to find +the number of jobs. GNU B normally only reads the next job +to run. The estimate is based on the runtime of finished jobs, so the first estimate will only be shown when the first job has finished. @@ -905,8 +989,7 @@ the foreground. With B<--semaphore> GNU B will run the command in the foreground (opposite B<--bg>), and wait for completion of the command -before exiting. - +before exiting. Exit code will be that of the command. See also: B<--bg> B @@ -928,13 +1011,14 @@ Beware: If the fifo is never opened for reading, the job will block forever: Implies B<--pipe> unless B<--pipepart> is used. -See also: B<--cat> +See also: B<--cat> B<--pipe> B<--pipepart> =item B<--filter> I -Only run jobs where I is true. I can contain -replacement strings and Perl code. Example: +Only run jobs where I is true. + +I can contain replacement strings and Perl code. Example: parallel --filter '{1} < {2}+1' echo ::: {1..3} ::: {1..3} @@ -943,8 +1027,10 @@ Outputs: 1,1 1,2 1,3 2,2 2,3 3,3 =item B<--filter-hosts> -Remove down hosts. For each remote host: check that login through ssh -works. If not: do not use this host. +Remove down hosts. + +For each remote host: check that login through ssh works. If not: do +not use this host. For performance reasons, this check is performed only at the start and every time B<--sshloginfile> is changed. If an host goes down after @@ -956,23 +1042,29 @@ $PARALLEL, /etc/parallel/config or similar. This is because GNU B uses GNU B to compute this, so you will get an infinite loop. This will likely be fixed in a later release. +See also: B<--sshloginfile> B<--sshlogin> B<--retries> + =item B<--gnu> -Behave like GNU B. This option historically took precedence -over B<--tollef>. The B<--tollef> option is now retired, and therefore -may not be used. B<--gnu> is kept for compatibility. +Behave like GNU B. + +This option historically took precedence over B<--tollef>. The +B<--tollef> option is now retired, and therefore may not be +used. B<--gnu> is kept for compatibility. =item B<--group> -Group output. Output from each job is grouped together and is only -printed when the command is finished. Stdout (standard output) first -followed by stderr (standard error). +Group output. -This takes in the order of 0.5ms per job and depends on the speed of -your disk for larger output. It can be disabled with B<-u>, but this -means output from different commands can get mixed. +Output from each job is grouped together and is only printed when the +command is finished. Stdout (standard output) first followed by stderr +(standard error). + +This takes in the order of 0.5ms CPU time per job and depends on the +speed of your disk for larger output. It can be disabled with B<-u>, +but this means output from different commands can get mixed. B<--group> is the default. Can be reversed with B<-u>. @@ -981,8 +1073,10 @@ See also: B<--line-buffer> B<--ungroup> =item B<--group-by> I -Group input by value. Combined with B<--pipe>/B<--pipepart> -B<--group-by> groups lines with the same value into a record. +Group input by value. + +Combined with B<--pipe>/B<--pipepart> B<--group-by> groups lines with +the same value into a record. The value can be computed from the full line or from a single column. @@ -1049,9 +1143,8 @@ UserID when grouping: cat table.csv | parallel --pipe --colsep , --header : \ --group-by 'UserID s/\D//g' -kN1 wc -See the section: SPREADING BLOCKS OF DATA. - -See also: B<--bin> B<--shard> B<--roundrobin> +See also: SPREADING BLOCKS OF DATA B<--pipe> B<--pipepart> B<--bin> +B<--shard> B<--roundrobin> =item B<--help> @@ -1065,9 +1158,10 @@ Print a summary of the options to GNU B and exit. =item B<--halt> I -When should GNU B terminate? In some situations it makes no -sense to run all jobs. GNU B should simply give up as soon -as a condition is met. +When should GNU B terminate? + +In some situations it makes no sense to run all jobs. GNU +B should simply stop as soon as a condition is met. I defaults to B, which runs all jobs no matter what. @@ -1157,12 +1251,14 @@ soon,fail=1-99% =item B<--header> I -Use regexp as header. For normal usage the matched header (typically -the first line: B<--header '.*\n'>) will be split using B<--colsep> -(which will default to '\t') and column names can be used as -replacement variables: B<{column name}>, B<{column name/}>, B<{column -name//}>, B<{column name/.}>, B<{column name.}>, B<{=column name perl -expression =}>, .. +Use regexp as header. + +For normal usage the matched header (typically the first line: +B<--header '.*\n'>) will be split using B<--colsep> (which will +default to '\t') and column names can be used as replacement +variables: B<{column name}>, B<{column name/}>, B<{column name//}>, +B<{column name/.}>, B<{column name.}>, B<{=column name perl expression +=}>, .. For B<--pipe> the matched header will be prepended to each output. @@ -1170,15 +1266,19 @@ B<--header :> is an alias for B<--header '.*\n'>. If I is a number, it is a fixed number of lines. +See also: B<--colsep> B<--pipe> B<--pipepart> + =item B<--hostgroups> =item B<--hgrp> -Enable hostgroups on arguments. If an argument contains '@' the string -after '@' will be removed and treated as a list of hostgroups on which -this job is allowed to run. If there is no B<--sshlogin> with a -corresponding group, the job will run on any hostgroup. +Enable hostgroups on arguments. + +If an argument contains '@' the string after '@' will be removed and +treated as a list of hostgroups on which this job is allowed to +run. If there is no B<--sshlogin> with a corresponding group, the job +will run on any hostgroup. Example: @@ -1203,18 +1303,20 @@ Use the replacement string I instead of B<{}>. =item B<-i>[I] +This option is deprecated; use B<-I> instead. + This option is a synonym for B<-I>I if I is -specified, and for B<-I {}> otherwise. This option is deprecated; -use B<-I> instead. +specified, and for B<-I {}> otherwise. =item B<--joblog> I -Logfile for executed jobs. Save a list of the executed jobs to -I in the following TAB separated format: sequence number, -sshlogin, start time as seconds since epoch, run time in seconds, -bytes in files transferred, bytes in files returned, exit status, -signal, and command run. +Logfile for executed jobs. + +Save a list of the executed jobs to I in the following TAB +separated format: sequence number, sshlogin, start time as seconds +since epoch, run time in seconds, bytes in files transferred, bytes in +files returned, exit status, signal, and command run. For B<--pipe> bytes transferred and bytes returned are number of input and output of bytes. @@ -1242,10 +1344,11 @@ See also: B<--resume> B<--resume-failed> =item B<-P> I -Number of jobslots on each machine. Run up to N jobs in parallel. 0 -means as many as possible (this can take a while to -determine). Default is 100% which will run one job per CPU on each -machine. +Number of jobslots on each machine. + +Run up to N jobs in parallel. 0 means as many as possible (this can +take a while to determine). Default is 100% which will run one job per +CPU on each machine. Due to a bug B<-j 0> will also evaluate replacement strings twice up to the number of joblots: @@ -1266,8 +1369,11 @@ If B<--semaphore> is set, the default is 1 thus making a mutex. =item B<-P> I<+N> -Add N to the number of CPUs. Run this many jobs in parallel. See -also B<--use-cores-instead-of-threads> and +Add N to the number of CPU threads. + +Run this many jobs in parallel. + +See also: B<--use-cores-instead-of-threads> B<--use-sockets-instead-of-threads>. @@ -1279,8 +1385,10 @@ B<--use-sockets-instead-of-threads>. =item B<-P> I<-N> -Subtract N from the number of CPUs. Run this many jobs in parallel. -If the evaluated number is less than 1 then 1 will be used. +Subtract N from the number of CPU threads. + +Run this many jobs in parallel. If the evaluated number is less than +1 then 1 will be used. See also: B<--use-cores-instead-of-threads> B<--use-sockets-instead-of-threads> @@ -1294,8 +1402,9 @@ B<--use-sockets-instead-of-threads> =item B<-P> I% -Multiply N% with the number of CPUs. Run this many jobs in -parallel. +Multiply N% with the number of CPU threads. + +Run this many jobs in parallel. See also: B<--use-cores-instead-of-threads> B<--use-sockets-instead-of-threads> @@ -1309,23 +1418,26 @@ B<--use-sockets-instead-of-threads> =item B<-P> I -Read parameter from file. Use the content of I as parameter -for I<-j>. E.g. I could contain the string 100% or +2 or -10. If I is changed when a job completes, I is -read again and the new number of jobs is computed. If the number is -lower than before, running jobs will be allowed to finish but new jobs -will not be started until the wanted number of jobs has been reached. -This makes it possible to change the number of simultaneous running -jobs while GNU B is running. +Read parameter from file. + +Use the content of I as parameter for +I<-j>. E.g. I could contain the string 100% or +2 or 10. If +I is changed when a job completes, I is read again +and the new number of jobs is computed. If the number is lower than +before, running jobs will be allowed to finish but new jobs will not +be started until the wanted number of jobs has been reached. This +makes it possible to change the number of simultaneous running jobs +while GNU B is running. =item B<--keep-order> =item B<-k> -Keep sequence of output same as the order of input. Normally the -output of a job will be printed as soon as the job completes. Try this -to see the difference: +Keep sequence of output same as the order of input. + +Normally the output of a job will be printed as soon as the job +completes. Try this to see the difference: parallel -j4 sleep {}\; echo {} ::: 2 1 4 3 parallel -j4 -k sleep {}\; echo {} ::: 2 1 4 3 @@ -1344,6 +1456,8 @@ kept the same. Run each of these twice and compare: B<-k> only affects the order in which the output is printed - not the order in which jobs are run. +See also: B<--group> B<--line-buffer> + =item B<-L> I @@ -1356,11 +1470,13 @@ continued on the next input line. B<-L 0> means read one line, but insert 0 arguments on the command line. -I can be postfixed with K, M, G, T, P, k, m, g, t, or p (see -UNIT PREFIX). +I can be postfixed with K, M, G, T, P, k, m, g, t, or p. Implies B<-X> unless B<-m>, B<--xargs>, or B<--pipe> is set. +See also: UNIT PREFIX B<-N> B<-l> B<--block-size> B<-X> B<-m> +B<--xargs> B<--pipe> + =item B<--max-lines>[=I] @@ -1377,12 +1493,16 @@ B<-l 0> is an alias for B<-l 1>. Implies B<-X> unless B<-m>, B<--xargs>, or B<--pipe> is set. +See also: UNIT PREFIX B<-N> B<-l> B<--block-size> B<-X> B<-m> +B<--xargs> B<--pipe> + =item B<--limit> "I I" -Dynamic job limit. Before starting a new job run I with -I. The exit value of I determines what GNU B -will do: +Dynamic job limit. + +Before starting a new job run I with I. The exit value +of I determines what GNU B will do: =over 4 @@ -1420,16 +1540,20 @@ Similar to B<--memfree>. =back +See also: B<--memfree> B<--load> + =item B<--line-buffer> =item B<--lb> -Buffer output on line basis. B<--group> will keep the output together -for a whole job. B<--ungroup> allows output to mixup with half a line -coming from one job and half a line coming from another -job. B<--line-buffer> fits between these two: GNU B will -print a full line, but will allow for mixing lines of different jobs. +Buffer output on line basis. + +B<--group> will keep the output together for a whole job. B<--ungroup> +allows output to mixup with half a line coming from one job and half a +line coming from another job. B<--line-buffer> fits between these two: +GNU B will print a full line, but will allow for mixing +lines of different jobs. B<--line-buffer> takes more CPU power than both B<--group> and B<--ungroup>, but can be much faster than B<--group> if the CPU is not @@ -1450,7 +1574,7 @@ mix. Compare: parallel -j0 --lb 'echo {};sleep {};echo {}' ::: 1 3 2 4 parallel -j0 -k --lb 'echo {};sleep {};echo {}' ::: 1 3 2 4 -See also: B<--group> B<--ungroup> +See also: B<--group> B<--ungroup> B<--keep-order> =item B<--xapply> @@ -1481,26 +1605,35 @@ See also: B<--header> B<:::+> B<::::+> =item B<--load> I +Only start jobs if load is less than max-load. + Do not start new jobs on a given computer unless the number of running processes on the computer is less than I. I uses the same syntax as B<--jobs>, so I<100%> for one per CPU is a valid setting. Only difference is 0 which is interpreted as 0.01. +See also: B<--limit> B<--jobs> + =item B<--controlmaster> =item B<-M> -Use ssh's ControlMaster to make ssh connections faster. Useful if jobs -run remote and are very fast to run. This is disabled for sshlogins -that specify their own ssh command. +Use ssh's ControlMaster to make ssh connections faster. + +Useful if jobs run remote and are very fast to run. This is disabled +for sshlogins that specify their own ssh command. + +See also: B<--ssh> B<--sshlogin> =item B<-m> -Multiple arguments. Insert as many arguments as the command line -length permits. If multiple jobs are being run in parallel: distribute -the arguments evenly among the jobs. Use B<-j1> or B<--xargs> to avoid this. +Multiple arguments. + +Insert as many arguments as the command line length permits. If +multiple jobs are being run in parallel: distribute the arguments +evenly among the jobs. Use B<-j1> or B<--xargs> to avoid this. If B<{}> is not used the arguments will be appended to the line. If B<{}> is used multiple times each B<{}> will be replaced @@ -1508,16 +1641,16 @@ with all the arguments. Support for B<-m> with B<--sshlogin> is limited and may fail. -See also B<-X> for context replace. If in doubt use B<-X> as that will -most likely do what is needed. +If in doubt use B<-X> as that will most likely do what is needed. + +See also: B<-X> B<--xargs> =item B<--memfree> I Minimum memory free when starting another job. -The I can be postfixed with K, M, G, T, P, k, m, g, t, or p (see -UNIT PREFIX). +The I can be postfixed with K, M, G, T, P, k, m, g, t, or p. If the jobs take up very different amount of RAM, GNU B will only start as many as there is memory for. If less than I bytes @@ -1528,18 +1661,16 @@ put back on the queue to be run later. B<--retries> must be set to determine how many times GNU B should retry a given job. -See also: B<--termseq> B<--retries> B<--memsuspend> +See also: UNIT PREFIX B<--termseq> B<--retries> B<--memsuspend> =item B<--memsuspend> I -Suspend jobs when there is less than 2 * I memory free. The -I can be postfixed with K, M, G, T, P, k, m, g, t, or p (see -UNIT PREFIX). +Suspend jobs when there is less memory available. -If the available memory falls below 2 * I, GNU B -will suspend some of the running jobs. If the available memory falls -below I, only one job will be running. +If the available memory falls below 2 * I, GNU B will +suspend some of the running jobs. If the available memory falls below +I, only one job will be running. If a single job takes up at most I RAM, all jobs will complete without running out of memory. If you have swap available, you can @@ -1552,27 +1683,35 @@ oldest job completes. B<--memsuspend> only works on local jobs because there is no obvious way to suspend remote jobs. -See also: B<--memfree> +I can be postfixed with K, M, G, T, P, k, m, g, t, or p. + +See also: UNIT PREFIX B<--memfree> =item B<--minversion> I -Print the version GNU B and exit. If the current version of -GNU B is less than I the exit code is -255. Otherwise it is 0. +Print the version GNU B and exit. + +If the current version of GNU B is less than I the +exit code is 255. Otherwise it is 0. This is useful for scripts that depend on features only available from -a certain version of GNU B. +a certain version of GNU B: + + parallel --minversion 20170422 && + echo halt done=50% supported from version 20170422 && + parallel --halt now,done=50% echo ::: {1..100} =item B<--max-args>=I =item B<-n> I -Use at most I arguments per command line. Fewer than -I arguments will be used if the size (see the B<-s> option) -is exceeded, unless the B<-x> option is given, in which case -GNU B will exit. +Use at most I arguments per command line. + +Fewer than I arguments will be used if the size (see the +B<-s> option) is exceeded, unless the B<-x> option is given, in which +case GNU B will exit. B<-n 0> means read one argument, but insert 0 arguments on the command line. @@ -1587,10 +1726,11 @@ Implies B<-X> unless B<-m> is set. =item B<-N> I -Use at most I arguments per command line. Like B<-n> but -also makes replacement strings B<{1}> .. B<{>IB<}> that -represents argument 1 .. I. If too few args the B<{>IB<}> will -be empty. +Use at most I arguments per command line. + +Like B<-n> but also makes replacement strings B<{1}> +.. B<{>IB<}> that represents argument 1 .. I. If +too few args the B<{>IB<}> will be empty. B<-N 0> means read one argument, but insert 0 arguments on the command line. @@ -1601,30 +1741,36 @@ This will set the owner of the homedir to the user: Implies B<-X> unless B<-m> or B<--pipe> is set. -I can be postfixed with K, M, G, T, P, k, m, g, t, or p (see -UNIT PREFIX). +I can be postfixed with K, M, G, T, P, k, m, g, t, or p. When used with B<--pipe> B<-N> is the number of records to read. This is somewhat slower than B<--block>. +See also: UNIT PREFIX B<--pipe> B<--block> B<-m> B<-X> + =item B<--nonall> -B<--onall> with no arguments. Run the command on all computers given -with B<--sshlogin> but take no arguments. GNU B will log -into B<--jobs> number of computers in parallel and run the job on the -computer. B<-j> adjusts how many computers to log into in parallel. +B<--onall> with no arguments. + +Run the command on all computers given with B<--sshlogin> but take no +arguments. GNU B will log into B<--jobs> number of computers +in parallel and run the job on the computer. B<-j> adjusts how many +computers to log into in parallel. This is useful for running the same command (e.g. uptime) on a list of servers. +See also: B<--onall> + =item B<--onall> -Run all the jobs on all computers given with B<--sshlogin>. GNU -B will log into B<--jobs> number of computers in parallel -and run one job at a time on the computer. The order of the jobs will -not be changed, but some computers may finish before others. +Run all the jobs on all computers given with B<--sshlogin>. + +GNU B will log into B<--jobs> number of computers in +parallel and run one job at a time on the computer. The order of the +jobs will not be changed, but some computers may finish before others. When using B<--group> the output will be grouped by each server, so all the output from one server will be grouped together. @@ -1632,6 +1778,8 @@ all the output from one server will be grouped together. B<--joblog> will contain an entry for each job on each server, so there will be several job sequence 1. +See also: B<--nonall> + =item B<--output-as-files> @@ -1649,9 +1797,10 @@ See also: B<--results> =item B<--spreadstdin> -Spread input to jobs on stdin (standard input). Read a block of data -from stdin (standard input) and give one block of data as input to one -job. +Spread input to jobs on stdin (standard input). + +Read a block of data from stdin (standard input) and give one block of +data as input to one job. The block size is determined by B<--block> (default: 1M). The strings B<--recstart> and B<--recend> tell GNU B how a record starts @@ -1681,8 +1830,9 @@ B<--fifo> B<--cat> B<--pipepart> B<-N> B<-L> =item B<--pipepart> -Pipe parts of a physical file. B<--pipepart> works similar to -B<--pipe>, but is much faster. +Pipe parts of a physical file. + +B<--pipepart> works similar to B<--pipe>, but is much faster. B<--pipepart> has a few limitations: @@ -1710,6 +1860,8 @@ See also: <--pipe> =item B<--plain> +Ignore B<--profile>, $PARALLEL, and ~/.parallel/config. + Ignore any B<--profile>, $PARALLEL, and ~/.parallel/config to get full control on the command line (used by GNU B internally when called with B<--sshlogin>). @@ -1717,6 +1869,8 @@ called with B<--sshlogin>). =item B<--plus> +Add more replacement strings. + Activate additional replacement strings: {+/} {+.} {+..} {+...} {..} {...} {/..} {/...} {##}. The idea being that '{+foo}' matches the opposite of '{foo}' and {} = {+/}/{/} = {.}.{+.} = {+/}/{/.}.{+.} = {..}.{+..} = @@ -1758,17 +1912,20 @@ inspired by bash's parameter expansion: {,str} lowercase str if found at the start {,,str} lowercase str +See also: B<--rpl> + =item B<--progress> -Show progress of computations. List the computers involved in the task -with number of CPUs detected and the max number of jobs to run. After -that show progress for each computer: number of running jobs, number -of completed jobs, and percentage of all jobs done by this -computer. The percentage will only be available after all jobs have -been scheduled as GNU B only read the next job when ready to -schedule it - this is to avoid wasting time and memory by reading -everything at startup. +Show progress of computations. + +List the computers involved in the task with number of CPUs detected +and the max number of jobs to run. After that show progress for each +computer: number of running jobs, number of completed jobs, and +percentage of all jobs done by this computer. The percentage will only +be available after all jobs have been scheduled as GNU B +only read the next job when ready to schedule it - this is to avoid +wasting time and memory by reading everything at startup. By sending GNU B SIGUSR2 you can toggle turning on/off B<--progress> on a running GNU B process. @@ -2094,7 +2251,9 @@ See also: B<--files> B<--tag> B<--header> B<--joblog> =item B<--resume> -Resumes from the last unfinished job. By reading B<--joblog> or the +Resumes from the last unfinished job. + +By reading B<--joblog> or the B<--results> dir GNU B will figure out the last unfinished job and continue from there. As GNU B only looks at the sequence numbers in B<--joblog> then the input, the command, and @@ -2106,7 +2265,9 @@ See also: B<--joblog> B<--results> B<--resume-failed> B<--retries> =item B<--resume-failed> -Retry all failed and resume from the last unfinished job. By reading +Retry all failed and resume from the last unfinished job. + +By reading B<--joblog> GNU B will figure out the failed jobs and run those again. After that it will resume last unfinished job and continue from there. As GNU B only looks at the sequence @@ -2119,7 +2280,9 @@ See also: B<--joblog> B<--resume> B<--retry-failed> B<--retries> =item B<--retry-failed> -Retry all failed jobs in joblog. By reading B<--joblog> GNU +Retry all failed jobs in joblog. + +By reading B<--joblog> GNU B will figure out the failed jobs and run those again. B<--retry-failed> ignores the command and arguments on the command @@ -2189,16 +2352,22 @@ See also: B<--joblog> B<--resume> B<--resume-failed> B<--retries> =item B<--retries> I +Try failing jobs I times. + If a job fails, retry it on another computer on which it has not failed. Do this I times. If there are fewer than I computers in B<--sshlogin> GNU B will re-use all the computers. This is useful if some jobs fail for no apparent reason (such as network failure). +See also: B<--termseq> + =item B<--return> I -Transfer files from remote computers. B<--return> is used with +Transfer files from remote computers. + +B<--return> is used with B<--sshlogin> when the arguments are files on the remote computers. When processing is done the file I will be transferred from the remote computer using B and will be put relative to @@ -2243,6 +2412,8 @@ For details on transferring see B<--transferfile>. =item B<--round> +Distribute chunks of standard input in a round robin fashion. + Normally B<--pipe> will give a single block to each instance of the command. With B<--roundrobin> all blocks will at random be written to commands already running. This is useful if the command takes a long @@ -2392,22 +2563,19 @@ these to complete before starting another command. B<--semaphore> implies B<--bg> unless B<--fg> is specified. -B<--semaphore> implies B<--semaphorename `tty`> unless -B<--semaphorename> is specified. - -Used with B<--fg>, B<--wait>, and B<--semaphorename>. - The command B is an alias for B. -See also: B +See also: B B<--bg> B<--fg> B<--semaphorename> +B<--semaphoretimeout> B<--wait> =item B<--semaphorename> I =item B<--id> I -Use B as the name of the semaphore. Default is the name of the -controlling tty (output from B). +Use B as the name of the semaphore. + +The default is the name of the controlling tty (output from B). The default normally works as expected when used interactively, but when used in a script I should be set. I<$$> or I @@ -2417,7 +2585,7 @@ The semaphore is stored in ~/.parallel/semaphores/ Implies B<--semaphore>. -See also: B +See also: B B<--semaphore> =item B<--semaphoretimeout> I @@ -2697,8 +2865,8 @@ The remote host must have GNU B installed. B<--sshlogin> is known to cause problems with B<-m> and B<-X>. -See also: B<--transferfile> B<--return> B<--cleanup> B<--trc> -B<--sshloginfile> B<--workdir> +See also: B<--basefile> B<--transferfile> B<--return> B<--cleanup> +B<--trc> B<--sshloginfile> B<--workdir> B<--filter-hosts> =item B<--sshloginfile> I @@ -2764,6 +2932,8 @@ only contain servers that are up: done & parallel --slf tmp2.slf ... +See also: B<--filter-hosts> + =item B<--slotreplace> I @@ -2930,16 +3100,20 @@ See also: B<-v> B<-p> =item B<--transfer> -Transfer files to remote computers. Shorthand for: B<--transferfile {}>. +Transfer files to remote computers. + +Shorthand for: B<--transferfile {}>. =item B<--transferfile> I =item B<--tf> I +Transfer I to remote computers. + B<--transferfile> is used with B<--sshlogin> to transfer files to the remote computers. The files will be transferred using B and -will be put relative to the work dir (see B<--workdir>). +will be put relative to the work dir. The I will normally contain a replacement string. @@ -2981,6 +3155,9 @@ shorthand for B<--transferfile {}> is B<--transfer>. B<--transferfile> is ignored when used with B<--sshlogin :> or when not used with B<--sshlogin>. +See also: B<--workdir> B<--sshlogin> B<--basefile> B<--return> +B<--cleanup> + =item B<--trc> I @@ -5142,8 +5319,8 @@ It needs to be quoted like one of these: ls | parallel perl -ne '/^\\S+\\s+\\S+\$/\ and\ print\ \$ARGV,\"\\n\"' ls | parallel perl -ne \''/^\S+\s+\S+$/ and print $ARGV,"\n"'\' -Notice how spaces, \'s, "'s, and $'s need to be quoted. GNU B -can do the quoting by using option -q: +Notice how spaces, \'s, "'s, and $'s need to be quoted. GNU +B can do the quoting by using option -q: ls | parallel -q perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"' @@ -5175,8 +5352,8 @@ Or for substituting output: ls | parallel -q bash -c \ 'tar c {} | tee >(gzip >{}.tar.gz) | bzip2 >{}.tar.bz2' -B: To avoid dealing with the quoting problems it may be -easier just to write a small script or a function (remember to +B: If this is confusing consider avoiding having to deal +with quoting by writing a small script or a function (remember to B the function) and have GNU B call that. @@ -5349,6 +5526,11 @@ Path to B. If unset the B in $PATH is used. Directory for temporary files. See: B<--tmpdir>. +=item $PARALLEL_REMOTE_TMPDIR + +Directory for temporary files on remote servers See: B<--tmpdir>. + + =item $PARALLEL The environment variable $PARALLEL will be used as default options for @@ -5577,7 +5759,7 @@ not exist with PostgreSQL. =head1 REPORTING BUGS -Report bugs to or +Report bugs to or https://savannah.gnu.org/bugs/?func=additem&group=parallel When you write your report, please keep in mind, that you must give diff --git a/testsuite/tests-to-run/sem01.sh b/testsuite/tests-to-run/sem01.sh index 48e84b91..b0d8d23d 100755 --- a/testsuite/tests-to-run/sem01.sh +++ b/testsuite/tests-to-run/sem01.sh @@ -63,6 +63,28 @@ par_semaphore-timeout() { stdout sem --id st --wait } +par_exit() { + echo '### Exit values' + test_exit() { + stdout sem --fg --id exit$1 exit $1 + echo $? + } + export -f test_exit + parallel --tag -k test_exit ::: 0 1 10 100 101 102 222 255 + + echo '### Exit values - signal' + test_signal() { + bash -c 'kill -'$1' $$' + echo Bash exit value $? + stdout sem --fg --id signal$1 kill -$1 '$$' + echo Sem exit value $? + } + export -f test_signal + stdout parallel -k --timeout 3 --tag test_signal ::: {0..64} | + perl -pe 's/line 1: (\d+)/line 1: PID/' +} + + export -f $(compgen -A function | grep par_) compgen -A function | grep par_ | LC_ALL=C sort | parallel --timeout 3000% -j6 --tag -k --joblog /tmp/jl-`basename $0` '{} 2>&1' | diff --git a/testsuite/wanted-results/sem01 b/testsuite/wanted-results/sem01 index b490db3b..8cca93d7 100644 --- a/testsuite/wanted-results/sem01 +++ b/testsuite/wanted-results/sem01 @@ -17,6 +17,198 @@ par_2jobs done 3 par_2jobs done 4 par_bg_p_should_error ### Test bug #33621: --bg -p should give an error message par_bg_p_should_error parallel: Error: Jobs running in the background cannot be interactive. +par_exit ### Exit values +par_exit 0 0 +par_exit 1 1 +par_exit 10 10 +par_exit 100 100 +par_exit 101 101 +par_exit 102 102 +par_exit 222 222 +par_exit 255 255 +par_exit ### Exit values - signal +par_exit 0 Bash exit value 0 +par_exit 0 Sem exit value 0 +par_exit 1 Bash exit value 129 +par_exit 1 Sem exit value 129 +par_exit 1 environment: line 1: PID Hangup bash -c 'kill -'$1' $$' +par_exit 2 Bash exit value 130 +par_exit 2 Sem exit value 130 +par_exit 3 Bash exit value 0 +par_exit 3 Sem exit value 0 +par_exit 4 Bash exit value 132 +par_exit 4 Sem exit value 132 +par_exit 4 environment: line 1: PID Illegal instruction (core dumped) bash -c 'kill -'$1' $$' +par_exit 5 Bash exit value 133 +par_exit 5 Sem exit value 133 +par_exit 5 environment: line 1: PID Trace/breakpoint trap (core dumped) bash -c 'kill -'$1' $$' +par_exit 6 Bash exit value 134 +par_exit 6 Sem exit value 134 +par_exit 6 environment: line 1: PID Aborted (core dumped) bash -c 'kill -'$1' $$' +par_exit 7 Bash exit value 135 +par_exit 7 Sem exit value 135 +par_exit 7 environment: line 1: PID Bus error (core dumped) bash -c 'kill -'$1' $$' +par_exit 8 Bash exit value 136 +par_exit 8 Sem exit value 136 +par_exit 8 environment: line 1: PID Floating point exception(core dumped) bash -c 'kill -'$1' $$' +par_exit 9 Bash exit value 137 +par_exit 9 Sem exit value 137 +par_exit 9 environment: line 1: PID Killed bash -c 'kill -'$1' $$' +par_exit 10 Bash exit value 138 +par_exit 10 Sem exit value 138 +par_exit 10 environment: line 1: PID User defined signal 1 bash -c 'kill -'$1' $$' +par_exit 11 Bash exit value 139 +par_exit 11 Sem exit value 139 +par_exit 11 environment: line 1: PID Segmentation fault (core dumped) bash -c 'kill -'$1' $$' +par_exit 12 Bash exit value 140 +par_exit 12 Sem exit value 140 +par_exit 12 environment: line 1: PID User defined signal 2 bash -c 'kill -'$1' $$' +par_exit 13 Bash exit value 141 +par_exit 13 Sem exit value 141 +par_exit 14 Bash exit value 0 +par_exit 14 Sem exit value 0 +par_exit 15 Bash exit value 143 +par_exit 15 Sem exit value 143 +par_exit 15 Terminated +par_exit 16 Bash exit value 144 +par_exit 16 Sem exit value 144 +par_exit 16 environment: line 1: PID Stack fault bash -c 'kill -'$1' $$' +par_exit 17 Bash exit value 0 +par_exit 17 Sem exit value 0 +par_exit 18 Bash exit value 0 +par_exit 18 Sem exit value 0 +par_exit parallel: Warning: This job was killed because it timed out: +par_exit parallel: Warning: test_signal 19 +par_exit parallel: Warning: This job was killed because it timed out: +par_exit parallel: Warning: test_signal 20 +par_exit parallel: Warning: This job was killed because it timed out: +par_exit parallel: Warning: test_signal 21 +par_exit parallel: Warning: This job was killed because it timed out: +par_exit parallel: Warning: test_signal 22 +par_exit 23 Bash exit value 0 +par_exit 23 Sem exit value 0 +par_exit 24 Bash exit value 152 +par_exit 24 Sem exit value 152 +par_exit 24 environment: line 1: PID CPU time limit exceeded (core dumped) bash -c 'kill -'$1' $$' +par_exit 25 Bash exit value 153 +par_exit 25 Sem exit value 153 +par_exit 25 environment: line 1: PID File size limit exceeded(core dumped) bash -c 'kill -'$1' $$' +par_exit 26 Bash exit value 154 +par_exit 26 Sem exit value 154 +par_exit 26 environment: line 1: PID Virtual timer expired bash -c 'kill -'$1' $$' +par_exit 27 Bash exit value 155 +par_exit 27 Sem exit value 155 +par_exit 27 environment: line 1: PID Profiling timer expired bash -c 'kill -'$1' $$' +par_exit 28 Bash exit value 0 +par_exit 28 Sem exit value 0 +par_exit 29 Bash exit value 157 +par_exit 29 Sem exit value 157 +par_exit 29 environment: line 1: PID I/O possible bash -c 'kill -'$1' $$' +par_exit 30 Bash exit value 158 +par_exit 30 Sem exit value 158 +par_exit 30 environment: line 1: PID Power failure bash -c 'kill -'$1' $$' +par_exit 31 Bash exit value 159 +par_exit 31 Sem exit value 159 +par_exit 31 environment: line 1: PID Bad system call (core dumped) bash -c 'kill -'$1' $$' +par_exit 32 Bash exit value 160 +par_exit 32 Sem exit value 160 +par_exit 32 environment: line 1: PID Unknown signal 32 bash -c 'kill -'$1' $$' +par_exit 33 Bash exit value 161 +par_exit 33 Sem exit value 161 +par_exit 33 environment: line 1: PID Unknown signal 33 bash -c 'kill -'$1' $$' +par_exit 34 Bash exit value 162 +par_exit 34 Sem exit value 162 +par_exit 34 environment: line 1: PID Real-time signal 0 bash -c 'kill -'$1' $$' +par_exit 35 Bash exit value 163 +par_exit 35 Sem exit value 163 +par_exit 35 environment: line 1: PID Real-time signal 1 bash -c 'kill -'$1' $$' +par_exit 36 Bash exit value 164 +par_exit 36 Sem exit value 164 +par_exit 36 environment: line 1: PID Real-time signal 2 bash -c 'kill -'$1' $$' +par_exit 37 Bash exit value 165 +par_exit 37 Sem exit value 165 +par_exit 37 environment: line 1: PID Real-time signal 3 bash -c 'kill -'$1' $$' +par_exit 38 Bash exit value 166 +par_exit 38 Sem exit value 166 +par_exit 38 environment: line 1: PID Real-time signal 4 bash -c 'kill -'$1' $$' +par_exit 39 Bash exit value 167 +par_exit 39 Sem exit value 167 +par_exit 39 environment: line 1: PID Real-time signal 5 bash -c 'kill -'$1' $$' +par_exit 40 Bash exit value 168 +par_exit 40 Sem exit value 168 +par_exit 40 environment: line 1: PID Real-time signal 6 bash -c 'kill -'$1' $$' +par_exit 41 Bash exit value 169 +par_exit 41 Sem exit value 169 +par_exit 41 environment: line 1: PID Real-time signal 7 bash -c 'kill -'$1' $$' +par_exit 42 Bash exit value 170 +par_exit 42 Sem exit value 170 +par_exit 42 environment: line 1: PID Real-time signal 8 bash -c 'kill -'$1' $$' +par_exit 43 Bash exit value 171 +par_exit 43 Sem exit value 171 +par_exit 43 environment: line 1: PID Real-time signal 9 bash -c 'kill -'$1' $$' +par_exit 44 Bash exit value 172 +par_exit 44 Sem exit value 172 +par_exit 44 environment: line 1: PID Real-time signal 10 bash -c 'kill -'$1' $$' +par_exit 45 Bash exit value 173 +par_exit 45 Sem exit value 173 +par_exit 45 environment: line 1: PID Real-time signal 11 bash -c 'kill -'$1' $$' +par_exit 46 Bash exit value 174 +par_exit 46 Sem exit value 174 +par_exit 46 environment: line 1: PID Real-time signal 12 bash -c 'kill -'$1' $$' +par_exit 47 Bash exit value 175 +par_exit 47 Sem exit value 175 +par_exit 47 environment: line 1: PID Real-time signal 13 bash -c 'kill -'$1' $$' +par_exit 48 Bash exit value 176 +par_exit 48 Sem exit value 176 +par_exit 48 environment: line 1: PID Real-time signal 14 bash -c 'kill -'$1' $$' +par_exit 49 Bash exit value 177 +par_exit 49 Sem exit value 177 +par_exit 49 environment: line 1: PID Real-time signal 15 bash -c 'kill -'$1' $$' +par_exit 50 Bash exit value 178 +par_exit 50 Sem exit value 178 +par_exit 50 environment: line 1: PID Real-time signal 16 bash -c 'kill -'$1' $$' +par_exit 51 Bash exit value 179 +par_exit 51 Sem exit value 179 +par_exit 51 environment: line 1: PID Real-time signal 17 bash -c 'kill -'$1' $$' +par_exit 52 Bash exit value 180 +par_exit 52 Sem exit value 180 +par_exit 52 environment: line 1: PID Real-time signal 18 bash -c 'kill -'$1' $$' +par_exit 53 Bash exit value 181 +par_exit 53 Sem exit value 181 +par_exit 53 environment: line 1: PID Real-time signal 19 bash -c 'kill -'$1' $$' +par_exit 54 Bash exit value 182 +par_exit 54 Sem exit value 182 +par_exit 54 environment: line 1: PID Real-time signal 20 bash -c 'kill -'$1' $$' +par_exit 55 Bash exit value 183 +par_exit 55 Sem exit value 183 +par_exit 55 environment: line 1: PID Real-time signal 21 bash -c 'kill -'$1' $$' +par_exit 56 Bash exit value 184 +par_exit 56 Sem exit value 184 +par_exit 56 environment: line 1: PID Real-time signal 22 bash -c 'kill -'$1' $$' +par_exit 57 Bash exit value 185 +par_exit 57 Sem exit value 185 +par_exit 57 environment: line 1: PID Real-time signal 23 bash -c 'kill -'$1' $$' +par_exit 58 Bash exit value 186 +par_exit 58 Sem exit value 186 +par_exit 58 environment: line 1: PID Real-time signal 24 bash -c 'kill -'$1' $$' +par_exit 59 Bash exit value 187 +par_exit 59 Sem exit value 187 +par_exit 59 environment: line 1: PID Real-time signal 25 bash -c 'kill -'$1' $$' +par_exit 60 Bash exit value 188 +par_exit 60 Sem exit value 188 +par_exit 60 environment: line 1: PID Real-time signal 26 bash -c 'kill -'$1' $$' +par_exit 61 Bash exit value 189 +par_exit 61 Sem exit value 189 +par_exit 61 environment: line 1: PID Real-time signal 27 bash -c 'kill -'$1' $$' +par_exit 62 Bash exit value 190 +par_exit 62 Sem exit value 190 +par_exit 62 environment: line 1: PID Real-time signal 28 bash -c 'kill -'$1' $$' +par_exit 63 Bash exit value 191 +par_exit 63 Sem exit value 191 +par_exit 63 environment: line 1: PID Real-time signal 29 bash -c 'kill -'$1' $$' +par_exit 64 Bash exit value 192 +par_exit 64 Sem exit value 192 +par_exit 64 environment: line 1: PID Real-time signal 30 bash -c 'kill -'$1' $$' par_fg_line-buffer ### Failed on 20141226 par_fg_line-buffer OK par_fg_then_bg ### Test --fg followed by --bg