diff options
Diffstat (limited to 'usr.bin/tmux/job.c')
-rw-r--r-- | usr.bin/tmux/job.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/tmux/job.c b/usr.bin/tmux/job.c index 8358f8e301c..ade884d008d 100644 --- a/usr.bin/tmux/job.c +++ b/usr.bin/tmux/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.37 2015/10/28 09:51:55 nicm Exp $ */ +/* $OpenBSD: job.c,v 1.38 2015/10/31 08:13:58 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -41,13 +41,14 @@ struct joblist all_jobs = LIST_HEAD_INITIALIZER(all_jobs); /* Start a job running, if it isn't already. */ struct job * -job_run(const char *cmd, struct session *s, int cwd, +job_run(const char *cmd, struct session *s, const char *cwd, void (*callbackfn)(struct job *), void (*freefn)(void *), void *data) { struct job *job; struct environ *env; pid_t pid; int nullfd, out[2]; + const char *home; if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, out) != 0) return (NULL); @@ -67,8 +68,10 @@ job_run(const char *cmd, struct session *s, int cwd, case 0: /* child */ clear_signals(1); - if (cwd != -1 && fchdir(cwd) != 0) - chdir("/"); + if (cwd == NULL || chdir(cwd) != 0) { + if ((home = find_home()) == NULL || chdir(home) != 0) + chdir("/"); + } environ_push(env); environ_free(env); |