diff options
author | nicm <nicm> | 2021-02-19 09:09:16 +0000 |
---|---|---|
committer | nicm <nicm> | 2021-02-19 09:09:16 +0000 |
commit | b04f8acb7057bda74e30976acedbbd73767e5bdc (patch) | |
tree | 8b3be4d6a36b2dcc2fb668a510f94f4d3a1ec1d0 | |
parent | fb42ae3071763fdc6a2fe2e57feec774623b1c33 (diff) | |
download | rtmux-b04f8acb7057bda74e30976acedbbd73767e5bdc.tar.gz rtmux-b04f8acb7057bda74e30976acedbbd73767e5bdc.tar.bz2 rtmux-b04f8acb7057bda74e30976acedbbd73767e5bdc.zip |
Check return value of chdir() to stop a silly warning with some
compilers, GitHub issue 2573.
-rw-r--r-- | job.c | 8 | ||||
-rw-r--r-- | spawn.c | 8 |
2 files changed, 8 insertions, 8 deletions
@@ -114,10 +114,10 @@ job_run(const char *cmd, struct session *s, const char *cwd, proc_clear_signals(server_proc, 1); sigprocmask(SIG_SETMASK, &oldset, NULL); - if (cwd == NULL || chdir(cwd) != 0) { - if ((home = find_home()) == NULL || chdir(home) != 0) - chdir("/"); - } + if ((cwd == NULL || chdir(cwd) != 0) && + ((home = find_home()) == NULL || chdir(home) != 0) && + chdir("/") != 0) + fatal("chdir failed"); environ_push(env); environ_free(env); @@ -379,10 +379,10 @@ spawn_pane(struct spawn_context *sc, char **cause) * Child process. Change to the working directory or home if that * fails. */ - if (chdir(new_wp->cwd) != 0) { - if ((tmp = find_home()) == NULL || chdir(tmp) != 0) - chdir("/"); - } + if (chdir(new_wp->cwd) != 0 && + ((tmp = find_home()) == NULL || chdir(tmp) != 0) && + chdir("/") != 0) + fatal("chdir failed"); /* * Update terminal escape characters from the session if available and |