mirror of https://github.com/tmux/tmux.git
Merge branch 'obsd-master'
This commit is contained in:
commit
9fd9952752
|
@ -129,7 +129,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
memcpy(&cdata->mouse, &shared->mouse, sizeof cdata->mouse);
|
memcpy(&cdata->mouse, &shared->mouse, sizeof cdata->mouse);
|
||||||
|
|
||||||
job_run(shellcmd, s, cwd, NULL, cmd_if_shell_callback,
|
job_run(shellcmd, s, cwd, NULL, cmd_if_shell_callback,
|
||||||
cmd_if_shell_free, cdata);
|
cmd_if_shell_free, cdata, 0);
|
||||||
free(shellcmd);
|
free(shellcmd);
|
||||||
|
|
||||||
if (args_has(args, 'b'))
|
if (args_has(args, 'b'))
|
||||||
|
|
|
@ -111,7 +111,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
cdata->item = item;
|
cdata->item = item;
|
||||||
|
|
||||||
job_run(cdata->cmd, s, cwd, NULL, cmd_run_shell_callback,
|
job_run(cdata->cmd, s, cwd, NULL, cmd_run_shell_callback,
|
||||||
cmd_run_shell_free, cdata);
|
cmd_run_shell_free, cdata, 0);
|
||||||
|
|
||||||
if (args_has(args, 'b'))
|
if (args_has(args, 'b'))
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
2
format.c
2
format.c
|
@ -295,7 +295,7 @@ format_job_get(struct format_tree *ft, const char *cmd)
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
if (fj->job == NULL && (force || fj->last != t)) {
|
if (fj->job == NULL && (force || fj->last != t)) {
|
||||||
fj->job = job_run(expanded, NULL, NULL, format_job_update,
|
fj->job = job_run(expanded, NULL, NULL, format_job_update,
|
||||||
format_job_complete, NULL, fj);
|
format_job_complete, NULL, fj, JOB_NOWAIT);
|
||||||
if (fj->job == NULL) {
|
if (fj->job == NULL) {
|
||||||
free(fj->out);
|
free(fj->out);
|
||||||
xasprintf(&fj->out, "<'%s' didn't start>", fj->cmd);
|
xasprintf(&fj->out, "<'%s' didn't start>", fj->cmd);
|
||||||
|
|
3
job.c
3
job.c
|
@ -43,7 +43,7 @@ struct joblist all_jobs = LIST_HEAD_INITIALIZER(all_jobs);
|
||||||
struct job *
|
struct job *
|
||||||
job_run(const char *cmd, struct session *s, const char *cwd,
|
job_run(const char *cmd, struct session *s, const char *cwd,
|
||||||
job_update_cb updatecb, job_complete_cb completecb, job_free_cb freecb,
|
job_update_cb updatecb, job_complete_cb completecb, job_free_cb freecb,
|
||||||
void *data)
|
void *data, int flags)
|
||||||
{
|
{
|
||||||
struct job *job;
|
struct job *job;
|
||||||
struct environ *env;
|
struct environ *env;
|
||||||
|
@ -110,6 +110,7 @@ job_run(const char *cmd, struct session *s, const char *cwd,
|
||||||
|
|
||||||
job = xmalloc(sizeof *job);
|
job = xmalloc(sizeof *job);
|
||||||
job->state = JOB_RUNNING;
|
job->state = JOB_RUNNING;
|
||||||
|
job->flags = flags;
|
||||||
|
|
||||||
job->cmd = xstrdup(cmd);
|
job->cmd = xstrdup(cmd);
|
||||||
job->pid = pid;
|
job->pid = pid;
|
||||||
|
|
|
@ -1289,6 +1289,8 @@ server_client_check_exit(struct client *c)
|
||||||
if (EVBUFFER_LENGTH(c->stderr_data) != 0)
|
if (EVBUFFER_LENGTH(c->stderr_data) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (c->flags & CLIENT_ATTACHED)
|
||||||
|
notify_client("client-detached", c);
|
||||||
proc_send(c->peer, MSG_EXIT, -1, &c->retval, sizeof c->retval);
|
proc_send(c->peer, MSG_EXIT, -1, &c->retval, sizeof c->retval);
|
||||||
c->flags &= ~CLIENT_EXIT;
|
c->flags &= ~CLIENT_EXIT;
|
||||||
}
|
}
|
||||||
|
|
11
server.c
11
server.c
|
@ -243,6 +243,7 @@ server_loop(void)
|
||||||
{
|
{
|
||||||
struct client *c;
|
struct client *c;
|
||||||
u_int items;
|
u_int items;
|
||||||
|
struct job *job;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
items = cmdq_next(NULL);
|
items = cmdq_next(NULL);
|
||||||
|
@ -275,6 +276,11 @@ server_loop(void)
|
||||||
if (!TAILQ_EMPTY(&clients))
|
if (!TAILQ_EMPTY(&clients))
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
LIST_FOREACH(job, &all_jobs, entry) {
|
||||||
|
if ((~job->flags & JOB_NOWAIT) && job->state == JOB_RUNNING)
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,8 +296,11 @@ server_send_exit(void)
|
||||||
TAILQ_FOREACH_SAFE(c, &clients, entry, c1) {
|
TAILQ_FOREACH_SAFE(c, &clients, entry, c1) {
|
||||||
if (c->flags & CLIENT_SUSPENDED)
|
if (c->flags & CLIENT_SUSPENDED)
|
||||||
server_client_lost(c);
|
server_client_lost(c);
|
||||||
else
|
else {
|
||||||
|
if (c->flags & CLIENT_ATTACHED)
|
||||||
|
notify_client("client-detached", c);
|
||||||
proc_send(c->peer, MSG_SHUTDOWN, -1, NULL, 0);
|
proc_send(c->peer, MSG_SHUTDOWN, -1, NULL, 0);
|
||||||
|
}
|
||||||
c->session = NULL;
|
c->session = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
tmux.h
5
tmux.h
|
@ -626,6 +626,9 @@ struct job {
|
||||||
JOB_CLOSED
|
JOB_CLOSED
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
|
int flags;
|
||||||
|
#define JOB_NOWAIT 0x1
|
||||||
|
|
||||||
char *cmd;
|
char *cmd;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
|
@ -1653,7 +1656,7 @@ extern const struct options_table_entry options_table[];
|
||||||
/* job.c */
|
/* job.c */
|
||||||
extern struct joblist all_jobs;
|
extern struct joblist all_jobs;
|
||||||
struct job *job_run(const char *, struct session *, const char *,
|
struct job *job_run(const char *, struct session *, const char *,
|
||||||
job_update_cb, job_complete_cb, job_free_cb, void *);
|
job_update_cb, job_complete_cb, job_free_cb, void *, int);
|
||||||
void job_free(struct job *);
|
void job_free(struct job *);
|
||||||
void job_died(struct job *, int);
|
void job_died(struct job *, int);
|
||||||
|
|
||||||
|
|
|
@ -1677,7 +1677,7 @@ window_copy_copy_pipe(struct window_pane *wp, struct session *s,
|
||||||
return;
|
return;
|
||||||
expanded = format_single(NULL, arg, NULL, s, NULL, wp);
|
expanded = format_single(NULL, arg, NULL, s, NULL, wp);
|
||||||
|
|
||||||
job = job_run(expanded, s, NULL, NULL, NULL, NULL, NULL);
|
job = job_run(expanded, s, NULL, NULL, NULL, NULL, NULL, JOB_NOWAIT);
|
||||||
bufferevent_write(job->event, buf, len);
|
bufferevent_write(job->event, buf, len);
|
||||||
|
|
||||||
free(expanded);
|
free(expanded);
|
||||||
|
|
Loading…
Reference in New Issue