2 .\" Copyright (c) 2004-2009, Jilles Tjoelker
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with
6 .\" or without modification, are permitted provided that the
7 .\" following conditions are met:
9 .\" 1. Redistributions of source code must retain the above
10 .\" copyright notice, this list of conditions and the
11 .\" following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the
13 .\" above copyright notice, this list of conditions and
14 .\" the following disclaimer in the documentation and/or
15 .\" other materials provided with the distribution.
17 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
18 .\" CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
19 .\" WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21 .\" PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 .\" COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
23 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 .\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 .\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 .\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
30 .\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
40 .Nd wait for processes to terminate
50 utility will wait until each of the given processes has terminated.
52 The following option is available:
53 .Bl -tag -width indent
55 Exit when any of the given processes has terminated.
57 If any process is still running after
63 value can be integer or decimal numbers.
64 Values without unit symbols are interpreted as seconds.
66 Supported unit symbols are:
67 .Bl -tag -width indent -compact
76 Print the exit status when each process terminates or
78 if the timer goes off earlier.
83 utility exits 0 on success, and >0 if an error occurs.
87 flag is specified and a timeout occurs, the exit status will be 124.
89 Invalid pids elicit a warning message but are otherwise ignored.
93 processes in the background.
94 The first one will sleep for 30 seconds and the second one for one hour.
95 Wait for any of them to finish but no more than 5 seconds.
96 Since a timeout occurs the exit status is 124:
97 .Bd -literal -offset indent
98 $ sleep 30 & sleep 3600 &
101 $ pwait -o -t5 1646 1647
106 Same as above but try to obtain the exit status of the processes.
109 is shown and the exit status is 124:
110 .Bd -literal -offset indent
111 $ sleep 30 & sleep 3600 &
114 $ pwait -v -t 5 1652 1653
122 processes in the background sleeping for 30 and 40 seconds respectively.
123 Wait 60 seconds for any of them to finish and get their exit codes:
124 .Bd -literal -offset indent
125 $ sleep 30 & sleep 40 &
128 $ pwait -v -t 60 1674 1675
129 1674: exited with status 0.
130 1675: exited with status 0.
144 is not a substitute for the
147 as it will not clean up any zombies or state in the parent process.
151 will ignore its own pid, if it is provided as a process id to wait for.
155 command first appeared in SunOS 5.8.