There is a race in proc_open in PHP that is currently not avoided by
setting FD_CLOEXEC on the pipe file descriptors (with the 'e' flag for
the pipes). What happens, in a multithreaded Apache environment, when
multiple rrdtools are attempted to be launched (for example, when a lot
of graphs are requested at once) is this:
Thread 1: creates pipes for stdin/stdout
Thread 2: creates pipes for stdin/stdout
Thread 1: forks process x
Thread 2: forks process y
Process x: inherits pipes from Thread 1 and Thread 2
Process y: inherits pipes from Thread 1 and Thread 2
Process x: closes 'other side' of pipes from Thread 1
Process x: executes rrdtool
Thread 1: closes 'other side' of its pipes
Thread 1: writes command to rrdtool (no trailing newline)
Thread 1: closes stdin pipe to Process x
Process x: receives command from Thread 1
Process x: waits for more data, or stdin to close
Process x: hangs, because the pipe is still open in Process y
Thread 1: waits for data from rrdtool, which never comes
(meanwhile, the same thing happens between Thread 2 and Process y)
This is really a PHP bug, and I'll see if there's a possibility to get
that fixed there, but this at least fixes the problem by allowing
rrdtool to exit, itself, instead of waiting for stdin to be closed.