From: jca+emacs@wxcvbn.org (Jérémie Courrèges-Anglas)
To: Glenn Morris <rgm@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: emacs-24.2.93 build problems (on OpenBSD)
Date: Tue, 05 Mar 2013 15:52:16 +0100 [thread overview]
Message-ID: <87k3plgaqn.fsf@moo.wxcvbn.org> (raw)
In-Reply-To: 87obeyeykk.fsf@moo.wxcvbn.org
[-- Attachment #1.1: Type: text/plain, Size: 854 bytes --]
jca+emacs@wxcvbn.org (Jérémie Courrèges-Anglas) writes:
> Glenn Morris <rgm@gnu.org> writes:
>
>> Jérémie Courrèges-Anglas wrote:
>>
>>> I have no idea whether it is correct, but M-: (list-system-processes)
>>> returns nil here on OpenBSD-current (5.3).
>>
>> Too late to make it work for 24.3, but could you make a bug report about
>> this please?
By the way, I don't have the time to make a bugreport right now, but
here's the diff (against 24.2.93) I would submit (after I have time to
test it thoroughly).
People with an access to OpenBSD and / or MirOS boxes (any version),
please test with diff.
This takes the #ifdef dance out of the function, doesn't hardcode the
mib size and uses the correct mib for (somewhat) recent OpenBSD versions.
list-system-processes doesn't return nil any more (OpenBSD 5.3 -current).
[-- Attachment #1.2: patch-sysdep.c --]
[-- Type: application/octet-stream, Size: 2601 bytes --]
--- sysdep.c.orig Tue Mar 5 15:09:25 2013
+++ sysdep.c Tue Mar 5 15:09:30 2013
@@ -2649,42 +2649,61 @@
#elif defined BSD_SYSTEM
+/* Sysctl-based access to the list of processes. */
+
+/* Compatibility macros */
+#if defined __OpenBSD__
+# if defined KERN_PROC && KERN_PROC == 14 /* Old API */
+# define MIB_INITIALIZER {CTL_KERN, KERN_PROC, KERN_PROC_ALL}
+# define PID_FROM_KINFO_PROC(k) (k).kp_proc.p_pid
+# else /* New API */
+# if !defined KERN_PROC
+# define KERN_PROC KERN_PROC2
+# define kinfo_proc kinfo_proc2
+# endif
+# define MIB_INITIALIZER \
+ {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0, sizeof (struct kinfo_proc), 4096}
+# define PID_FROM_KINFO_PROC(k) (k).p_pid
+# endif
+/* Darwin, NetBSD, OSX, ... */
+#elif defined DARWIN_OS || defined __NetBSD__
+# define MIB_INITIALIZER {CTL_KERN, KERN_PROC, KERN_PROC_ALL}
+# define PID_FROM_KINFO_PROC(k) (k).kp_proc.p_pid
+#else
+/* FreeBSD, DragonFlyBSD, ... */
+# define MIB_INITIALIZER {CTL_KERN, KERN_PROC, KERN_PROC_PROC}
+# define PID_FROM_KINFO_PROC(k) (k).ki_pid
+#endif
+
Lisp_Object
list_system_processes (void)
{
-#if defined DARWIN_OS || defined __NetBSD__ || defined __OpenBSD__
- int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
-#else
- int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PROC};
-#endif
- size_t len;
+ int mib[] = MIB_INITIALIZER;
+ size_t len, mibsize = sizeof mib / sizeof mib[0];
struct kinfo_proc *procs;
size_t i;
+ FILE *f;
struct gcpro gcpro1;
Lisp_Object proclist = Qnil;
- if (sysctl (mib, 3, NULL, &len, NULL, 0) != 0)
+ if (sysctl (mib, mibsize, NULL, &len, NULL, 0) != 0)
return proclist;
procs = xmalloc (len);
- if (sysctl (mib, 3, procs, &len, NULL, 0) != 0)
+ if (sysctl (mib, mibsize, procs, &len, NULL, 0) != 0)
{
xfree (procs);
return proclist;
}
-
+
GCPRO1 (proclist);
- len /= sizeof (struct kinfo_proc);
+ len /= sizeof procs[0];
for (i = 0; i < len; i++)
{
-#if defined DARWIN_OS || defined __NetBSD__
- proclist = Fcons (make_fixnum_or_float (procs[i].kp_proc.p_pid), proclist);
-#elif defined __OpenBSD__
- proclist = Fcons (make_fixnum_or_float (procs[i].p_pid), proclist);
-#else
- proclist = Fcons (make_fixnum_or_float (procs[i].ki_pid), proclist);
-#endif
+ proclist =
+ Fcons (make_fixnum_or_float (PID_FROM_KINFO_PROC (procs[i])),
+ proclist);
}
UNGCPRO;
@@ -2692,6 +2711,9 @@
return proclist;
}
+
+#undef MIB_INITIALIZER
+#undef PID_FROM_KINFO_PROC
/* The WINDOWSNT implementation is in w32.c.
The MSDOS implementation is in dosfns.c. */
[-- Attachment #2: Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2013-03-05 14:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-02 23:00 emacs-24.2.93 build problems Nelson H. F. Beebe
2013-03-03 0:09 ` Paul Eggert
2013-03-04 20:34 ` Glenn Morris
2013-03-04 23:44 ` Jérémie Courrèges-Anglas
2013-03-05 3:47 ` Glenn Morris
2013-03-05 14:00 ` Jérémie Courrèges-Anglas
2013-03-05 14:52 ` Jérémie Courrèges-Anglas [this message]
2013-03-05 20:06 ` emacs-24.2.93 build problems (on OpenBSD) Glenn Morris
2013-03-05 17:06 ` emacs-24.2.93 build problems Glenn Morris
2013-03-05 17:24 ` list-system-processes on OpenBSD [was Re: emacs-24.2.93 build problems] Glenn Morris
2013-03-05 17:36 ` Paul Eggert
2013-03-05 20:42 ` list-system-processes on OpenBSD Glenn Morris
2013-03-05 21:57 ` Paul Eggert
2013-03-05 22:30 ` Jérémie Courrèges-Anglas
2013-03-06 0:38 ` [24.3] possible build failure for list-system-processes on NetBSD Jérémie Courrèges-Anglas
2013-03-06 2:28 ` [24.3] possible build failure for list-system-processes on DragonFlyBSD Jérémie Courrèges-Anglas
2013-03-06 3:12 ` Glenn Morris
2013-03-06 5:07 ` Paul Eggert
2013-03-06 7:30 ` Glenn Morris
2013-03-06 2:31 ` list-system-processes on OpenBSD [was Re: emacs-24.2.93 build problems] Leo Liu
2013-03-04 23:51 ` emacs-24.2.93 build problems Glenn Morris
2013-03-05 2:06 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k3plgaqn.fsf@moo.wxcvbn.org \
--to=jca+emacs@wxcvbn.org \
--cc=emacs-devel@gnu.org \
--cc=rgm@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.