diff options
author | nicm <nicm> | 2015-07-13 15:49:31 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-07-13 15:49:31 +0000 |
commit | c7374c31c4ba176e94825e8d734b5abe8a6879b1 (patch) | |
tree | 862211dc6d3c5137f9aee3b8feb19ea9ddcd9eaf /tty.c | |
parent | 81069f66f96dd83025fc6f2990619eb861199e10 (diff) | |
download | rtmux-c7374c31c4ba176e94825e8d734b5abe8a6879b1.tar.gz rtmux-c7374c31c4ba176e94825e8d734b5abe8a6879b1.tar.bz2 rtmux-c7374c31c4ba176e94825e8d734b5abe8a6879b1.zip |
Initialize cwd fd to -1 so that we don't close fd 0 if the client is
destroyed before it is changed. Also allow ttyname() to fail. Fixes
problems when running out of file descriptors reported by Bruno Sutic.
Diffstat (limited to 'tty.c')
-rw-r--r-- | tty.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -59,11 +59,14 @@ void tty_default_colours(struct grid_cell *, const struct window_pane *); #define tty_pane_full_width(tty, ctx) \ ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx) -void +int
tty_init(struct tty *tty, struct client *c, int fd, char *term) { char *path; + if (!isatty(fd))
+ return (-1);
+
memset(tty, 0, sizeof *tty); tty->log_fd = -1; @@ -75,13 +78,15 @@ tty_init(struct tty *tty, struct client *c, int fd, char *term) tty->client = c; if ((path = ttyname(fd)) == NULL) - fatalx("ttyname failed"); + return (-1);
tty->path = xstrdup(path); tty->cstyle = 0; tty->ccolour = xstrdup(""); tty->flags = 0; tty->term_flags = 0; +
+ return (0);
} int |