mirror of
https://github.com/tmux/tmux.git
synced 2025-09-01 20:57:00 +00:00
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.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user