GNU bug report logs - #5725
23.1.94; list_system_processes for BSD_SYSTEM (with patch)

Previous Next

Package: emacs;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Mon, 15 Mar 2010 17:02:02 UTC

Severity: wishlist

Tags: patch

Done: Leo <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Leo <sdl.web <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#5725: closed (23.1.94; list_system_processes for BSD_SYSTEM
 (with patch))
Date: Sun, 22 Apr 2012 03:07:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sun, 22 Apr 2012 11:05:10 +0800
with message-id <m1k4184gbd.fsf <at> gmail.com>
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
help-debbugs <at> gnu.org.)


-- 
5725: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5725
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
Date: Mon, 15 Mar 2010 17:01:10 +0000
[Message part 3 (text/plain, inline)]
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.

[lsp.diff (text/x-patch, inline)]
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)
[Message part 5 (text/plain, inline)]
Leo
[Message part 6 (message/rfc822, inline)]
From: Leo <sdl.web <at> gmail.com>
To: Chong Yidong <cyd <at> gnu.org>
Cc: 5725-done <at> debbugs.gnu.org
Subject: Re: bug#5725: 23.1.94;
	list_system_processes for BSD_SYSTEM (with patch)
Date: Sun, 22 Apr 2012 11:05:10 +0800
I pushed the commit as in revno 107988 after successfully testing it in
Snow Leopard with emacs built with X11. Thanks.

Leo


This bug report was last modified 13 years and 37 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.