Next: , Previous: , Up: Job Slots   [Contents][Index]


13.1.1 POSIX Jobserver Interaction

On POSIX systems the jobserver is implemented as a simple UNIX pipe. The pipe will be pre-loaded with one single-character token for each available job. To obtain an extra slot you must read a single character from the jobserver pipe; to release a slot you must write a single character back into the jobserver pipe. Note that the read side of the jobserver pipe is set to “blocking” mode.

To access the pipe you must parse the MAKEFLAGS variable and look for the argument string --jobserver-auth=R,W where ‘R’ and ‘W’ are non-negative integers representing file descriptors: ‘R’ is the read file descriptor and ‘W’ is the write file descriptor.

It’s important that when you release the job slot, you write back the same character you read from the pipe for that slot. Don’t assume that all tokens are the same character; different characters may have different meanings to GNU make. The order is not important, since make has no idea in what order jobs will complete anyway.

There are various error conditions you must consider to ensure your implementation is robust:


Next: , Previous: , Up: Job Slots   [Contents][Index]