summaryrefslogtreecommitdiffstats
path: root/osdep-linux.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-01-26 22:57:20 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-01-26 22:57:20 +0000
commit9cde0c24779e8f43b6d122bc62fa22b6022d9ef0 (patch)
tree833af8a6751da50421ae9db66ae10e2e6a05823c /osdep-linux.c
parent4d7e555a48a6fb0732565b24482d24e968f49eae (diff)
Be more clever about picking window name.
Diffstat (limited to 'osdep-linux.c')
-rw-r--r--osdep-linux.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/osdep-linux.c b/osdep-linux.c
index b2a68459..986b8d8e 100644
--- a/osdep-linux.c
+++ b/osdep-linux.c
@@ -1,4 +1,4 @@
-/* $Id: osdep-linux.c,v 1.1 2009-01-20 19:35:03 nicm Exp $ */
+/* $Id: osdep-linux.c,v 1.2 2009-01-26 22:57:19 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -27,16 +27,23 @@
#include "tmux.h"
char *
-get_argv0(pid_t pgrp)
+get_argv0(int fd, unused char *tty)
{
FILE *f;
char *path, *buf;
size_t len;
int ch;
+ pid_t pgrp;
+
+ if ((pgrp = tcgetpgrp(fd)) == -1)
+ return (NULL);
xasprintf(&path, "/proc/%lld/cmdline", (long long) pgrp);
- if ((f = fopen(path, "r")) == NULL)
+ if ((f = fopen(path, "r")) == NULL) {
+ xfree(path);
return (NULL);
+ }
+ xfree(path);
len = 0;
buf = NULL;