summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-06-14 10:07:45 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-06-14 10:07:45 +0000
commite5b1cbc810288bfa82a138879eb273d32c20f8b8 (patch)
treef235b0593477bde5bc890a5a5ef1d817e9bcb8dc /usr.bin
parentf497f8d1baf7ae1a9a80d67911135c4ef2a2aa08 (diff)
Add a format for client PID (client_pid) and server PID (pid). Diff for
client_pid from Thomas Adam.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/client.c10
-rw-r--r--usr.bin/tmux/format.c4
-rw-r--r--usr.bin/tmux/server-client.c8
-rw-r--r--usr.bin/tmux/tmux.16
-rw-r--r--usr.bin/tmux/tmux.h4
5 files changed, 24 insertions, 8 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c
index 46daf511ae4..fd76960eb09 100644
--- a/usr.bin/tmux/client.c
+++ b/usr.bin/tmux/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.89 2015/06/04 23:27:51 nicm Exp $ */
+/* $OpenBSD: client.c,v 1.90 2015/06/14 10:07:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -348,9 +348,10 @@ client_main(int argc, char **argv, int flags)
void
client_send_identify(int flags)
{
- const char *s;
+ const char *s;
char **ss;
- int fd;
+ int fd;
+ pid_t pid;
client_write_one(MSG_IDENTIFY_FLAGS, -1, &flags, sizeof flags);
@@ -370,6 +371,9 @@ client_send_identify(int flags)
fatal("dup failed");
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++)
client_write_one(MSG_IDENTIFY_ENVIRON, -1, *ss, strlen(*ss) + 1);
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index aea5f31ae9f..ee6a5c53874 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.71 2015/06/10 12:56:04 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.72 2015/06/14 10:07:44 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -271,6 +271,7 @@ format_create_status(int status)
*ptr = '\0';
format_add(ft, "host_short", "%s", host);
}
+ format_add(ft, "pid", "%ld", (long) getpid());
return (ft);
}
@@ -703,6 +704,7 @@ format_defaults_client(struct format_tree *ft, struct client *c)
if (ft->s == NULL)
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_width", "%u", c->tty.sx);
if (c->tty.path != NULL)
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index b1e136fdce3..a4961243b75 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.142 2015/06/05 18:06:30 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.143 2015/06/14 10:07:44 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1044,6 +1044,7 @@ server_client_msg_dispatch(struct client *c)
case MSG_IDENTIFY_CWD:
case MSG_IDENTIFY_STDIN:
case MSG_IDENTIFY_ENVIRON:
+ case MSG_IDENTIFY_CLIENTPID:
case MSG_IDENTIFY_DONE:
server_client_msg_identify(c, &imsg);
break;
@@ -1218,6 +1219,11 @@ server_client_msg_identify(struct client *c, struct imsg *imsg)
if (strchr(data, '=') != NULL)
environ_put(&c->environ, data);
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:
break;
}
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index b4bdec18cbd..8e9c903b797 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.436 2015/06/07 21:39:39 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.437 2015/06/14 10:07:44 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 7 2015 $
+.Dd $Mdocdate: June 14 2015 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -3353,6 +3353,7 @@ The following variables are available, where appropriate:
.It Li "client_created_string" Ta "" Ta "String time client created"
.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_pid" Ta "" Ta "PID of client process"
.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_session" Ta "" Ta "Name of the client's session"
@@ -3396,6 +3397,7 @@ The following variables are available, where appropriate:
.It Li "pane_top" Ta "" Ta "Top of pane"
.It Li "pane_tty" Ta "" Ta "Pseudo terminal 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_upper" Ta "" Ta "Top of scroll region in pane"
.It Li "session_alerts" Ta "" Ta "List of window indexes with alerts"
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 7bb362c03da..a99b38e4b1b 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.522 2015/06/07 21:39:39 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.523 2015/06/14 10:07:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -425,6 +425,7 @@ enum msgtype {
MSG_IDENTIFY_STDIN,
MSG_IDENTIFY_ENVIRON,
MSG_IDENTIFY_DONE,
+ MSG_IDENTIFY_CLIENTPID,
MSG_COMMAND = 200,
MSG_DETACH,
@@ -1206,6 +1207,7 @@ RB_HEAD(status_out_tree, status_out);
struct client {
struct imsgbuf ibuf;
+ pid_t pid;
int fd;
struct event event;
int retval;