diff --git a/tty.c b/tty.c
index 9d30ed9..2535bf3 100644
--- a/tty.c
+++ b/tty.c
@@ -283,7 +283,8 @@ tty_free(struct tty *tty)
void
tty_raw(struct tty *tty, const char *s)
{
- write(tty->fd, s, strlen(s));
+ if (write(tty->fd, s, strlen(s)) == -1)
+ fatal("write failed");
}
void
@@ -316,7 +317,9 @@ tty_puts(struct tty *tty, const char *s)
buffer_write(tty->out, s, strlen(s));
if (tty->log_fd != -1)
- write(tty->log_fd, s, strlen(s));
+ if (write(tty->log_fd, s, strlen(s)) == -1)
+ fatal("write failed");
+
}
void
@@ -342,7 +345,8 @@ tty_putc(struct tty *tty, u_char ch)
}
if (tty->log_fd != -1)
- write(tty->log_fd, &ch, 1);
+ if (write(tty->log_fd, &ch, 1) == -1)
+ fatal("write failed");
}
void
@@ -355,7 +359,9 @@ tty_pututf8(struct tty *tty, const struct grid_utf8 *gu)
break;
buffer_write8(tty->out, gu->data[i]);
if (tty->log_fd != -1)
- write(tty->log_fd, &gu->data[i], 1);
+ if (write(tty->log_fd, &gu->data[i], 1) == -1)
+ fatal("write failed");
+
}
tty->cx += gu->width;
diff --git a/window.c b/window.c
index f4be17d..318d2e9 100644
--- a/window.c
+++ b/window.c
@@ -516,7 +516,9 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
return (-1);
case 0:
if (chdir(wp->cwd) != 0)
- chdir("/");
+ if (chdir("/") <0)
+ fatal("chdir failed");
+
if (tcgetattr(STDIN_FILENO, &tio2) != 0)
fatal("tcgetattr failed");