yet more KERN_PROC shit.
It's not complicated, just some time I would rather use doing important stuff, like testing pkg_add...
This commit is contained in:
parent
3596e2db24
commit
3803247c2b
@ -1,6 +1,6 @@
|
||||
$OpenBSD: patch-kcontrol_kfontinst_kfontinst_GetPid_c,v 1.2 2007/05/25 09:49:54 espie Exp $
|
||||
$OpenBSD: patch-kcontrol_kfontinst_kfontinst_GetPid_c,v 1.3 2010/01/17 09:18:57 espie Exp $
|
||||
--- kcontrol/kfontinst/kfontinst/GetPid.c.orig Mon May 14 09:55:38 2007
|
||||
+++ kcontrol/kfontinst/kfontinst/GetPid.c Mon May 14 19:06:23 2007
|
||||
+++ kcontrol/kfontinst/kfontinst/GetPid.c Sun Jan 17 10:17:19 2010
|
||||
@@ -55,6 +55,7 @@
|
||||
Linux Tested on Linux 2.4
|
||||
FreeBSD Tested on FreeBSD 5.1 by Brian Ledbetter <brian@shadowcom.net>
|
||||
@ -18,3 +18,55 @@ $OpenBSD: patch-kcontrol_kfontinst_kfontinst_GetPid_c,v 1.2 2007/05/25 09:49:54
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
@@ -181,29 +182,29 @@ unsigned int kfi_getPid(const char *proc, unsigned int
|
||||
int mib[4];
|
||||
size_t len,
|
||||
num;
|
||||
- struct kinfo_proc *p;
|
||||
+ struct kinfo_proc2 *p;
|
||||
|
||||
mib[0] = CTL_KERN;
|
||||
- mib[1] = KERN_PROC;
|
||||
+ mib[1] = KERN_PROC2;
|
||||
mib[2] = KERN_PROC_ALL;
|
||||
sysctl(mib, 3, NULL, &len, NULL, 0);
|
||||
- p=(struct kinfo_proc*)malloc(len);
|
||||
+ p=(struct kinfo_proc2*)malloc(len);
|
||||
sysctl(mib, 3, p, &len, NULL, 0);
|
||||
|
||||
- for(num=0; num < len / sizeof(struct kinfo_proc) && !error; num++)
|
||||
+ for(num=0; num < len / sizeof(struct kinfo_proc2) && !error; num++)
|
||||
{
|
||||
- struct kinfo_proc proc_p;
|
||||
+ struct kinfo_proc2 proc_p;
|
||||
size_t len;
|
||||
|
||||
mib[0] = CTL_KERN;
|
||||
- mib[1] = KERN_PROC;
|
||||
+ mib[1] = KERN_PROC2;
|
||||
mib[2] = KERN_PROC_PID;
|
||||
#if __FreeBSD_version >= 500015
|
||||
mib[3] = p[num].ki_pid;
|
||||
#elif defined(__DragonFly__) && __DragonFly_version >= 190000
|
||||
mib[3] = p[num].kp_pid;
|
||||
#else
|
||||
- mib[3] = p[num].kp_proc.p_pid;
|
||||
+ mib[3] = p[num].p_pid;
|
||||
#endif
|
||||
|
||||
len=sizeof(proc_p);
|
||||
@@ -227,12 +228,12 @@ unsigned int kfi_getPid(const char *proc, unsigned int
|
||||
#if defined(__DragonFly__)
|
||||
if(proc_p.kp_eproc.e_ppid==ppid && p[num].kp_thread.td_comm && 0==strcmp(p[num].kp_thread.td_comm, proc))
|
||||
#else
|
||||
- if(proc_p.kp_eproc.e_ppid==ppid && p[num].kp_proc.p_comm && 0==strcmp(p[num].kp_proc.p_comm, proc))
|
||||
+ if(proc_p.p_ppid==ppid && p[num].p_comm && 0==strcmp(p[num].p_comm, proc))
|
||||
#endif
|
||||
if(pid)
|
||||
error=true;
|
||||
else
|
||||
- pid=p[num].kp_proc.p_pid;
|
||||
+ pid=p[num].p_pid;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user