10e5e4167SJilles Tjoelker.\" 20e5e4167SJilles Tjoelker.\" Copyright (c) 2004-2009, Jilles Tjoelker 30e5e4167SJilles Tjoelker.\" All rights reserved. 40e5e4167SJilles Tjoelker.\" 50e5e4167SJilles Tjoelker.\" Redistribution and use in source and binary forms, with 60e5e4167SJilles Tjoelker.\" or without modification, are permitted provided that the 70e5e4167SJilles Tjoelker.\" following conditions are met: 80e5e4167SJilles Tjoelker.\" 90e5e4167SJilles Tjoelker.\" 1. Redistributions of source code must retain the above 100e5e4167SJilles Tjoelker.\" copyright notice, this list of conditions and the 110e5e4167SJilles Tjoelker.\" following disclaimer. 120e5e4167SJilles Tjoelker.\" 2. Redistributions in binary form must reproduce the 130e5e4167SJilles Tjoelker.\" above copyright notice, this list of conditions and 140e5e4167SJilles Tjoelker.\" the following disclaimer in the documentation and/or 150e5e4167SJilles Tjoelker.\" other materials provided with the distribution. 160e5e4167SJilles Tjoelker.\" 170e5e4167SJilles Tjoelker.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 180e5e4167SJilles Tjoelker.\" CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 190e5e4167SJilles Tjoelker.\" WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 200e5e4167SJilles Tjoelker.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 210e5e4167SJilles Tjoelker.\" PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 220e5e4167SJilles Tjoelker.\" COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 230e5e4167SJilles Tjoelker.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 240e5e4167SJilles Tjoelker.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 250e5e4167SJilles Tjoelker.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 260e5e4167SJilles Tjoelker.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 270e5e4167SJilles Tjoelker.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 280e5e4167SJilles Tjoelker.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 290e5e4167SJilles Tjoelker.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 300e5e4167SJilles Tjoelker.\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 310e5e4167SJilles Tjoelker.\" OF SUCH DAMAGE. 320e5e4167SJilles Tjoelker.\" 330e5e4167SJilles Tjoelker.\" $FreeBSD$ 340e5e4167SJilles Tjoelker.\" 35*270a4869SFernando Apesteguía.Dd October 5, 2020 360e5e4167SJilles Tjoelker.Dt PWAIT 1 37aa12cea2SUlrich Spörlein.Os 380e5e4167SJilles Tjoelker.Sh NAME 390e5e4167SJilles Tjoelker.Nm pwait 400e5e4167SJilles Tjoelker.Nd wait for processes to terminate 410e5e4167SJilles Tjoelker.Sh SYNOPSIS 420e5e4167SJilles Tjoelker.Nm 43b06b52baSBryan Drewery.Op Fl t Ar duration 442362bc2cSPawel Jakub Dawidek.Op Fl ov 450e5e4167SJilles Tjoelker.Ar pid 460e5e4167SJilles Tjoelker\&... 470e5e4167SJilles Tjoelker.Sh DESCRIPTION 480e5e4167SJilles TjoelkerThe 490e5e4167SJilles Tjoelker.Nm 500e5e4167SJilles Tjoelkerutility will wait until each of the given processes has terminated. 510e5e4167SJilles Tjoelker.Pp 520e5e4167SJilles TjoelkerThe following option is available: 530e5e4167SJilles Tjoelker.Bl -tag -width indent 542362bc2cSPawel Jakub Dawidek.It Fl o 552362bc2cSPawel Jakub DawidekExit when any of the given processes has terminated. 56b06b52baSBryan Drewery.It Fl t Ar duration 57b06b52baSBryan DreweryIf any process is still running after 58b06b52baSBryan Drewery.Ar duration , 59b06b52baSBryan Drewery.Nm 60b06b52baSBryan Drewerywill exit. 61b06b52baSBryan DreweryThe 62b06b52baSBryan Drewery.Ar duration 63b06b52baSBryan Dreweryvalue can be integer or decimal numbers. 64b06b52baSBryan DreweryValues without unit symbols are interpreted as seconds. 65b06b52baSBryan Drewery.Pp 66b06b52baSBryan DrewerySupported unit symbols are: 67b06b52baSBryan Drewery.Bl -tag -width indent -compact 68b06b52baSBryan Drewery.It s 69b06b52baSBryan Dreweryseconds 70b06b52baSBryan Drewery.It m 71b06b52baSBryan Dreweryminutes 72b06b52baSBryan Drewery.It h 73b06b52baSBryan Dreweryhours 74b06b52baSBryan Drewery.El 750e5e4167SJilles Tjoelker.It Fl v 76*270a4869SFernando ApesteguíaPrint the exit status when each process terminates or 77*270a4869SFernando Apesteguía.Ql timeout 78*270a4869SFernando Apesteguíaif the timer goes off earlier. 790e5e4167SJilles Tjoelker.El 80b06b52baSBryan Drewery.Sh EXIT STATUS 810e5e4167SJilles TjoelkerThe 820e5e4167SJilles Tjoelker.Nm 83b06b52baSBryan Dreweryutility exits 0 on success, and >0 if an error occurs. 84b06b52baSBryan Drewery.Pp 85b06b52baSBryan DreweryIf the 86b06b52baSBryan Drewery.Fl t 87b06b52baSBryan Dreweryflag is specified and a timeout occurs, the exit status will be 124. 880e5e4167SJilles Tjoelker.Pp 890e5e4167SJilles TjoelkerInvalid pids elicit a warning message but are otherwise ignored. 90*270a4869SFernando Apesteguía.Sh EXAMPLES 91*270a4869SFernando ApesteguíaStart two 92*270a4869SFernando Apesteguía.Xr sleep 1 93*270a4869SFernando Apesteguíaprocesses in the background. 94*270a4869SFernando ApesteguíaThe first one will sleep for 30 seconds and the second one for one hour. 95*270a4869SFernando ApesteguíaWait for any of them to finish but no more than 5 seconds. 96*270a4869SFernando ApesteguíaSince a timeout occurs the exit status is 124: 97*270a4869SFernando Apesteguía.Bd -literal -offset indent 98*270a4869SFernando Apesteguía$ sleep 30 & sleep 3600 & 99*270a4869SFernando Apesteguía[1] 1646 100*270a4869SFernando Apesteguía[2] 1647 101*270a4869SFernando Apesteguía$ pwait -o -t5 1646 1647 102*270a4869SFernando Apesteguía$? 103*270a4869SFernando Apesteguía124 104*270a4869SFernando Apesteguía.Ed 105*270a4869SFernando Apesteguía.Pp 106*270a4869SFernando ApesteguíaSame as above but try to obtain the exit status of the processes. 107*270a4869SFernando ApesteguíaIn this case 108*270a4869SFernando Apesteguía.Ql timeout 109*270a4869SFernando Apesteguíais shown and the exit status is 124: 110*270a4869SFernando Apesteguía.Bd -literal -offset indent 111*270a4869SFernando Apesteguía$ sleep 30 & sleep 3600 & 112*270a4869SFernando Apesteguía[1] 1652 113*270a4869SFernando Apesteguía[2] 1653 114*270a4869SFernando Apesteguía$ pwait -v -t 5 1652 1653 115*270a4869SFernando Apesteguíatimeout 116*270a4869SFernando Apesteguía$? 117*270a4869SFernando Apesteguía124 118*270a4869SFernando Apesteguía.Ed 119*270a4869SFernando Apesteguía.Pp 120*270a4869SFernando ApesteguíaStart two 121*270a4869SFernando Apesteguía.Xr sleep 1 122*270a4869SFernando Apesteguíaprocesses in the background sleeping for 30 and 40 seconds respectively. 123*270a4869SFernando ApesteguíaWait 60 seconds for any of them to finish and get their exit codes: 124*270a4869SFernando Apesteguía.Bd -literal -offset indent 125*270a4869SFernando Apesteguía$ sleep 30 & sleep 40 & 126*270a4869SFernando Apesteguía[1] 1674 127*270a4869SFernando Apesteguía[2] 1675 128*270a4869SFernando Apesteguía$ pwait -v -t 60 1674 1675 129*270a4869SFernando Apesteguía1674: exited with status 0. 130*270a4869SFernando Apesteguía1675: exited with status 0. 131*270a4869SFernando Apesteguía[1]- Done sleep 30 132*270a4869SFernando Apesteguía[2]+ Done sleep 40 133*270a4869SFernando Apesteguía$ echo $? 134*270a4869SFernando Apesteguía0 135*270a4869SFernando Apesteguía.Ed 1360e5e4167SJilles Tjoelker.Sh SEE ALSO 1370e5e4167SJilles Tjoelker.Xr kill 1 , 1380e5e4167SJilles Tjoelker.Xr pkill 1 , 1390e5e4167SJilles Tjoelker.Xr ps 1 , 1400e5e4167SJilles Tjoelker.Xr wait 1 , 1410e5e4167SJilles Tjoelker.Xr kqueue 2 1420e5e4167SJilles Tjoelker.Sh NOTES 1430e5e4167SJilles Tjoelker.Nm 1440e5e4167SJilles Tjoelkeris not a substitute for the 1450e5e4167SJilles Tjoelker.Xr wait 1 1460e5e4167SJilles Tjoelkerbuiltin 1470e5e4167SJilles Tjoelkeras it will not clean up any zombies or state in the parent process. 1480e5e4167SJilles Tjoelker.Sh HISTORY 1490e5e4167SJilles TjoelkerA 1500e5e4167SJilles Tjoelker.Nm 1510e5e4167SJilles Tjoelkercommand first appeared in SunOS 5.8. 152