=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/procname.c,v retrieving revision 1.16 retrieving revision 1.17 diff -c -r1.16 -r1.17 *** src/usr.bin/tmux/procname.c 2016/10/10 21:29:23 1.16 --- src/usr.bin/tmux/procname.c 2020/04/08 11:26:07 1.17 *************** *** 1,4 **** ! /* $OpenBSD: procname.c,v 1.16 2016/10/10 21:29:23 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: procname.c,v 1.17 2020/04/08 11:26:07 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 38,43 **** --- 38,44 ---- static struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *); char *get_proc_name(int, char *); + char *get_proc_cwd(int); static struct kinfo_proc * cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2) *************** *** 131,134 **** --- 132,149 ---- error: free(buf); return (NULL); + } + + char * + get_proc_cwd(int fd) + { + int name[] = { CTL_KERN, KERN_PROC_CWD, 0 }; + static char path[MAXPATHLEN]; + size_t pathlen = sizeof path; + + if ((name[2] = tcgetpgrp(fd)) == -1) + return (NULL); + if (sysctl(name, 3, path, &pathlen, NULL, 0) != 0) + return (NULL); + return (path); }