From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Omar Polo Newsgroups: gmane.emacs.devel Subject: Re: [patch] system_process_attributes for OpenBSD Date: Sat, 02 Jan 2021 13:30:41 +0100 Message-ID: <87ft3jplla.fsf@omarpolo.com> References: <87k0sw5lzt.fsf@omarpolo.com> <878s9bpzj8.fsf@asteroid.bittivirhe.fi> <87o8i7pqvt.fsf@omarpolo.com> <87v9cfo7o0.fsf@asteroid.bittivirhe.fi> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38257"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.13; emacs 27.1 Cc: emacs-devel@gnu.org To: Timo =?utf-8?Q?Myyr=C3=A4?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jan 02 13:32:33 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kvg5B-0009sv-6Y for ged-emacs-devel@m.gmane-mx.org; Sat, 02 Jan 2021 13:32:33 +0100 Original-Received: from localhost ([::1]:33732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kvg5A-0000uL-83 for ged-emacs-devel@m.gmane-mx.org; Sat, 02 Jan 2021 07:32:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvg3j-0000Fm-Iq for emacs-devel@gnu.org; Sat, 02 Jan 2021 07:31:04 -0500 Original-Received: from mail.omarpolo.com ([144.91.116.244]:64034) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvg3c-0001Ua-Hx for emacs-devel@gnu.org; Sat, 02 Jan 2021 07:31:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omarpolo.com; s=20200327; t=1609590647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qvG6RbItYiGgF4OyhyFf1lGz7HbmAiQOpdQUoq2Tj+k=; b=KN+N6MUjqrMhxjSAQT58UfveK51GPf3PhRR4CZig7b0yaU0h5sFBfZGb+9zYcUoOhOgeDV A7a6Rn1a7cjDtdYFGBnjooUVYVTbBI+2Ln7azoAh/tK1Bsrgd+m36DJvV+cZBi+g0u301S p2Gzo8Pn99JeSk62tJdcKAzu+I/uZEo= Original-Received: from localhost (host-80-116-112-105.retail.telecomitalia.it [80.116.112.105]) by mail.omarpolo.com (OpenSMTPD) with ESMTPSA id 147d2a61 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 2 Jan 2021 13:30:47 +0100 (CET) Original-Received: from venera (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 6c060374; Sat, 2 Jan 2021 13:30:41 +0100 (CET) In-reply-to: <87v9cfo7o0.fsf@asteroid.bittivirhe.fi> Received-SPF: pass client-ip=144.91.116.244; envelope-from=op@omarpolo.com; helo=mail.omarpolo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:262312 Archived-At: Timo Myyr=C3=A4 writes: > [snip] > > Yeah, forgot to finish this so its been a while. Seems that the process > listing is already in emacs so that can be discarded. > > But I got following sample program working without using kvm. > > #include > #include > #include > #include > #include > > int > main(int argc, char **argv) { > if (argc < 2) { > fprintf(stderr, "Must give PID number as an argument!\n"); > exit(1); > } > pid_t pid =3D atoi(argv[1]); /* valid pid */ > int mib[6] =3D { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid, sizeof(struct= kinfo_proc), 1}; > struct kinfo_proc proc; > size_t len =3D sizeof(proc); > > if (sysctl(mib, 6, &proc, &len, NULL, 0) !=3D 0) > err(1, "sysctl"); > printf("pid belongs to command: %s\n", proc.p_comm); > return 0; > } > > I'd say above would be prefered as there would be no need to add more > libraries. I recall the sysctl(8) is intentionally a bit limited but the > sysctl(2) should give full access. > > Timo Yeah, you're right! No wonders I got "invalid argument" from sysctl(2), I was using the wrong mib! I'll update the patch ditching kvm in favour of sysctl. Other than avoid linking to kvm, this allows me to drop that ugly static variable for the kvm handler. Thanks! Omar Polo