diff options
Diffstat (limited to 'osdep-linux.c')
-rw-r--r-- | osdep-linux.c | 13 |
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; |