-// $Id: vlogin.c 2325 2006-09-21 19:42:31Z dhozac $
+// $Id: vlogin.c 2525 2007-04-08 00:40:16Z dhozac $
// Copyright (C) 2006 Benedikt Böhm <hollow@gentoo.org>
// Based on vserver-utils' vlogin program.
}
/* copy terminal activities */
-static void
+static ssize_t
terminal_copy(int src, int dst)
{
char buf[64];
terminal_kill(SIGTERM);
exit(1);
} else if (len == -1)
- return;
+ return -1;
/* write activity to user */
EwriteAll(dst, buf, len);
+
+ return len;
}
/* shuffle all output, and reset the terminal */
exit(wrapper_exit_code);
}
- if (FD_ISSET(STDIN_FILENO, &rfds))
- terminal_copy(STDIN_FILENO, t.fd);
+ if (FD_ISSET(STDIN_FILENO, &rfds)) {
+ /* EOF */
+ if (terminal_copy(STDIN_FILENO, t.fd) == 0) {
+ terminal_kill(SIGHUP);
+ exit(0);
+ }
+ }
- if (FD_ISSET(t.fd, &rfds))
- terminal_copy(t.fd, STDOUT_FILENO);
+ if (FD_ISSET(t.fd, &rfds)) {
+ /* EOF */
+ if (terminal_copy(t.fd, STDOUT_FILENO) == 0) {
+ terminal_kill(SIGHUP);
+ exit(0);
+ }
+ }
}
/* never get here, signal handler exits */