From b04f8acb7057bda74e30976acedbbd73767e5bdc Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 19 Feb 2021 09:09:16 +0000 Subject: Check return value of chdir() to stop a silly warning with some compilers, GitHub issue 2573. --- job.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'job.c') diff --git a/job.c b/job.c index efc0199e..6267336b 100644 --- a/job.c +++ b/job.c @@ -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); -- cgit v1.2.3