<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 12, 2019 at 5:56 PM Ipsen S Ripsbusker <<a href="mailto:ipsens@ripsbusker.no.eu.org" target="_blank">ipsens@ripsbusker.no.eu.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">As a tangent to Ivan's talk, we discussed the merits of checking of exit<br>
status (or other indicators of success) of parallel calls to scp.<br>
If I recall correctly, Ivan started multiple background scp processes<br>
with &, and then he waited for them to complete with the following<br>
command, which always exits 0.<br>
<br>
wait<br>
<br>
The following command waits for the same background processes, and<br>
it still exits 0 if all processes exited 0. It differs in that it<br>
exits 1 if any process exited with something other than 0.<br></blockquote><div><br></div><div>This isn't quite right. Wait with multiple pids will exit with whatever the exit code was of the last pid specified so:</div><div><br></div><div><div>$ { sh -c 'sleep 1; exit 1;' & sh -c 'sleep 1; exit 0;' & }; wait `jobs -p`</div><div>[1] 237790</div><div>[2] 237791</div><div>[1]- Exit 1 sh -c 'sleep 1; exit 1;'</div><div>[2]+ Done sh -c 'sleep 1; exit 0;'</div></div><div>$ echo $?</div><div>0</div><div><br></div><div>More from the spec:</div><div><br></div><div>"<span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px">If one or more operands were specified, all of them have terminated or were not known by the invoking shell, and the status of the last operand specified is known, then the exit status of </span><i style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px">wait</i><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px"> shall be the exit status information of the command indicated by the last operand specified."</span></div><div><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px"><br></span></div><div><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:13.3333px">source: <a href="http://pubs.opengroup.org/onlinepubs/007904975/utilities/wait.html">http://pubs.opengroup.org/onlinepubs/007904975/utilities/wait.html</a></span></font><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
wait `jobs -p`<br></blockquote><div><br></div><div>Why not just use $!?</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Note that these are of course the standard wait(1) and jobs(1),<br>
which are usually builtins in sh(1).<br>
<br>
_______________________________________________<br>
talk mailing list<br>
<a href="mailto:talk@lists.nycbug.org" target="_blank">talk@lists.nycbug.org</a><br>
<a href="http://lists.nycbug.org:8080/mailman/listinfo/talk" rel="noreferrer" target="_blank">http://lists.nycbug.org:8080/mailman/listinfo/talk</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_65597880444424893gmail_signature">regards,<br>matt</div></div></div></div>