diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-10-10 12:29:36 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-10-10 12:29:36 +0000 |
commit | 9b4858ef43fdde58fb93678191a500528a661fcb (patch) | |
tree | 1f1f476593d0cb0e46c1554a059b4f4d7a5f884d | |
parent | 65217d74cd8ea37b9ffd3fdd20459efeba0967bf (diff) |
We accidentally haven't been using $TMUX to work out the session for a
while and in fact it is less useful that using the client ttyname. So
don't bother and don't pass it from the client. If we need it in future
it is in c->environ.
-rw-r--r-- | usr.bin/tmux/client.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/cmd.c | 10 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.c | 32 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 9 |
5 files changed, 15 insertions, 46 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c index 2887f4bb122..966626af31e 100644 --- a/usr.bin/tmux/client.c +++ b/usr.bin/tmux/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.73 2013/10/10 12:28:08 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.74 2013/10/10 12:29:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -280,10 +280,6 @@ client_main(int argc, char **argv, int flags) size += strlen(argv[i]) + 1; data = xmalloc((sizeof *data) + size); - /* Fill in command line arguments. */ - data->pid = environ_pid; - data->session_id = environ_session_id; - /* Prepare command for server. */ data->argc = argc; if (cmd_pack_argv(argc, argv, (char*)(data + 1), size) != 0) { diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c index 323605fc020..026c5e584c2 100644 --- a/usr.bin/tmux/cmd.c +++ b/usr.bin/tmux/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.88 2013/10/10 12:28:56 nicm Exp $ */ +/* $OpenBSD: cmd.c,v 1.89 2013/10/10 12:29:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -314,7 +314,6 @@ cmd_print(struct cmd *cmd, char *buf, size_t len) struct session * cmd_current_session(struct cmd_q *cmdq, int prefer_unattached) { - struct msg_command_data *data = cmdq->msgdata; struct client *c = cmdq->client; struct session *s; struct sessionslist ss; @@ -356,13 +355,6 @@ cmd_current_session(struct cmd_q *cmdq, int prefer_unattached) return (s); } - /* Use the session from the TMUX environment variable. */ - if (data != NULL && data->pid == getpid() && data->session_id != -1) { - s = session_find_by_id(data->session_id); - if (s != NULL) - return (s); - } - return (cmd_choose_session(prefer_unattached)); } diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 00d6e9903b9..10eb95e0579 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.110 2013/10/10 12:27:38 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.111 2013/10/10 12:29:35 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -62,6 +62,8 @@ server_client_create(int fd) fatal("gettimeofday failed"); memcpy(&c->activity_time, &c->creation_time, sizeof c->activity_time); + environ_init(&c->environ); + c->cmdq = cmdq_new(c); c->cmdq->client_exit = 1; diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index bfb5eaa7b2e..23aab622f1e 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.125 2013/10/10 12:26:36 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.126 2013/10/10 12:29:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -49,11 +49,8 @@ time_t start_time; char socket_path[MAXPATHLEN]; int login_shell; char *environ_path; -pid_t environ_pid = -1; -int environ_session_id = -1; __dead void usage(void); -void parseenvironment(void); char *makesocketpath(const char *); __dead void @@ -124,23 +121,6 @@ areshell(const char *shell) return (0); } -void -parseenvironment(void) -{ - char *env, path[256]; - long pid; - int id; - - if ((env = getenv("TMUX")) == NULL) - return; - - if (sscanf(env, "%255[^,],%ld,%d", path, &pid, &id) != 3) - return; - environ_path = xstrdup(path); - environ_pid = pid; - environ_session_id = id; -} - char * makesocketpath(const char *label) { @@ -223,7 +203,9 @@ main(int argc, char **argv) { struct passwd *pw; char *s, *path, *label, *home, **var, tmp[MAXPATHLEN]; - int opt, flags, quiet, keys; + char in[256]; + long long pid; + int opt, flags, quiet, keys, session; #ifdef DEBUG malloc_options = (char *) "AFGJPX"; @@ -351,11 +333,15 @@ main(int argc, char **argv) } } + /* Get path from environment. */ + s = getenv("TMUX"); + if (s != NULL && sscanf(s, "%255[^,],%lld,%d", in, &pid, &session) == 3) + environ_path = xstrdup(in); + /* * Figure out the socket path. If specified on the command-line with -S * or -L, use it, otherwise try $TMUX or assume -L default. */ - parseenvironment(); if (path == NULL) { /* If no -L, use the environment. */ if (label == NULL) { diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index ee144c1f62d..4fd3b9e94f8 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.428 2013/10/10 12:26:36 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.429 2013/10/10 12:29:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -464,9 +464,6 @@ enum msgtype { * Don't forget to bump PROTOCOL_VERSION if any of these change! */ struct msg_command_data { - pid_t pid; /* from $TMUX or -1 */ - int session_id; /* from $TMUX or -1 */ - int argc; }; /* followed by packed argv */ @@ -1408,8 +1405,6 @@ struct cmd_q { void (*emptyfn)(struct cmd_q *); void *data; - struct msg_command_data *msgdata; - TAILQ_ENTRY(cmd_q) waitentry; }; @@ -1503,8 +1498,6 @@ extern time_t start_time; extern char socket_path[MAXPATHLEN]; extern int login_shell; extern char *environ_path; -extern pid_t environ_pid; -extern int environ_session_id; void logfile(const char *); const char *getshell(void); int checkshell(const char *); |