diff options
Diffstat (limited to 'osdep-darwin.c')
-rw-r--r-- | osdep-darwin.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/osdep-darwin.c b/osdep-darwin.c index 653b52fe..5f768cbb 100644 --- a/osdep-darwin.c +++ b/osdep-darwin.c @@ -1,4 +1,4 @@ -/* $Id: osdep-darwin.c,v 1.1 2009-01-20 22:17:53 nicm Exp $ */ +/* $Id: osdep-darwin.c,v 1.2 2009-01-26 22:57:19 nicm Exp $ */ /* * Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org> @@ -23,7 +23,7 @@ #include <stdlib.h> -char *get_argv0(pid_t); +char *get_argv0(int, char *); /* * XXX This actually returns the executable path, not the process's argv[0]. @@ -32,13 +32,15 @@ char *get_argv0(pid_t); */ char * -get_argv0(pid_t pgrp) +get_argv0(int fd, __attribute__ ((unused)) char *tty) { int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, 0 }; size_t size; struct kinfo_proc kp; - mib[3] = pgrp; + if ((mib[3] = tcgetpgrp(fd)) == -1) + return (NULL) + size = sizeof kp; if (sysctl(mib, 4, &kp, &size, NULL, 0) == -1 || kp.kp_proc.p_comm[0] == '\0') |