Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2015-06-14 12:01:10 +01:00
commit 37005d04a9
5 changed files with 18 additions and 2 deletions

View File

@ -352,9 +352,10 @@ client_main(int argc, char **argv, int flags)
void void
client_send_identify(int flags) client_send_identify(int flags)
{ {
const char *s; const char *s;
char **ss; char **ss;
int fd; int fd;
pid_t pid;
client_write_one(MSG_IDENTIFY_FLAGS, -1, &flags, sizeof flags); client_write_one(MSG_IDENTIFY_FLAGS, -1, &flags, sizeof flags);
@ -374,6 +375,9 @@ client_send_identify(int flags)
fatal("dup failed"); fatal("dup failed");
client_write_one(MSG_IDENTIFY_STDIN, fd, NULL, 0); client_write_one(MSG_IDENTIFY_STDIN, fd, NULL, 0);
pid = getpid();
client_write_one(MSG_IDENTIFY_CLIENTPID, -1, &pid, sizeof pid);
for (ss = environ; *ss != NULL; ss++) for (ss = environ; *ss != NULL; ss++)
client_write_one(MSG_IDENTIFY_ENVIRON, -1, *ss, strlen(*ss) + 1); client_write_one(MSG_IDENTIFY_ENVIRON, -1, *ss, strlen(*ss) + 1);

View File

@ -272,6 +272,7 @@ format_create_status(int status)
*ptr = '\0'; *ptr = '\0';
format_add(ft, "host_short", "%s", host); format_add(ft, "host_short", "%s", host);
} }
format_add(ft, "pid", "%ld", (long) getpid());
return (ft); return (ft);
} }
@ -704,6 +705,7 @@ format_defaults_client(struct format_tree *ft, struct client *c)
if (ft->s == NULL) if (ft->s == NULL)
ft->s = c->session; ft->s = c->session;
format_add(ft, "client_pid", "%ld", (long) c->pid);
format_add(ft, "client_height", "%u", c->tty.sy); format_add(ft, "client_height", "%u", c->tty.sy);
format_add(ft, "client_width", "%u", c->tty.sx); format_add(ft, "client_width", "%u", c->tty.sx);
if (c->tty.path != NULL) if (c->tty.path != NULL)

View File

@ -1053,6 +1053,7 @@ server_client_msg_dispatch(struct client *c)
case MSG_IDENTIFY_CWD: case MSG_IDENTIFY_CWD:
case MSG_IDENTIFY_STDIN: case MSG_IDENTIFY_STDIN:
case MSG_IDENTIFY_ENVIRON: case MSG_IDENTIFY_ENVIRON:
case MSG_IDENTIFY_CLIENTPID:
case MSG_IDENTIFY_DONE: case MSG_IDENTIFY_DONE:
server_client_msg_identify(c, &imsg); server_client_msg_identify(c, &imsg);
break; break;
@ -1227,6 +1228,11 @@ server_client_msg_identify(struct client *c, struct imsg *imsg)
if (strchr(data, '=') != NULL) if (strchr(data, '=') != NULL)
environ_put(&c->environ, data); environ_put(&c->environ, data);
break; break;
case MSG_IDENTIFY_CLIENTPID:
if (datalen != sizeof c->pid)
fatalx("bad MSG_IDENTIFY_CLIENTPID size");
memcpy(&c->pid, data, sizeof c->pid);
break;
default: default:
break; break;
} }

2
tmux.1
View File

@ -3357,6 +3357,7 @@ The following variables are available, where appropriate:
.It Li "client_created_string" Ta "" Ta "String time client created" .It Li "client_created_string" Ta "" Ta "String time client created"
.It Li "client_height" Ta "" Ta "Height of client" .It Li "client_height" Ta "" Ta "Height of client"
.It Li "client_last_session" Ta "" Ta "Name of the client's last session" .It Li "client_last_session" Ta "" Ta "Name of the client's last session"
.It Li "client_pid" Ta "" Ta "PID of client process"
.It Li "client_prefix" Ta "" Ta "1 if prefix key has been pressed" .It Li "client_prefix" Ta "" Ta "1 if prefix key has been pressed"
.It Li "client_readonly" Ta "" Ta "1 if client is readonly" .It Li "client_readonly" Ta "" Ta "1 if client is readonly"
.It Li "client_session" Ta "" Ta "Name of the client's session" .It Li "client_session" Ta "" Ta "Name of the client's session"
@ -3401,6 +3402,7 @@ The following variables are available, where appropriate:
.It Li "pane_top" Ta "" Ta "Top of pane" .It Li "pane_top" Ta "" Ta "Top of pane"
.It Li "pane_tty" Ta "" Ta "Pseudo terminal of pane" .It Li "pane_tty" Ta "" Ta "Pseudo terminal of pane"
.It Li "pane_width" Ta "" Ta "Width of pane" .It Li "pane_width" Ta "" Ta "Width of pane"
.It Li "pid" Ta "" Ta "Server PID"
.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane" .It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane"
.It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane" .It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
.It Li "session_alerts" Ta "" Ta "List of window indexes with alerts" .It Li "session_alerts" Ta "" Ta "List of window indexes with alerts"

2
tmux.h
View File

@ -429,6 +429,7 @@ enum msgtype {
MSG_IDENTIFY_STDIN, MSG_IDENTIFY_STDIN,
MSG_IDENTIFY_ENVIRON, MSG_IDENTIFY_ENVIRON,
MSG_IDENTIFY_DONE, MSG_IDENTIFY_DONE,
MSG_IDENTIFY_CLIENTPID,
MSG_COMMAND = 200, MSG_COMMAND = 200,
MSG_DETACH, MSG_DETACH,
@ -1210,6 +1211,7 @@ RB_HEAD(status_out_tree, status_out);
struct client { struct client {
struct imsgbuf ibuf; struct imsgbuf ibuf;
pid_t pid;
int fd; int fd;
struct event event; struct event event;
int retval; int retval;