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

* bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
  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
  2012-04-21 10:24 ` Chong Yidong
  1 sibling, 2 replies; 9+ messages in thread
From: Eduard Wiebe @ 2010-04-03  8:37 UTC (permalink / raw)
  To: Leo; +Cc: 5725

The following message is a courtesy copy of an article
that has been posted to gmane.emacs.bugs as well.

Leo <sdl.web@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






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

* bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
  2010-04-03  8:37 ` Eduard Wiebe
@ 2010-04-03 13:42   ` Leo
  2010-04-03 15:57   ` Leo
  1 sibling, 0 replies; 9+ messages in thread
From: Leo @ 2010-04-03 13:42 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 5725

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@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






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

* bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
  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
  1 sibling, 1 reply; 9+ messages in thread
From: Leo @ 2010-04-03 15:57 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 5725

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

On 2010-04-03 09:37 +0100, Eduard Wiebe wrote:
> Leo <sdl.web@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.


[-- Attachment #2: bsd.log --]
[-- Type: text/x-log, Size: 7668 bytes --]

sysdep.c: In function ‘list_system_processes’:
sysdep.c:3236: error: ‘struct kinfo_proc’ has no member named ‘ki_pid’
sysdep.c:3236: error: ‘struct kinfo_proc’ has no member named ‘ki_pid’
sysdep.c:3236: error: ‘struct kinfo_proc’ has no member named ‘ki_pid’
sysdep.c:3236: error: ‘struct kinfo_proc’ has no member named ‘ki_pid’
sysdep.c:3236: error: ‘struct kinfo_proc’ has no member named ‘ki_pid’
sysdep.c: In function ‘system_process_attributes’:
sysdep.c:3820: error: ‘struct kinfo_proc’ has no member named ‘ki_uid’
sysdep.c:3820: error: ‘struct kinfo_proc’ has no member named ‘ki_uid’
sysdep.c:3820: error: ‘struct kinfo_proc’ has no member named ‘ki_uid’
sysdep.c:3820: error: ‘struct kinfo_proc’ has no member named ‘ki_uid’
sysdep.c:3820: error: ‘struct kinfo_proc’ has no member named ‘ki_uid’
sysdep.c:3823: error: ‘struct kinfo_proc’ has no member named ‘ki_uid’
sysdep.c:3828: error: ‘struct kinfo_proc’ has no member named ‘ki_svgid’
sysdep.c:3828: error: ‘struct kinfo_proc’ has no member named ‘ki_svgid’
sysdep.c:3828: error: ‘struct kinfo_proc’ has no member named ‘ki_svgid’
sysdep.c:3828: error: ‘struct kinfo_proc’ has no member named ‘ki_svgid’
sysdep.c:3828: error: ‘struct kinfo_proc’ has no member named ‘ki_svgid’
sysdep.c:3831: error: ‘struct kinfo_proc’ has no member named ‘ki_svgid’
sysdep.c:3837: error: ‘struct kinfo_proc’ has no member named ‘ki_comm’
sysdep.c:3837: error: ‘struct kinfo_proc’ has no member named ‘ki_comm’
sysdep.c:3843: error: ‘struct kinfo_proc’ has no member named ‘ki_stat’
sysdep.c:3853: error: ‘SLOCK’ undeclared (first use in this function)
sysdep.c:3853: error: (Each undeclared identifier is reported only once
sysdep.c:3853: error: for each function it appears in.)
sysdep.c:3868: error: ‘struct kinfo_proc’ has no member named ‘ki_ppid’
sysdep.c:3868: error: ‘struct kinfo_proc’ has no member named ‘ki_ppid’
sysdep.c:3868: error: ‘struct kinfo_proc’ has no member named ‘ki_ppid’
sysdep.c:3868: error: ‘struct kinfo_proc’ has no member named ‘ki_ppid’
sysdep.c:3868: error: ‘struct kinfo_proc’ has no member named ‘ki_ppid’
sysdep.c:3869: error: ‘struct kinfo_proc’ has no member named ‘ki_pgid’
sysdep.c:3869: error: ‘struct kinfo_proc’ has no member named ‘ki_pgid’
sysdep.c:3869: error: ‘struct kinfo_proc’ has no member named ‘ki_pgid’
sysdep.c:3869: error: ‘struct kinfo_proc’ has no member named ‘ki_pgid’
sysdep.c:3869: error: ‘struct kinfo_proc’ has no member named ‘ki_pgid’
sysdep.c:3870: error: ‘struct kinfo_proc’ has no member named ‘ki_sid’
sysdep.c:3870: error: ‘struct kinfo_proc’ has no member named ‘ki_sid’
sysdep.c:3870: error: ‘struct kinfo_proc’ has no member named ‘ki_sid’
sysdep.c:3870: error: ‘struct kinfo_proc’ has no member named ‘ki_sid’
sysdep.c:3870: error: ‘struct kinfo_proc’ has no member named ‘ki_sid’
sysdep.c:3873: error: ‘struct kinfo_proc’ has no member named ‘ki_tdev’
sysdep.c:3873: error: ‘struct kinfo_proc’ has no member named ‘ki_tdev’
sysdep.c:3878: error: ‘struct kinfo_proc’ has no member named ‘ki_tpgid’
sysdep.c:3878: error: ‘struct kinfo_proc’ has no member named ‘ki_tpgid’
sysdep.c:3878: error: ‘struct kinfo_proc’ has no member named ‘ki_tpgid’
sysdep.c:3878: error: ‘struct kinfo_proc’ has no member named ‘ki_tpgid’
sysdep.c:3878: error: ‘struct kinfo_proc’ has no member named ‘ki_tpgid’
sysdep.c:3879: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3879: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3879: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3879: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3879: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3880: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3880: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3880: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3880: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3880: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3881: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3882: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3889: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3889: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3889: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3890: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3890: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3890: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3891: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3891: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3891: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3891: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage’
sysdep.c:3894: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3894: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3894: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3895: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3895: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3895: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3896: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3896: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3896: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3896: error: ‘struct kinfo_proc’ has no member named ‘ki_rusage_ch’
sysdep.c:3899: error: ‘struct kinfo_proc’ has no member named ‘ki_numthreads’
sysdep.c:3899: error: ‘struct kinfo_proc’ has no member named ‘ki_numthreads’
sysdep.c:3899: error: ‘struct kinfo_proc’ has no member named ‘ki_numthreads’
sysdep.c:3899: error: ‘struct kinfo_proc’ has no member named ‘ki_numthreads’
sysdep.c:3899: error: ‘struct kinfo_proc’ has no member named ‘ki_numthreads’
sysdep.c:3900: error: ‘struct kinfo_proc’ has no member named ‘ki_pri’
sysdep.c:3901: error: ‘struct kinfo_proc’ has no member named ‘ki_nice’
sysdep.c:3902: error: ‘struct kinfo_proc’ has no member named ‘ki_start’
sysdep.c:3902: error: ‘struct kinfo_proc’ has no member named ‘ki_start’
sysdep.c:3902: error: ‘struct kinfo_proc’ has no member named ‘ki_start’
sysdep.c:3903: error: ‘struct kinfo_proc’ has no member named ‘ki_size’
sysdep.c:3904: error: ‘struct kinfo_proc’ has no member named ‘ki_rssize’
sysdep.c:3907: error: ‘struct kinfo_proc’ has no member named ‘ki_start’
sysdep.c:3907: error: ‘struct kinfo_proc’ has no member named ‘ki_start’
sysdep.c:3920: error: ‘struct kinfo_proc’ has no member named ‘ki_pctcpu’
sysdep.c:3921: error: ‘struct kinfo_proc’ has no member named ‘ki_swtime’
sysdep.c:3929: error: ‘struct kinfo_proc’ has no member named ‘ki_flag’
sysdep.c:3930: error: ‘struct kinfo_proc’ has no member named ‘ki_rssize’
sysdep.c:3935: error: ‘KERN_PROC_ARGS’ undeclared (first use in this function)
make[1]: *** [sysdep.o] Error 1
make: *** [src] Error 2

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


Thanks,

Leo

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

* bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
  2010-04-03 15:57   ` Leo
@ 2010-04-04 17:15     ` Eduard Wiebe
  0 siblings, 0 replies; 9+ messages in thread
From: Eduard Wiebe @ 2010-04-04 17:15 UTC (permalink / raw)
  To: Leo; +Cc: 5725

Leo <sdl.web@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







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

* bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
  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
@ 2012-04-21 10:24 ` Chong Yidong
  2012-04-21 15:29   ` Leo
  2012-04-22  3:05   ` Leo
  1 sibling, 2 replies; 9+ messages in thread
From: Chong Yidong @ 2012-04-21 10:24 UTC (permalink / raw)
  To: Leo; +Cc: 5725

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.





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

* bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
  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
  1 sibling, 1 reply; 9+ messages in thread
From: Leo @ 2012-04-21 15:29 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 5725

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);






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

* bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
  2012-04-21 10:24 ` Chong Yidong
  2012-04-21 15:29   ` Leo
@ 2012-04-22  3:05   ` Leo
  1 sibling, 0 replies; 9+ messages in thread
From: Leo @ 2012-04-22  3:05 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 5725-done

I pushed the commit as in revno 107988 after successfully testing it in
Snow Leopard with emacs built with X11. Thanks.

Leo





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

* bug#5725: 23.1.94; list_system_processes for BSD_SYSTEM (with patch)
  2012-04-21 15:29   ` Leo
@ 2012-04-22  5:52     ` Chong Yidong
  0 siblings, 0 replies; 9+ messages in thread
From: Chong Yidong @ 2012-04-22  5:52 UTC (permalink / raw)
  To: Leo; +Cc: 5725

Leo <sdl.web@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.





^ permalink raw reply	[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).