This is the homepage for wait4, a tool to wait for the termination of an arbitrary process.
wait4 is distributed under the terms of the GNU General Public License, version 3 or higher.
wait4 is used in the same way than the standard shell command wait, the only difference being that wait4 is not restricted to waiting child processes of the current shell: it can wait for any process, including processes of another user.
The following command:
$ wait4 1234 5678
will hold the terminal until the processes of PID 1234 and 5678 terminate, then wait4 will return the exit code of the 5768 process (this is not possible on all systems, see below).
-t, --timeout option is used,
wait4 will exit once all target processes have terminated
or when the specified time (in seconds) has elapsed, whichever
To function properly, wait4 relies on some non-standard mechanisms that the underlying system must provide to keep a program informed of process termination events.
On GNU/Linux, wait4 uses Netlink; this requires wait4 to start with root privileges to be able to bind a socket to a AF_NETLINK address; these privileges are dropped after the bind(2) call.
On some BSD systems, wait4 should be able to use the kevent(2) system call. Support for this has been currently tested on NetBSD only, any input from BSD users or developers is welcome. Note that there are some minor differences in the kevent(2) implementation between the different flavors of BSD, and it seems that only the FreeBSD kevent(2) allows to retrieve the termination status of a process.
On systems where neither Netlink or kevent is available, wait4 uses a signal-based polling method: it pretends to send a signal to the target process(es) every second. This method should work on any POSIX-compliant system but with the following limitations:
The source code is stored in a Git repository which can be cloned with the following command:
$ git clone https://git.incenp.org/damien/wait4.git
Download the last release tarball:
wait4-0.3.1.tar.gz (application/gzip, 101K, signature)