version 1.16, 2016/10/10 21:29:23 |
version 1.17, 2020/04/08 11:26:07 |
|
|
|
|
static struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *); |
static struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *); |
char *get_proc_name(int, char *); |
char *get_proc_name(int, char *); |
|
char *get_proc_cwd(int); |
|
|
static struct kinfo_proc * |
static struct kinfo_proc * |
cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2) |
cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2) |
|
|
error: |
error: |
free(buf); |
free(buf); |
return (NULL); |
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); |
} |
} |