Be more clever about picking window name.

This commit is contained in:
Nicholas Marriott
2009-01-26 22:57:20 +00:00
parent 4d7e555a48
commit 9cde0c2477
8 changed files with 173 additions and 36 deletions

View File

@ -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')