Commit f2956e80 authored by Michal Schmidt's avatar Michal Schmidt
Browse files

nspawn: assume stdout is always writable if it does not support epoll

stdout can be redirected to a regular file. Regular files don't support epoll.
nspawn failed with: "Failed to register fds in epoll: Operation not permitted".

If stdout does not support epoll, assume it's always writable.
parent e45460d6
...@@ -885,8 +885,17 @@ static int process_pty(int master, pid_t pid, sigset_t *mask) { ...@@ -885,8 +885,17 @@ static int process_pty(int master, pid_t pid, sigset_t *mask) {
signal_ev.events = EPOLLIN; signal_ev.events = EPOLLIN;
signal_ev.data.fd = signal_fd; signal_ev.data.fd = signal_fd;
if (epoll_ctl(ep, EPOLL_CTL_ADD, STDOUT_FILENO, &stdout_ev) < 0 || if (epoll_ctl(ep, EPOLL_CTL_ADD, STDOUT_FILENO, &stdout_ev) < 0) {
epoll_ctl(ep, EPOLL_CTL_ADD, master, &master_ev) < 0 || if (errno != EPERM) {
log_error("Failed to register stdout in epoll: %m");
r = -errno;
goto finish;
}
/* stdout without epoll support. Likely redirected to regular file. */
stdout_writable = true;
}
if (epoll_ctl(ep, EPOLL_CTL_ADD, master, &master_ev) < 0 ||
epoll_ctl(ep, EPOLL_CTL_ADD, signal_fd, &signal_ev) < 0) { epoll_ctl(ep, EPOLL_CTL_ADD, signal_fd, &signal_ev) < 0) {
log_error("Failed to register fds in epoll: %m"); log_error("Failed to register fds in epoll: %m");
r = -errno; r = -errno;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment