From owner-freebsd-arch@FreeBSD.ORG Sat May 3 18:21:05 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0C047DF1; Sat, 3 May 2014 18:21:05 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A100016AD; Sat, 3 May 2014 18:21:04 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.8/8.14.8) with ESMTP id s43IKsQ9095799; Sat, 3 May 2014 21:20:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua s43IKsQ9095799 Received: (from kostik@localhost) by tom.home (8.14.8/8.14.8/Submit) id s43IKr0C095796; Sat, 3 May 2014 21:20:53 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 3 May 2014 21:20:53 +0300 From: Konstantin Belousov To: Sergey Kandaurov Subject: Re: safer alternative for pfind and pget? Message-ID: <20140503182053.GC74331@kib.kiev.ua> References: <20140502220925.GB28158@dft-labs.eu> <20140502223609.GU43976@funkthat.com> <20140503091213.GA3876@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jy6Sn24JjFx/iggw" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: Mikolaj Golub , John-Mark Gurney , Mateusz Guzik , FreeBSD Arch X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 May 2014 18:21:05 -0000 --jy6Sn24JjFx/iggw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, May 03, 2014 at 01:59:12PM +0400, Sergey Kandaurov wrote: > On 3 May 2014 13:12, Mikolaj Golub wrote: > > On Fri, May 02, 2014 at 03:36:09PM -0700, John-Mark Gurney wrote: > >> Mateusz Guzik wrote this message on Sat, May 03, 2014 at 00:09 +0200: > >> > - pget which provides limited (mostly negative) filtering > >> > >> as pget is undocumented, please make it part of this project to > >> document it.. > > > > pluknet had a man page for pget long time ago, reviewed by kib. I > > thought it was committed. Don't know why it did not happen. >=20 > This is something I have for pget(9). > If it is good enough, I'll commit it. >=20 See some minor notes below. And yes, please commit this. > .\" Copyright (c) 2011 Sergey Kandaurov > .\" All rights reserved. > .\" > .\" Redistribution and use in source and binary forms, with or without > .\" modification, are permitted provided that the following conditions > .\" are met: > .\" 1. Redistributions of source code must retain the above copyright > .\" notice, this list of conditions and the following disclaimer. > .\" 2. Redistributions in binary form must reproduce the above copyright > .\" notice, this list of conditions and the following disclaimer in the > .\" documentation and/or other materials provided with the distributio= n. > .\" > .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PU= RPOSE > .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIAB= LE > .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUE= NTIAL > .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOO= DS > .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S= TRICT > .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY= WAY > .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > .\" SUCH DAMAGE. > .\" > .\" $FreeBSD$ > .\" > .Dd December 21, 2011 > .Dt PGET 9 > .Os > .Sh NAME > .Nm pget > .Nd locate a process by number > .Sh SYNOPSIS > .In sys/param.h > .In sys/proc.h > .Ft int > .Fn pget "pid_t pid" "int flags" "struct proc **pp" > .Sh DESCRIPTION > This function > takes a > .Fa pid > as its argument, which can be either a process or thread id, In the later case, a process owning the specified thread is looked for. >and fills a pointer to the > .Vt proc > structure in > .Fa *pp . > The actual operation is performed by invoking the > .Xr pfind 9 > function. > The found process is returned locked. > Only for > .Dv PGET_HOLD > case it is returned unlocked (but referenced). s/referenced/held/ > The > .Fn pget > function can > perform additional manipulations, depending on a > .Fa flags > argument. > .Pp > The > .Fa flags > argument is the logical OR of some subset of: > .Bl -tag -width ".Dv PGET_NOTINEXEC" > .It Dv PGET_HOLD > If set, the found process will be referenced and unlocked. > .It Dv PGET_CANSEE > If set, the found process will be checked for its visibility. > See > .Xr p_cansee 9 . > .It Dv PGET_CANDEBUG > If set, the found process will be checked for its debuggability. > See > .Xr p_candebug 9 . > .It Dv PGET_ISCURRENT > If set, the found process will be checked that it matches the current > process context. > .It Dv PGET_NOTWEXIT > If set, the found process will be checked that it does not have the proce= ss > flag > .Dv P_WEXIT > set. > .It Dv PGET_NOTINEXEC > If set, the found process will be checked that it does not have the proce= ss > flag > .Dv P_INEXEC > set. > .It Dv PGET_NOTID > If set, > .Fa pid > is not assumed as a thread id for values larger than > .Dv PID_MAX . > .It Dv PGET_WANTREAD > A shorthand for > .Pq Dv PGET_HOLD | PGET_CANDEBUG | PGET_NOTWEXIT . > .El > .Sh RETURN VALUES > If the process is found in the specified way, then zero is returned, > otherwise an appropriate error code is returned. > .Sh SEE ALSO > .Xr p_candebug 9 , > .Xr p_cansee 9 , > .Xr pfind 9 --jy6Sn24JjFx/iggw Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJTZTOFAAoJEJDCuSvBvK1BaJMQAIeEuT9RHLqR6iHDkE3iLaSc zfiNxMXkz6j0J9o1nlBvXmY8Ra7EvwhGQydmhxh5LJUfQdRKbz98jhzxXdUsLEUc ThePYNCaEsM64pnF+OdL2X9BVkINj4Yaa8sAQVhD0Eot49xUhPcEw4StC7fx6qO5 uLBqxtlzcVnVUGyKJwLmi2BZn2Hgu8igsAs4i3zlzq6IIgbVvFLUSEdah0JyGw/2 y1r5CSNk57LovlYaMPIgPvth+n/StPJnP144XVgg+Cvsy6r7kbd4OwBx6MmsrcVq 7IFjVtRDRhYC3avj/3KyAgHwF/pb0YEGtKbVd5bJCR2pAkcrf4iUybjmGnhGy3R+ pgUktME+OI0iydVEpHbwrCvHNEAFmp93Sny7wYMzo0q6hz6wK2e7ehNskFQy0RD2 5u9MZHPcQbUh6nMV/lOhOGuyPJL1xV61cyfIiCvTmiqrw1xYnmGvR4WNeiHSQaek 0mUOUS79cFiAKF0rWzjrwOXiK8xPBclv+0aNk6FHsjI1B7qBM0Nh0gVEZlUfvlRP QiJ/Ni130ot6fhlamgjphrjAXEAnWcPvWZ1QaG6NzHPChES2daUY7+LC5Nn+eKAE cNV5cmeq2aGbPL8IRmn2rmTPCeAdbOvT3Q0fjY4GTA7UWfXmJlK+FsdoqXcgOIoK 7Pf5/1aFHW/9JKjkPLp4 =azoE -----END PGP SIGNATURE----- --jy6Sn24JjFx/iggw--