Changeset View
Changeset View
Standalone View
Standalone View
bin/pwait/pwait.1
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
.It s | .It s | ||||
seconds | seconds | ||||
.It m | .It m | ||||
minutes | minutes | ||||
.It h | .It h | ||||
hours | hours | ||||
.El | .El | ||||
.It Fl v | .It Fl v | ||||
Print the exit status when each process terminates. | Print the exit status when each process terminates or | ||||
.Ql timeout | |||||
if the timer goes off earlier. | |||||
.El | .El | ||||
.Sh EXIT STATUS | .Sh EXIT STATUS | ||||
The | The | ||||
.Nm | .Nm | ||||
utility exits 0 on success, and >0 if an error occurs. | utility exits 0 on success, and >0 if an error occurs. | ||||
.Pp | .Pp | ||||
If the | If the | ||||
.Fl t | .Fl t | ||||
flag is specified and a timeout occurs, the exit status will be 124. | flag is specified and a timeout occurs, the exit status will be 124. | ||||
.Pp | .Pp | ||||
Invalid pids elicit a warning message but are otherwise ignored. | Invalid pids elicit a warning message but are otherwise ignored. | ||||
.Sh EXAMPLES | |||||
Start two | |||||
.Xr sleep 1 | |||||
processes in the background. | |||||
The first one will sleep for 30 seconds and the second one for one hour. | |||||
Wait for any of them to finish but no more than 5 seconds. | |||||
Since a timeout occurs the exit status is 124: | |||||
.Bd -literal -offset indent | |||||
$ sleep 30 & sleep 3600 & | |||||
[1] 1646 | |||||
[2] 1647 | |||||
$ pwait -o -t5 1646 1647 | |||||
$? | |||||
124 | |||||
.Ed | |||||
.Pp | |||||
Same as above but try to obtain the exit status of the processes. | |||||
In this case | |||||
.Ql timeout | |||||
is shown and the exit status is 124: | |||||
.Bd -literal -offset indent | |||||
$ sleep 30 & sleep 3600 & | |||||
[1] 1652 | |||||
[2] 1653 | |||||
$ pwait -v -t 5 1652 1653 | |||||
timeout | |||||
$? | |||||
124 | |||||
.Ed | |||||
.Pp | |||||
Start two | |||||
.Xr sleep 1 | |||||
processes in the background sleeping for 30 and 40 seconds respectively. | |||||
Wait 60 seconds for any of them to finish and get their exit codes: | |||||
.Bd -literal -offset indent | |||||
$ sleep 30 & sleep 40 & | |||||
[1] 1674 | |||||
[2] 1675 | |||||
$ pwait -v -t 60 1674 1675 | |||||
1674: exited with status 0. | |||||
1675: exited with status 0. | |||||
[1]- Done sleep 30 | |||||
[2]+ Done sleep 40 | |||||
$ echo $? | |||||
0 | |||||
.Ed | |||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr kill 1 , | .Xr kill 1 , | ||||
.Xr pkill 1 , | .Xr pkill 1 , | ||||
.Xr ps 1 , | .Xr ps 1 , | ||||
.Xr wait 1 , | .Xr wait 1 , | ||||
.Xr kqueue 2 | .Xr kqueue 2 | ||||
.Sh NOTES | .Sh NOTES | ||||
.Nm | .Nm | ||||
is not a substitute for the | is not a substitute for the | ||||
.Xr wait 1 | .Xr wait 1 | ||||
builtin | builtin | ||||
as it will not clean up any zombies or state in the parent process. | as it will not clean up any zombies or state in the parent process. | ||||
.Sh HISTORY | .Sh HISTORY | ||||
A | A | ||||
.Nm | .Nm | ||||
command first appeared in SunOS 5.8. | command first appeared in SunOS 5.8. |