mirror of
https://github.com/tmux/tmux.git
synced 2024-11-18 02:18:53 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
fc84097379
12
client.c
12
client.c
@ -497,20 +497,10 @@ client_send_identify(const char *ttynam, const char *termname, char **caps,
|
|||||||
static __dead void
|
static __dead void
|
||||||
client_exec(const char *shell, const char *shellcmd)
|
client_exec(const char *shell, const char *shellcmd)
|
||||||
{
|
{
|
||||||
const char *name, *ptr;
|
|
||||||
char *argv0;
|
char *argv0;
|
||||||
|
|
||||||
log_debug("shell %s, command %s", shell, shellcmd);
|
log_debug("shell %s, command %s", shell, shellcmd);
|
||||||
|
argv0 = shell_argv0(shell, !!(client_flags & CLIENT_LOGIN));
|
||||||
ptr = strrchr(shell, '/');
|
|
||||||
if (ptr != NULL && *(ptr + 1) != '\0')
|
|
||||||
name = ptr + 1;
|
|
||||||
else
|
|
||||||
name = shell;
|
|
||||||
if (client_flags & CLIENT_LOGIN)
|
|
||||||
xasprintf(&argv0, "-%s", name);
|
|
||||||
else
|
|
||||||
xasprintf(&argv0, "%s", name);
|
|
||||||
setenv("SHELL", shell, 1);
|
setenv("SHELL", shell, 1);
|
||||||
|
|
||||||
proc_clear_signals(client_proc, 1);
|
proc_clear_signals(client_proc, 1);
|
||||||
|
31
job.c
31
job.c
@ -77,19 +77,28 @@ job_run(const char *cmd, int argc, char **argv, struct environ *e, struct sessio
|
|||||||
struct environ *env;
|
struct environ *env;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int nullfd, out[2], master;
|
int nullfd, out[2], master;
|
||||||
const char *home;
|
const char *home, *shell;
|
||||||
sigset_t set, oldset;
|
sigset_t set, oldset;
|
||||||
struct winsize ws;
|
struct winsize ws;
|
||||||
char **argvp, tty[TTY_NAME_MAX];
|
char **argvp, tty[TTY_NAME_MAX], *argv0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do not set TERM during .tmux.conf, it is nice to be able to use
|
* Do not set TERM during .tmux.conf (second argument here), it is nice
|
||||||
* if-shell to decide on default-terminal based on outside TERM.
|
* to be able to use if-shell to decide on default-terminal based on
|
||||||
|
* outside TERM.
|
||||||
*/
|
*/
|
||||||
env = environ_for_session(s, !cfg_finished);
|
env = environ_for_session(s, !cfg_finished);
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
environ_copy(e, env);
|
environ_copy(e, env);
|
||||||
|
|
||||||
|
if (s != NULL)
|
||||||
|
shell = options_get_string(s->options, "default-shell");
|
||||||
|
else
|
||||||
|
shell = options_get_string(global_s_options, "default-shell");
|
||||||
|
if (!checkshell(shell))
|
||||||
|
shell = _PATH_BSHELL;
|
||||||
|
argv0 = shell_argv0(shell, 0);
|
||||||
|
|
||||||
sigfillset(&set);
|
sigfillset(&set);
|
||||||
sigprocmask(SIG_BLOCK, &set, &oldset);
|
sigprocmask(SIG_BLOCK, &set, &oldset);
|
||||||
|
|
||||||
@ -105,10 +114,11 @@ job_run(const char *cmd, int argc, char **argv, struct environ *e, struct sessio
|
|||||||
}
|
}
|
||||||
if (cmd == NULL) {
|
if (cmd == NULL) {
|
||||||
cmd_log_argv(argc, argv, "%s:", __func__);
|
cmd_log_argv(argc, argv, "%s:", __func__);
|
||||||
log_debug("%s: cwd=%s", __func__, cwd == NULL ? "" : cwd);
|
log_debug("%s: cwd=%s, shell=%s", __func__,
|
||||||
|
cwd == NULL ? "" : cwd, shell);
|
||||||
} else {
|
} else {
|
||||||
log_debug("%s: cmd=%s, cwd=%s", __func__, cmd,
|
log_debug("%s: cmd=%s, cwd=%s, shell=%s", __func__, cmd,
|
||||||
cwd == NULL ? "" : cwd);
|
cwd == NULL ? "" : cwd, shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pid) {
|
switch (pid) {
|
||||||
@ -150,7 +160,8 @@ job_run(const char *cmd, int argc, char **argv, struct environ *e, struct sessio
|
|||||||
closefrom(STDERR_FILENO + 1);
|
closefrom(STDERR_FILENO + 1);
|
||||||
|
|
||||||
if (cmd != NULL) {
|
if (cmd != NULL) {
|
||||||
execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);
|
setenv("SHELL", shell, 1);
|
||||||
|
execl(shell, argv0, "-c", cmd, (char *)NULL);
|
||||||
fatal("execl failed");
|
fatal("execl failed");
|
||||||
} else {
|
} else {
|
||||||
argvp = cmd_copy_argv(argc, argv);
|
argvp = cmd_copy_argv(argc, argv);
|
||||||
@ -161,6 +172,7 @@ job_run(const char *cmd, int argc, char **argv, struct environ *e, struct sessio
|
|||||||
|
|
||||||
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||||
environ_free(env);
|
environ_free(env);
|
||||||
|
free(argv0);
|
||||||
|
|
||||||
job = xmalloc(sizeof *job);
|
job = xmalloc(sizeof *job);
|
||||||
job->state = JOB_RUNNING;
|
job->state = JOB_RUNNING;
|
||||||
@ -194,12 +206,13 @@ job_run(const char *cmd, int argc, char **argv, struct environ *e, struct sessio
|
|||||||
fatalx("out of memory");
|
fatalx("out of memory");
|
||||||
bufferevent_enable(job->event, EV_READ|EV_WRITE);
|
bufferevent_enable(job->event, EV_READ|EV_WRITE);
|
||||||
|
|
||||||
log_debug("run job %p: %s, pid %ld", job, job->cmd, (long) job->pid);
|
log_debug("run job %p: %s, pid %ld", job, job->cmd, (long)job->pid);
|
||||||
return (job);
|
return (job);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||||
environ_free(env);
|
environ_free(env);
|
||||||
|
free(argv0);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
tmux.c
18
tmux.c
@ -235,6 +235,24 @@ fail:
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
shell_argv0(const char *shell, int is_login)
|
||||||
|
{
|
||||||
|
const char *slash, *name;
|
||||||
|
char *argv0;
|
||||||
|
|
||||||
|
slash = strrchr(shell, '/');
|
||||||
|
if (slash != NULL && slash[1] != '\0')
|
||||||
|
name = slash + 1;
|
||||||
|
else
|
||||||
|
name = shell;
|
||||||
|
if (is_login)
|
||||||
|
xasprintf(&argv0, "-%s", name);
|
||||||
|
else
|
||||||
|
xasprintf(&argv0, "%s", name);
|
||||||
|
return (argv0);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setblocking(int fd, int state)
|
setblocking(int fd, int state)
|
||||||
{
|
{
|
||||||
|
1
tmux.h
1
tmux.h
@ -2096,6 +2096,7 @@ extern int ptm_fd;
|
|||||||
extern const char *shell_command;
|
extern const char *shell_command;
|
||||||
int checkshell(const char *);
|
int checkshell(const char *);
|
||||||
void setblocking(int, int);
|
void setblocking(int, int);
|
||||||
|
char *shell_argv0(const char *, int);
|
||||||
uint64_t get_timer(void);
|
uint64_t get_timer(void);
|
||||||
const char *sig2name(int);
|
const char *sig2name(int);
|
||||||
const char *find_cwd(void);
|
const char *find_cwd(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user