summaryrefslogtreecommitdiffstats
path: root/osdep-darwin.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-darwin.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-darwin.c')
-rw-r--r--osdep-darwin.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/osdep-darwin.c b/osdep-darwin.c
index a2622abe..ae90a512 100644
--- a/osdep-darwin.c
+++ b/osdep-darwin.c
@@ -1,4 +1,4 @@
-/* $Id: osdep-darwin.c,v 1.8 2009-02-11 19:35:50 nicm Exp $ */
+/* $Id: osdep-darwin.c,v 1.9 2009-02-13 00:43:04 nicm Exp $ */
/*
* Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
@@ -25,36 +25,27 @@
#include <string.h>
#include <unistd.h>
-int osdep_get_name(int, char *, pid_t *, char **);
+char *osdep_get_name(int, char *);
#define unused __attribute__ ((unused))
-/*
- * XXX This actually returns the executable path, not the process's argv[0].
- * Anyone who wishes to complain about this is welcome to grab a copy of
- * Apple's 'ps' source and start digging.
- */
-
-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)
{
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, 0 };
size_t size;
struct kinfo_proc kp;
- *name = NULL;
-
if ((mib[3] = tcgetpgrp(fd)) == -1)
- return (-1);
+ return (NULL);
size = sizeof kp;
if (sysctl(mib, 4, &kp, &size, NULL, 0) == -1)
- return (-1);
+ return (NULL);
if (*kp.kp_proc.p_comm == '\0')
- return (-1);
+ return (NULL);
- *name = strdup(kp.kp_proc.p_comm);
- return (0);
+ return (strdup(kp.kp_proc.p_comm));
}
#endif