Commit f01769f9 authored by Leo Liu's avatar Leo Liu
Browse files

* src/sysdep.c (list_system_processes): Support Darwin.

Fixes: debbugs:5725
parent 5790543d
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> 2012-04-22 Paul Eggert <eggert@cs.ucla.edu>
* sysdep.c [__FreeBSD__]: Minor cleanups. * sysdep.c [__FreeBSD__]: Minor cleanups.
......
...@@ -44,6 +44,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -44,6 +44,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <math.h> #include <math.h>
#endif #endif
#ifdef DARWIN_OS
#include <sys/sysctl.h>
#endif
#ifdef WINDOWSNT #ifdef WINDOWSNT
#define read sys_read #define read sys_read
#define write sys_write #define write sys_write
...@@ -2536,12 +2540,16 @@ list_system_processes (void) ...@@ -2536,12 +2540,16 @@ list_system_processes (void)
return proclist; return proclist;
} }
#elif defined __FreeBSD__ #elif defined BSD_SYSTEM
Lisp_Object Lisp_Object
list_system_processes (void) 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}; int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PROC};
#endif
size_t len; size_t len;
struct kinfo_proc *procs; struct kinfo_proc *procs;
size_t i; size_t i;
...@@ -2562,7 +2570,13 @@ list_system_processes (void) ...@@ -2562,7 +2570,13 @@ list_system_processes (void)
GCPRO1 (proclist); GCPRO1 (proclist);
len /= sizeof (struct kinfo_proc); len /= sizeof (struct kinfo_proc);
for (i = 0; i < len; i++) 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; UNGCPRO;
xfree (procs); xfree (procs);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment