aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-02-20 17:46:16 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-02-20 17:46:16 +0000
commit01f8719c77d85d11ba04a16218094ced1b7d59ef (patch)
tree79c839d7bd706b415c587f626e38217d28a0f3c8
parentclient: allocate current working directory buffer dynamically (diff)
term: spawn_new: check return value of chdir() and write()
-rw-r--r--terminal.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/terminal.c b/terminal.c
index 37b2cc84..ba19b552 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1961,9 +1961,13 @@ term_spawn_new(const struct terminal *term)
if (pid2 == 0) {
/* Child */
close(pipe_fds[0]);
- chdir(term->cwd);
- execlp(term->foot_exe, term->foot_exe, NULL);
- write(pipe_fds[1], &errno, sizeof(errno));
+ if (chdir(term->cwd) < 0 ||
+ execlp(term->foot_exe, term->foot_exe, NULL) < 0)
+ {
+ (void)!write(pipe_fds[1], &errno, sizeof(errno));
+ _exit(errno);
+ }
+ assert(false);
_exit(errno);
}