emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#5725: closed (23.1.94; list_system_processes for B


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#5725: closed (23.1.94; list_system_processes for BSD_SYSTEM (with patch))
Date: Sun, 22 Apr 2012 03:07:02 +0000

Your message dated Sun, 22 Apr 2012 11:05:10 +0800
with message-id <address@hidden>
and subject line Re: bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM 
(with patch)
has caused the debbugs.gnu.org bug report #5725,
regarding 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
5725: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5725
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 23.1.94; list_system_processes for BSD_SYSTEM (with patch) Date: Mon, 15 Mar 2010 17:01:10 +0000
The included patch implements list_system_processes through sysctl.h
which I guess is available on all BSD systems. I have also implemented
process_attributes and will send it in after more testing.

diff --git a/src/sysdep.c b/src/sysdep.c
index 2f79a71..5cefc75 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -3200,6 +3200,45 @@ list_system_processes ()
   return proclist;
 }
 
+#elif defined (BSD_SYSTEM)
+#include <sys/sysctl.h>
+
+Lisp_Object
+list_system_processes ()
+{
+  struct gcpro        gcpro1;
+  Lisp_Object         proclist = Qnil;
+  struct kinfo_proc * procinfo;
+  const int name[4]            = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0};
+  size_t              length;
+  int                 err;
+  int                 i;
+  EMACS_INT           pid;
+
+  GCPRO1 (proclist);
+  err = sysctl((int *)name, 4, NULL, &length, NULL, 0);
+  if (err == 0 && length > 0)
+    {
+      procinfo = malloc (length);
+      if (procinfo != NULL)
+        {
+          err = sysctl((int *)name, 4, procinfo, &length, NULL, 0);
+          if (err == 0 && length > 0)
+            {
+              for (i=0; i < (length/sizeof(*procinfo)); i++)
+                {
+                  pid = procinfo[i].kp_proc.p_pid;
+                  proclist = Fcons (make_fixnum_or_float(pid), proclist);
+                }
+            }
+          free(procinfo);
+        }
+    }
+  UNGCPRO;
+
+  return proclist;
+}
+
 /* The WINDOWSNT implementation is in w32.c.
    The MSDOS implementation is in dosfns.c.  */
 #elif !defined (WINDOWSNT) && !defined (MSDOS)
Leo

--- End Message ---
--- Begin Message --- Subject: Re: bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM (with patch) Date: Sun, 22 Apr 2012 11:05:10 +0800 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.95 (Mac OS X 10.6.8)
I pushed the commit as in revno 107988 after successfully testing it in
Snow Leopard with emacs built with X11. Thanks.

Leo


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]