Passing a file descriptor to the command used in create_subprocess_exec
would result in Xvfb complaining it could not write to the file descriptor.
File descriptors are closed by default when passed to a subprocess, plus file descriptors do not inherit by default.
I have in this example shown how to use a pipe to pass in a file descriptor which we then read from to get the result. I set file descriptors to not be automatically closed and I set the pipe to allow inheritance.
docker build -t xfd .
docker run -it --rm xfd
Example result. DISPLAY 0 was allocated to one of the executions, DISPLAY 1 to the other.
$ docker run -it --rm xfd
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
DISPLAY: 0
Await xvfb
DISPLAY: 1
Await xvfb