mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-27 10:33:09 +01:00
Merge branch 'obsd-master'
This commit is contained in:
commit
a3bce7a322
@ -93,6 +93,24 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
|
|||||||
session_set_current(s, wl);
|
session_set_current(s, wl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cflag != NULL) {
|
||||||
|
ft = format_create();
|
||||||
|
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s,
|
||||||
|
NULL, NULL);
|
||||||
|
cp = format_expand(ft, cflag);
|
||||||
|
format_free(ft);
|
||||||
|
|
||||||
|
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
||||||
|
free(cp);
|
||||||
|
if (fd == -1) {
|
||||||
|
cmdq_error(cmdq, "bad working directory: %s",
|
||||||
|
strerror(errno));
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
close(s->cwd);
|
||||||
|
s->cwd = fd;
|
||||||
|
}
|
||||||
|
|
||||||
if (c->session != NULL) {
|
if (c->session != NULL) {
|
||||||
if (dflag) {
|
if (dflag) {
|
||||||
/*
|
/*
|
||||||
@ -108,24 +126,6 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cflag != NULL) {
|
|
||||||
ft = format_create();
|
|
||||||
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s,
|
|
||||||
NULL, NULL);
|
|
||||||
cp = format_expand(ft, cflag);
|
|
||||||
format_free(ft);
|
|
||||||
|
|
||||||
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
|
||||||
free(cp);
|
|
||||||
if (fd == -1) {
|
|
||||||
cmdq_error(cmdq, "bad working directory: %s",
|
|
||||||
strerror(errno));
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
close(s->cwd);
|
|
||||||
s->cwd = fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Eflag) {
|
if (!Eflag) {
|
||||||
update = options_get_string(&s->options,
|
update = options_get_string(&s->options,
|
||||||
"update-environment");
|
"update-environment");
|
||||||
@ -146,24 +146,6 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cflag != NULL) {
|
|
||||||
ft = format_create();
|
|
||||||
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s,
|
|
||||||
NULL, NULL);
|
|
||||||
cp = format_expand(ft, cflag);
|
|
||||||
format_free(ft);
|
|
||||||
|
|
||||||
fd = open(cp, O_RDONLY|O_DIRECTORY);
|
|
||||||
free(cp);
|
|
||||||
if (fd == -1) {
|
|
||||||
cmdq_error(cmdq, "bad working directory: %s",
|
|
||||||
strerror(errno));
|
|
||||||
return (CMD_RETURN_ERROR);
|
|
||||||
}
|
|
||||||
close(s->cwd);
|
|
||||||
s->cwd = fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rflag)
|
if (rflag)
|
||||||
c->flags |= CLIENT_READONLY;
|
c->flags |= CLIENT_READONLY;
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ cmd_if_shell_callback(struct job *job)
|
|||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
char *cause, *cmd;
|
char *cause, *cmd;
|
||||||
|
|
||||||
if (cmdq->dead)
|
if (cmdq->flags & CMD_Q_DEAD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0)
|
if (!WIFEXITED(job->status) || WEXITSTATUS(job->status) != 0)
|
||||||
|
@ -41,16 +41,16 @@ enum cmd_retval
|
|||||||
cmd_kill_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_kill_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s, *s2, *s3;
|
struct session *s, *sloop, *stmp;
|
||||||
|
|
||||||
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
RB_FOREACH_SAFE(s2, sessions, &sessions, s3) {
|
RB_FOREACH_SAFE(sloop, sessions, &sessions, stmp) {
|
||||||
if (s != s2) {
|
if (sloop != s) {
|
||||||
server_destroy_session(s2);
|
server_destroy_session(sloop);
|
||||||
session_destroy(s2);
|
session_destroy(sloop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@ -30,10 +29,10 @@
|
|||||||
enum cmd_retval cmd_list_panes_exec(struct cmd *, struct cmd_q *);
|
enum cmd_retval cmd_list_panes_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
void cmd_list_panes_server(struct cmd *, struct cmd_q *);
|
void cmd_list_panes_server(struct cmd *, struct cmd_q *);
|
||||||
void cmd_list_panes_session(
|
void cmd_list_panes_session(struct cmd *, struct session *, struct cmd_q *,
|
||||||
struct cmd *, struct session *, struct cmd_q *, int);
|
int);
|
||||||
void cmd_list_panes_window(struct cmd *,
|
void cmd_list_panes_window(struct cmd *, struct session *, struct winlink *,
|
||||||
struct session *, struct winlink *, struct cmd_q *, int);
|
struct cmd_q *, int);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_panes_entry = {
|
const struct cmd_entry cmd_list_panes_entry = {
|
||||||
"list-panes", "lsp",
|
"list-panes", "lsp",
|
||||||
@ -77,8 +76,8 @@ cmd_list_panes_server(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_list_panes_session(
|
cmd_list_panes_session(struct cmd *self, struct session *s, struct cmd_q *cmdq,
|
||||||
struct cmd *self, struct session *s, struct cmd_q *cmdq, int type)
|
int type)
|
||||||
{
|
{
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
|
||||||
@ -87,8 +86,8 @@ cmd_list_panes_session(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_list_panes_window(struct cmd *self,
|
cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
|
||||||
struct session *s, struct winlink *wl, struct cmd_q *cmdq, int type)
|
struct cmd_q *cmdq, int type)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
@ -115,9 +114,9 @@ cmd_list_panes_window(struct cmd *self,
|
|||||||
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
template = "#{session_name}:#{window_index}.#{pane_index}: "
|
template = "#{session_name}:#{window_index}."
|
||||||
"[#{pane_width}x#{pane_height}] [history "
|
"#{pane_index}: [#{pane_width}x#{pane_height}] "
|
||||||
"#{history_size}/#{history_limit}, "
|
"[history #{history_size}/#{history_limit}, "
|
||||||
"#{history_bytes} bytes] #{pane_id}"
|
"#{history_bytes} bytes] #{pane_id}"
|
||||||
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
"#{?pane_active, (active),}#{?pane_dead, (dead),}";
|
||||||
break;
|
break;
|
||||||
|
13
cmd-queue.c
13
cmd-queue.c
@ -35,7 +35,7 @@ cmdq_new(struct client *c)
|
|||||||
|
|
||||||
cmdq = xcalloc(1, sizeof *cmdq);
|
cmdq = xcalloc(1, sizeof *cmdq);
|
||||||
cmdq->references = 1;
|
cmdq->references = 1;
|
||||||
cmdq->dead = 0;
|
cmdq->flags = 0;
|
||||||
|
|
||||||
cmdq->client = c;
|
cmdq->client = c;
|
||||||
cmdq->client_exit = -1;
|
cmdq->client_exit = -1;
|
||||||
@ -51,8 +51,11 @@ cmdq_new(struct client *c)
|
|||||||
int
|
int
|
||||||
cmdq_free(struct cmd_q *cmdq)
|
cmdq_free(struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
if (--cmdq->references != 0)
|
if (--cmdq->references != 0) {
|
||||||
return (cmdq->dead);
|
if (cmdq->flags & CMD_Q_DEAD)
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
cmdq_flush(cmdq);
|
cmdq_flush(cmdq);
|
||||||
free(cmdq);
|
free(cmdq);
|
||||||
@ -192,6 +195,7 @@ cmdq_continue_one(struct cmd_q *cmdq)
|
|||||||
int
|
int
|
||||||
cmdq_continue(struct cmd_q *cmdq)
|
cmdq_continue(struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
|
struct client *c = cmdq->client;
|
||||||
struct cmd_q_item *next;
|
struct cmd_q_item *next;
|
||||||
enum cmd_retval retval;
|
enum cmd_retval retval;
|
||||||
int empty;
|
int empty;
|
||||||
@ -199,6 +203,9 @@ cmdq_continue(struct cmd_q *cmdq)
|
|||||||
cmdq->references++;
|
cmdq->references++;
|
||||||
notify_disable();
|
notify_disable();
|
||||||
|
|
||||||
|
log_debug("continuing cmdq %p: flags=%#x, client=%d", cmdq, cmdq->flags,
|
||||||
|
c != NULL ? c->ibuf.fd : -1);
|
||||||
|
|
||||||
empty = TAILQ_EMPTY(&cmdq->queue);
|
empty = TAILQ_EMPTY(&cmdq->queue);
|
||||||
if (empty)
|
if (empty)
|
||||||
goto empty;
|
goto empty;
|
||||||
|
@ -131,7 +131,7 @@ cmd_run_shell_callback(struct job *job)
|
|||||||
int retcode;
|
int retcode;
|
||||||
u_int lines;
|
u_int lines;
|
||||||
|
|
||||||
if (cmdq->dead)
|
if (cmdq->flags & CMD_Q_DEAD)
|
||||||
return;
|
return;
|
||||||
cmd = cdata->cmd;
|
cmd = cdata->cmd;
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ server_client_lost(struct client *c)
|
|||||||
free(c->prompt_string);
|
free(c->prompt_string);
|
||||||
free(c->prompt_buffer);
|
free(c->prompt_buffer);
|
||||||
|
|
||||||
c->cmdq->dead = 1;
|
c->cmdq->flags |= CMD_Q_DEAD;
|
||||||
cmdq_free(c->cmdq);
|
cmdq_free(c->cmdq);
|
||||||
c->cmdq = NULL;
|
c->cmdq = NULL;
|
||||||
|
|
||||||
|
3
tmux.h
3
tmux.h
@ -1306,7 +1306,8 @@ TAILQ_HEAD(cmd_q_items, cmd_q_item);
|
|||||||
/* Command queue. */
|
/* Command queue. */
|
||||||
struct cmd_q {
|
struct cmd_q {
|
||||||
int references;
|
int references;
|
||||||
int dead;
|
int flags;
|
||||||
|
#define CMD_Q_DEAD 0x1
|
||||||
|
|
||||||
struct client *client;
|
struct client *client;
|
||||||
int client_exit;
|
int client_exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user