> That means that you have to first arrange for it not to be closed on
> exec, and it also means that qemu is now depending on the external
> program to correctly set up the incoming socket so that qemu can just
> do the accept() on it.
At this point, I wonder if it isn't better to move the accept to the
external program, so that it could even use a pipe. The accept can be
replaced by
struct pollfd pfd;
pfd.fd = fd;
pfd.events = POLLIN;
poll (&pfd, 1, INFTIM);
if (pfd.revents & (POLLERR | POLLHUP | POLLNVAL))
handle_error ();
or the equivalent using select.