summaryrefslogtreecommitdiffstats
path: root/osdep-linux.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-02-13 00:43:04 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-02-13 00:43:04 +0000
commitcce03e138b6363036d9b6c3c96925b3a372e421b (patch)
tree0a35dd6ae5cc69dc77423576d203f9b24a59b147 /osdep-linux.c
parentb1e911aff02d8381018fca067e7783c6a72da593 (diff)
Looking up argv[0] is expensive, so just use p_comm for the window name which is good enough. Also increase name update time to 500 ms.
Diffstat (limited to 'osdep-linux.c')
-rw-r--r--osdep-linux.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/osdep-linux.c b/osdep-linux.c
index 079b562d..ccc176d9 100644
--- a/osdep-linux.c
+++ b/osdep-linux.c
@@ -1,4 +1,4 @@
-/* $Id: osdep-linux.c,v 1.4 2009-02-09 18:08:01 nicm Exp $ */
+/* $Id: osdep-linux.c,v 1.5 2009-02-13 00:43:04 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -26,8 +26,8 @@
#include "tmux.h"
-int
-osdep_get_name(int fd, unused char *tty, unused pid_t *last_pid, char **name)
+char *
+osdep_get_name(int fd, unused char *tty)
{
FILE *f;
char *path, *buf;
@@ -35,15 +35,13 @@ osdep_get_name(int fd, unused char *tty, unused pid_t *last_pid, char **name)
int ch;
pid_t pgrp;
- *name = NULL;
-
if ((pgrp = tcgetpgrp(fd)) == -1)
- return (-1);
+ return (NULL);
xasprintf(&path, "/proc/%lld/cmdline", (long long) pgrp);
if ((f = fopen(path, "r")) == NULL) {
xfree(path);
- return (-1);
+ return (NULL);
}
xfree(path);
@@ -57,10 +55,9 @@ osdep_get_name(int fd, unused char *tty, unused pid_t *last_pid, char **name)
}
if (buf != NULL)
buf[len] = '\0';
- *name = buf;
fclose(f);
- return (0);
+ return (buf);
}
#endif