mirror of
https://github.com/tmux/tmux.git
synced 2025-09-10 13:28:20 +00:00
Don't try to change directory if it is NULL.
This commit is contained in:
20
job.c
20
job.c
@@ -52,7 +52,7 @@ struct job {
|
|||||||
|
|
||||||
char *cmd;
|
char *cmd;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
char tty[TTY_NAME_MAX];
|
char tty[TTY_NAME_MAX];
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
@@ -141,14 +141,16 @@ job_run(const char *cmd, int argc, char **argv, struct environ *e,
|
|||||||
proc_clear_signals(server_proc, 1);
|
proc_clear_signals(server_proc, 1);
|
||||||
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||||
|
|
||||||
if (chdir(cwd) == 0)
|
if (cwd != NULL) {
|
||||||
environ_set(env, "PWD", 0, "%s", cwd);
|
if (chdir(cwd) == 0)
|
||||||
else if ((home = find_home()) != NULL && chdir(home) == 0)
|
environ_set(env, "PWD", 0, "%s", cwd);
|
||||||
environ_set(env, "PWD", 0, "%s", home);
|
else if ((home = find_home()) != NULL && chdir(home) == 0)
|
||||||
else if (chdir("/") == 0)
|
environ_set(env, "PWD", 0, "%s", home);
|
||||||
environ_set(env, "PWD", 0, "/");
|
else if (chdir("/") == 0)
|
||||||
else
|
environ_set(env, "PWD", 0, "/");
|
||||||
fatal("chdir failed");
|
else
|
||||||
|
fatal("chdir failed");
|
||||||
|
}
|
||||||
|
|
||||||
environ_push(env);
|
environ_push(env);
|
||||||
environ_free(env);
|
environ_free(env);
|
||||||
|
Reference in New Issue
Block a user