jobserver_wait, jobserver_collect - wait for jobserver jobs to terminate
#include <jobserver.h>
int jobserver_wait(struct jobserver * js, int timeout);
int jobserver_collect(struct jobserver * js, int timeout);
The jobserver_wait() function waits for at least 1 job of jobserver js to be terminated within timeout.
The jobserver_collect() function calls jobserver_wait() repeatedly and as many times as necessary to collect all remaining jobs of jobserver js as long as each call to jobserver_wait(), waiting at most timeout, reduces the number of jobs by at least one.
The timeout argument should respect the convention described in poll(2).
When a job is terminated, the jobserver_callback_return_t callback is called (see jobserver_launch_job(3)).
For information on how the termination of a jobserver independent process should be handled see section Handling forks in jobserver(7).
On success, the number of unterminated jobs left in the jobserver is returned, i.e. the number of jobs for which the jobserver_callback_return_t function has not been called yet.
On error, -1 is returned and errno is set accordingly.
The reading end of the jobserver pipe is not open for reading. The jobserver should be closed.
A child that was not a job exited (see section Handling forks in jobserver(7)).
The function was interupted by a signal that was not SIGCHLD.
No enough memory.
jobserver(7), jobserver_clear(3), jobserver_connect(3), jobserver_close(3), jobserver_create(3), jobserver_create_n(3), jobserver_launch_job(3), jobserver_print(3), jobserver_getenv(3), jobserver_setenv(3), jobserver_terminate_job(3), jobserver_unsetenv(3)