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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5725 in the body.
You can then email your comments to 5725 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5725; Package emacs. (Mon, 15 Mar 2010 17:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 15 Mar 2010 17:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

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 1 (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 3 (text/plain, inline)]
Leo

Added tag(s) patch. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 22 Mar 2010 21:32:02 GMT) Full text and rfc822 format available.

Severity set to 'wishlist' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 22 Mar 2010 21:32:02 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5725; Package emacs. (Sat, 03 Apr 2010 08:38:01 GMT) Full text and rfc822 format available.

Message #12 received at 5725 <at> debbugs.gnu.org (full text, mbox):

From: Eduard Wiebe <usenet <at> pusto.de>
To: Leo <sdl.web <at> gmail.com>
Cc: 5725 <at> debbugs.gnu.org
Subject: Re: bug#5725: 23.1.94;
	list_system_processes for BSD_SYSTEM (with patch)
Date: Sat, 03 Apr 2010 10:37:36 +0200
The following message is a courtesy copy of an article
that has been posted to gmane.emacs.bugs as well.

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

 Hi Leo,
 
> 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.

I've already done this and send it several weeks ago (bug#5243). Can you
test this patch on other BSD (!= FreeBSD) machine(s)?

-- 
Eduard Wiebe




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5725; Package emacs. (Sat, 03 Apr 2010 09:01:02 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5725; Package emacs. (Sat, 03 Apr 2010 13:43:01 GMT) Full text and rfc822 format available.

Message #18 received at 5725 <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: Eduard Wiebe <usenet <at> pusto.de>
Cc: 5725 <at> debbugs.gnu.org
Subject: Re: bug#5725: 23.1.94;
	list_system_processes for BSD_SYSTEM (with patch)
Date: Sat, 03 Apr 2010 14:42:29 +0100
On 2010-04-03 09:37 +0100, Eduard Wiebe wrote:
> The following message is a courtesy copy of an article
> that has been posted to gmane.emacs.bugs as well.
>
> Leo <sdl.web <at> gmail.com> writes:
>
>  Hi Leo,
>  
>> 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.
>
> I've already done this and send it several weeks ago (bug#5243). Can you
> test this patch on other BSD (!= FreeBSD) machine(s)?

Thank you. I will test this on OSX later on. I wished I had seen your
patch earlier before creating it myself.

Leo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5725; Package emacs. (Sat, 03 Apr 2010 15:58:01 GMT) Full text and rfc822 format available.

Message #21 received at 5725 <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: Eduard Wiebe <usenet <at> pusto.de>
Cc: 5725 <at> debbugs.gnu.org
Subject: Re: bug#5725: 23.1.94;
	list_system_processes for BSD_SYSTEM (with patch)
Date: Sat, 03 Apr 2010 16:57:01 +0100
[Message part 1 (text/plain, inline)]
On 2010-04-03 09:37 +0100, Eduard Wiebe wrote:
> Leo <sdl.web <at> gmail.com> writes:
>
>  Hi Leo,

Hello Eduard,

>
>> 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.
>
> I've already done this and send it several weeks ago (bug#5243). Can you
> test this patch on other BSD (!= FreeBSD) machine(s)?

I guess things have diverged on these BSD systems. Your patch can't
compile on Darwin (log attached). I wonder if you and YAMAMOTO Mitsuh
can make the patch in #5243 work on Darwin too.

My implementation of process_attributes involves using libproc.h which
is declared as private interface. I am thinking of changing it to use
mach/task_info.h but I haven't got around to do it.

[bsd.log (text/x-log, attachment)]
[Message part 3 (text/plain, inline)]
Thanks,

Leo

Forcibly Merged 5243 5725. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 03 Apr 2010 19:25:02 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5725; Package emacs. (Sun, 04 Apr 2010 17:16:02 GMT) Full text and rfc822 format available.

Message #26 received at 5725 <at> debbugs.gnu.org (full text, mbox):

From: Eduard Wiebe <usenet <at> pusto.de>
To: Leo <sdl.web <at> gmail.com>
Cc: 5725 <at> debbugs.gnu.org
Subject: Re: bug#5725: 23.1.94;
	list_system_processes for BSD_SYSTEM (with patch)
Date: Sun, 04 Apr 2010 19:15:21 +0200
Leo <sdl.web <at> gmail.com> writes:

>>> 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.
>>
>> I've already done this and send it several weeks ago (bug#5243). Can you
>> test this patch on other BSD (!= FreeBSD) machine(s)?
>
> I guess things have diverged on these BSD systems. 
> Your patch can't compile on Darwin (log attached). 

Too sad!

> I wonder if you and YAMAMOTO Mitsuh can make the patch in #5243 work
> on Darwin too.

Probably, you're right. 

> My implementation of process_attributes involves using libproc.h which
> is declared as private interface. I am thinking of changing it to use
> mach/task_info.h but I haven't got around to do it.

Sorry, but here i'm giving up.

-- 
Eduard Wiebe





bug closed, send any further explanations to 5243 <at> debbugs.gnu.org and Eduard Wiebe <usenet <at> pusto.de> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 21 Apr 2012 10:15:03 GMT) Full text and rfc822 format available.

Disconnected #5725 from all other report(s). Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 21 Apr 2012 10:18:02 GMT) Full text and rfc822 format available.

Did not alter fixed versions and reopened. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 21 Apr 2012 10:18:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5725; Package emacs. (Sat, 21 Apr 2012 10:26:01 GMT) Full text and rfc822 format available.

Message #35 received at 5725 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 5725 <at> debbugs.gnu.org
Subject: Re: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
Date: Sat, 21 Apr 2012 18:24:48 +0800
Hi Leo,

[Disconnecting Bug#5725 from Bug#5243]

I committed Eduard Wiebe's patch in Bug#5243 to trunk.  If his
implementation of system_process_attributes does not compile on Darwin,
and you have a separate one that works, could you add yours under a
different #elif?

Also, if the list_system_processes part works on Darwin, the relevant
#elif, from his patch, should be changed to BSD_SYSTEM; please check
that if you can, and amend as necessary.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5725; Package emacs. (Sat, 21 Apr 2012 15:30:04 GMT) Full text and rfc822 format available.

Message #38 received at 5725 <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: Chong Yidong <cyd <at> gnu.org>
Cc: 5725 <at> debbugs.gnu.org
Subject: Re: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
Date: Sat, 21 Apr 2012 23:29:09 +0800
On 2012-04-21 18:24 +0800, Chong Yidong wrote:
> [Disconnecting Bug#5725 from Bug#5243]
>
> I committed Eduard Wiebe's patch in Bug#5243 to trunk.  If his
> implementation of system_process_attributes does not compile on Darwin,
> and you have a separate one that works, could you add yours under a
> different #elif?
>
> Also, if the list_system_processes part works on Darwin, the relevant
> #elif, from his patch, should be changed to BSD_SYSTEM; please check
> that if you can, and amend as necessary.
>
> Thanks.

The difference is small. Are you happy with this change? I have tested
it in Snow Leopard 10.6.8.

=== modified file 'src/sysdep.c'
--- src/sysdep.c	2012-04-21 10:11:51 +0000
+++ src/sysdep.c	2012-04-21 15:25:18 +0000
@@ -44,6 +44,10 @@
 #include <math.h>
 #endif
 
+#ifdef DARWIN_OS
+#include <sys/sysctl.h>
+#endif
+
 #ifdef WINDOWSNT
 #define read sys_read
 #define write sys_write
@@ -2536,7 +2540,11 @@
   return proclist;
 }
 
-#elif defined (__FreeBSD__)
+#elif defined (BSD_SYSTEM)
+
+#ifdef DARWIN_OS
+#define KERN_PROC_PROC KERN_PROC_ALL
+#endif
 
 Lisp_Object
 list_system_processes ()
@@ -2562,7 +2570,13 @@
   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);





Reply sent to Leo <sdl.web <at> gmail.com>:
You have taken responsibility. (Sun, 22 Apr 2012 03:07:02 GMT) Full text and rfc822 format available.

Notification sent to Leo <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Sun, 22 Apr 2012 03:07:02 GMT) Full text and rfc822 format available.

Message #43 received at 5725-done <at> debbugs.gnu.org (full text, mbox):

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5725; Package emacs. (Sun, 22 Apr 2012 05:54:02 GMT) Full text and rfc822 format available.

Message #46 received at 5725 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 5725 <at> debbugs.gnu.org
Subject: Re: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
Date: Sun, 22 Apr 2012 13:52:13 +0800
Leo <sdl.web <at> gmail.com> writes:

> The difference is small. Are you happy with this change? I have tested
> it in Snow Leopard 10.6.8.

Looks fine to me.  Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 20 May 2012 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 354 days ago.

Previous Next


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