term: spawn_new: check return value of chdir() and write()

This commit is contained in:
Daniel Eklöf 2020-02-20 18:46:16 +01:00
parent e751227dc6
commit 01f8719c77
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -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);
}