unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
@ 2010-03-15 17:01 Leo
  2010-04-03  8:37 ` Eduard Wiebe
  2012-04-21 10:24 ` Chong Yidong
  0 siblings, 2 replies; 9+ messages in thread
From: Leo @ 2010-03-15 17:01 UTC (permalink / raw)
  To: 5725

[-- Attachment #1: Type: text/plain, Size: 200 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: lsp.diff --]
[-- Type: text/x-patch, Size: 1357 bytes --]

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)

[-- Attachment #3: Type: text/plain, Size: 5 bytes --]


Leo

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-22  5:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-15 17:01 bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM (with patch) Leo
2010-04-03  8:37 ` Eduard Wiebe
2010-04-03 13:42   ` Leo
2010-04-03 15:57   ` Leo
2010-04-04 17:15     ` Eduard Wiebe
2012-04-21 10:24 ` Chong Yidong
2012-04-21 15:29   ` Leo
2012-04-22  5:52     ` Chong Yidong
2012-04-22  3:05   ` Leo

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).