libjobserver – v0.2.0 Handle parallel jobs in a build automation application compatible with GNU Make code.malloc.fr

NAME

jobserver_wait, jobserver_collect - wait for jobserver jobs to terminate

SYNOPSIS

#include <jobserver.h>

int jobserver_wait(struct jobserver * js, int timeout);
int jobserver_collect(struct jobserver * js, int timeout);

DESCRIPTION

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).

RETURN VALUE

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.

ERROR

EBADF

The reading end of the jobserver pipe is not open for reading. The jobserver should be closed.

ECHILD

A child that was not a job exited (see section Handling forks in jobserver(7)).

EINTR

The function was interupted by a signal that was not SIGCHLD.

ENOMEM

No enough memory.

SEE ALSO

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)