return err;
}
-static int spawn_read(struct udev_event *event,
+static void spawn_read(struct udev_event *event,
const char *cmd,
int fd_stdout, int fd_stderr,
char *result, size_t ressize)
size_t respos = 0;
int fd_ep = -1;
struct epoll_event ep_outpipe, ep_errpipe;
- int err = 0;
/* read from child if requested */
if (fd_stdout < 0 && fd_stderr < 0)
- return 0;
+ return;
fd_ep = epoll_create1(EPOLL_CLOEXEC);
if (fd_ep < 0) {
- err = -errno;
err(udev, "error creating epoll fd: %m\n");
goto out;
}
age_usec = now_usec() - event->birth_usec;
if (age_usec >= event->timeout_usec) {
- err = -ETIMEDOUT;
err(udev, "timeout '%s'\n", cmd);
goto out;
}
if (fdcount < 0) {
if (errno == EINTR)
continue;
- err = -errno;
err(udev, "failed to poll: %m\n");
goto out;
}
if (fdcount == 0) {
- err = -ETIMEDOUT;
err(udev, "timeout '%s'\n", cmd);
goto out;
}
respos += count;
} else {
err(udev, "'%s' ressize %zd too short\n", cmd, ressize);
- err = -ENOBUFS;
}
}
}
} else if (ev[i].events & EPOLLHUP) {
if (epoll_ctl(fd_ep, EPOLL_CTL_DEL, *fd, NULL) < 0) {
- err = -errno;
err(udev, "failed to remove fd from epoll: %m\n");
goto out;
}
out:
if (fd_ep >= 0)
close(fd_ep);
- return err;
}
static int spawn_wait(struct udev_event *event, const char *cmd, pid_t pid)
errpipe[WRITE_END] = -1;
}
- err = spawn_read(event, cmd,
- outpipe[READ_END], errpipe[READ_END],
- result, ressize);
+ spawn_read(event, cmd,
+ outpipe[READ_END], errpipe[READ_END],
+ result, ressize);
err = spawn_wait(event, cmd, pid);
}