From: Omar Polo <op@omarpolo.com>
To: "Timo Myyrä" <timo.myyra@bittivirhe.fi>
Cc: emacs-devel@gnu.org
Subject: Re: [patch] system_process_attributes for OpenBSD
Date: Sat, 02 Jan 2021 11:36:22 +0100 [thread overview]
Message-ID: <87o8i7pqvt.fsf@omarpolo.com> (raw)
In-Reply-To: <878s9bpzj8.fsf@asteroid.bittivirhe.fi>
Timo Myyrä <timo.myyra@bittivirhe.fi> writes:
> Omar Polo <op@omarpolo.com> [2021-01-01, 23:29 +0100]:
>
>[snip]
>
> Hi Omar,
>
> Are you sure you need kvm? I'm under impression its frowned upon to
> access that from userland.
Thanks for sharing! I haven't followed closely the development of
OpenBSD, but at least on -CURRENT trying to get a struct kinfo_proc for
a specific pid via sysctl results in errors (both from sysctl(8) and
sysctl(3)):
$ sysctl kern.proc
sysctl: use ps to view kern.proc information
$ sysctl kern.proc 75056 # a valid pid
sysctl: use ps to view kern.proc information
sysctl: top level name 75056 in 75056 is invalid
$ cat <<EOF > pid.c
#include <sys/types.h>
#include <sys/sysctl.h>
#include <err.h>
#include <stdlib.h>
int
main(void)
{
pid_t pid = 75056; /* valid pid */
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid };
struct kinfo_proc proc;
size_t len = sizeof(proc);
if (sysctl(mib, 4, &proc, &len, NULL, 0) != 0 || len == 0)
err(1, "sysctl");
return 0;
}
EOF
$ cc pid.c -o pid && ./pid
pid: sysctl: Invalid argument
$ ps 75056
75056 ?? S 0:38.85 emacs --daemon (emacs-27.1)
This plus the fact that both top and ps in base uses kvm were the
rationale for my choice.
Regarding list_system_processes, I still have to check the differences,
but the current version on master is fundamentally equivalent to yours
(modulo a bunch of #ifdefs for freebsd and macos), so I guess it was
merged at some point? Here on emacs-27.1 (list-system-processes)
returns nil, but on emacs compiled from master it works correctly.
next prev parent reply other threads:[~2021-01-02 10:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-01 22:29 [patch] system_process_attributes for OpenBSD Omar Polo
2021-01-02 6:18 ` Lars Ingebrigtsen
2021-01-02 7:29 ` Timo Myyrä
2021-01-02 10:36 ` Omar Polo [this message]
2021-01-02 12:16 ` Timo Myyrä
2021-01-02 12:30 ` Omar Polo
2021-01-02 7:43 ` Timo Myyrä
2021-01-05 19:39 ` Omar Polo
2021-01-07 11:23 ` Lars Ingebrigtsen
2021-01-07 11:30 ` Omar Polo
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o8i7pqvt.fsf@omarpolo.com \
--to=op@omarpolo.com \
--cc=emacs-devel@gnu.org \
--cc=timo.myyra@bittivirhe.fi \
/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 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).