+2012-04-22 Leo Liu <sdl.web@gmail.com>
+
+ * sysdep.c (list_system_processes): Support Darwin (Bug#5725).
+
2012-04-22 Paul Eggert <eggert@cs.ucla.edu>
* sysdep.c [__FreeBSD__]: Minor cleanups.
#include <math.h>
#endif
+#ifdef DARWIN_OS
+#include <sys/sysctl.h>
+#endif
+
#ifdef WINDOWSNT
#define read sys_read
#define write sys_write
return proclist;
}
-#elif defined __FreeBSD__
+#elif defined BSD_SYSTEM
Lisp_Object
list_system_processes (void)
{
+#ifdef DARWIN_OS
+ int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
+#else
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PROC};
+#endif
size_t len;
struct kinfo_proc *procs;
size_t i;
GCPRO1 (proclist);
len /= sizeof (struct kinfo_proc);
for (i = 0; i < len; i++)
- proclist = Fcons (make_fixnum_or_float (procs[i].ki_pid), proclist);
+ {
+#ifdef DARWIN_OS
+ proclist = Fcons (make_fixnum_or_float (procs[i].kp_proc.p_pid), proclist);
+#else
+ proclist = Fcons (make_fixnum_or_float (procs[i].ki_pid), proclist);
+#endif
+ }
UNGCPRO;
xfree (procs);