Creating a pipe with O_NONBLOCK causes both the read and the write end to
be marked as non-blocking.
The "write" end is passed to the kernel autofs module, and it does not
expect a non-blocking pipe. If it gets -EAGAIN when trying to write
(which is unlikely, but not completely impossible), it will close the
write end of the pipe, which leads to unexpected errors.
So change the code to only set O_NONBLOCK on the "read" end of the
pipe. This is the only end that systemd interacts with, so the only end
it should be configuring.
goto fail;
}
- if (pipe2(p, O_NONBLOCK|O_CLOEXEC) < 0) {
+ if (pipe2(p, O_CLOEXEC) < 0) {
r = -errno;
goto fail;
}
+ r = fd_nonblock(p[0], true);
+ if (r < 0)
+ goto fail;
xsprintf(options, "fd=%i,pgrp="PID_FMT",minproto=5,maxproto=5,direct", p[1], getpgrp());
xsprintf(name, "systemd-"PID_FMT, getpid_cached());