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

NAME

jobserver_getenv_, jobserver_setenv_ - access the jobserver environment variable

SYNOPSIS

#include <jobserver.h>

int jobserver_getenv_(int * read, int * write, bool * dry_run, bool * debug, bool * Keep_going);
int jobserver_setenv_(int read, int write, bool dry_run, bool debug, bool keep_going);

DESCRIPTION

The jobserver_getenv_() function looks for the read and write file descriptors of the jobserver token pipe as well as its dry_run, debug, and keep_going status.

The jobserver_setenv_() function sets the jobserver token pipe file descriptors read and write in the environment as well as the dry_run, debug, and keep_going statuses.

RETURN VALUE

On success, the jobserver_getenv_() and jobserver_setenv_() functions return 0. On error, -1 is returned and errno is set accordingly.

The jobserver_getenv_() function returns 0 and both read and write are set to -1 if the jobserver is non existant, either because the MAKEFLAGS environment variable is not defined or because the --jobserver-auth (or --jobserver-fds) option is not used (see ENVIRONMENT in jobserver(7)). The dry_run, debug, and keep_going statuses, if present, are always collected.

The jobserver_setenv_() function overwrites any preexisting jobserver. When read and write are negative, the jobserver is completely removed from the environment. Note that this may not remove the MAKEFLAGS variable from the environment and that other options corresponding to the dry_run, debug, and keep_going status of the process are kept.

ERROR

EBADF

(jobserver_getenv_()) One of the read or write file descriptor could not be parsed.

ENOMEM

(jobserver_setenv_()) Not enough memory to add or change the MAKEFLAGS environment variable.

ATTRIBUTES

For an explanation of the terms used in this section, see attributes(7).

Interface Attribute Value
jobserver_getenv_() Thread safety MT-Safe env, locale
jobserver_setenv_() Thread safety MT-Unsafe const:env

SEE ALSO

jobserver(7), jobserver_getenv(3), jobserver_setenv(3), jobserver_unsetenv(3)