{
struct lxc_console *console = (struct lxc_console *)data;
char buf[1024];
- int r,w;
-
- if (events & EPOLLHUP)
- return 1;
-
- w = r = read(fd, buf, sizeof(buf));
- if (r < 0) {
- SYSERROR("failed to read");
- return 1;
- }
+ int r, w;
- if (!r) {
+ w = r = lxc_read_nointr(fd, buf, sizeof(buf));
+ if (r <= 0) {
INFO("console client on fd %d has exited", fd);
lxc_mainloop_del_handler(descr, fd);
close(fd);
- return 0;
+ return 1;
}
if (fd == console->peer)
- w = write(console->master, buf, r);
+ w = lxc_write_nointr(console->master, buf, r);
if (fd == console->master) {
if (console->log_fd >= 0)
- w = write(console->log_fd, buf, r);
+ w = lxc_write_nointr(console->log_fd, buf, r);
if (console->peer >= 0)
- w = write(console->peer, buf, r);
+ w = lxc_write_nointr(console->peer, buf, r);
}
if (w != r)
goto err2;
}
- if (lxc_console_mainloop_add(&descr, conf) < 0)
+ if (lxc_console_mainloop_add(&descr, conf) < 0) {
+ ERROR("Failed to add handlers to lxc mainloop.");
goto err3;
+ }
ret = lxc_mainloop(&descr, -1);
if (ret) {