xref: /freebsd/share/man/man9/pget.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
117f494c0SSergey Kandaurov.\" Copyright (c) 2011 Sergey Kandaurov
217f494c0SSergey Kandaurov.\" All rights reserved.
317f494c0SSergey Kandaurov.\"
417f494c0SSergey Kandaurov.\" Redistribution and use in source and binary forms, with or without
517f494c0SSergey Kandaurov.\" modification, are permitted provided that the following conditions
617f494c0SSergey Kandaurov.\" are met:
717f494c0SSergey Kandaurov.\" 1. Redistributions of source code must retain the above copyright
817f494c0SSergey Kandaurov.\"    notice, this list of conditions and the following disclaimer.
917f494c0SSergey Kandaurov.\" 2. Redistributions in binary form must reproduce the above copyright
1017f494c0SSergey Kandaurov.\"    notice, this list of conditions and the following disclaimer in the
1117f494c0SSergey Kandaurov.\"    documentation and/or other materials provided with the distribution.
1217f494c0SSergey Kandaurov.\"
1317f494c0SSergey Kandaurov.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1417f494c0SSergey Kandaurov.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1517f494c0SSergey Kandaurov.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1617f494c0SSergey Kandaurov.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1717f494c0SSergey Kandaurov.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1817f494c0SSergey Kandaurov.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1917f494c0SSergey Kandaurov.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2017f494c0SSergey Kandaurov.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2117f494c0SSergey Kandaurov.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2217f494c0SSergey Kandaurov.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2317f494c0SSergey Kandaurov.\" SUCH DAMAGE.
2417f494c0SSergey Kandaurov.\"
2517f494c0SSergey Kandaurov.Dd May 3, 2014
2617f494c0SSergey Kandaurov.Dt PGET 9
2717f494c0SSergey Kandaurov.Os
2817f494c0SSergey Kandaurov.Sh NAME
2917f494c0SSergey Kandaurov.Nm pget
3017f494c0SSergey Kandaurov.Nd locate a process by number
3117f494c0SSergey Kandaurov.Sh SYNOPSIS
3217f494c0SSergey Kandaurov.In sys/param.h
3317f494c0SSergey Kandaurov.In sys/proc.h
3417f494c0SSergey Kandaurov.Ft int
3517f494c0SSergey Kandaurov.Fn pget "pid_t pid" "int flags" "struct proc **pp"
3617f494c0SSergey Kandaurov.Sh DESCRIPTION
3717f494c0SSergey KandaurovThis function
3817f494c0SSergey Kandaurovtakes a
3917f494c0SSergey Kandaurov.Fa pid
4017f494c0SSergey Kandaurovas its argument,
4117f494c0SSergey Kandaurovwhich can be either a process or thread id,
4217f494c0SSergey Kandaurovand fills a pointer to the
4317f494c0SSergey Kandaurov.Vt proc
4417f494c0SSergey Kandaurovstructure in
4517f494c0SSergey Kandaurov.Fa *pp .
4617f494c0SSergey KandaurovIn the latter case, a process owning the specified thread is looked for.
47*4688952cSSergey KandaurovThe operation is performed by invoking the
4817f494c0SSergey Kandaurov.Xr pfind 9
4917f494c0SSergey Kandaurovfunction.
5017f494c0SSergey KandaurovThe found process is returned locked.
51*4688952cSSergey KandaurovFor the
5217f494c0SSergey Kandaurov.Dv PGET_HOLD
53*4688952cSSergey Kandaurovcase, it is returned unlocked (but held).
5417f494c0SSergey KandaurovThe
5517f494c0SSergey Kandaurov.Fn pget
5617f494c0SSergey Kandaurovfunction can
5717f494c0SSergey Kandaurovperform additional manipulations, depending on a
5817f494c0SSergey Kandaurov.Fa flags
5917f494c0SSergey Kandaurovargument.
6017f494c0SSergey Kandaurov.Pp
6117f494c0SSergey KandaurovThe
6217f494c0SSergey Kandaurov.Fa flags
6317f494c0SSergey Kandaurovargument is the logical OR of some subset of:
6417f494c0SSergey Kandaurov.Bl -tag -width ".Dv PGET_NOTINEXEC"
6517f494c0SSergey Kandaurov.It Dv PGET_HOLD
66*4688952cSSergey KandaurovIf set, the found process will be held and unlocked.
6717f494c0SSergey Kandaurov.It Dv PGET_CANSEE
6817f494c0SSergey KandaurovIf set, the found process will be checked for its visibility.
6917f494c0SSergey KandaurovSee
7017f494c0SSergey Kandaurov.Xr p_cansee 9 .
7117f494c0SSergey Kandaurov.It Dv PGET_CANDEBUG
7217f494c0SSergey KandaurovIf set, the found process will be checked for its debuggability.
7317f494c0SSergey KandaurovSee
7417f494c0SSergey Kandaurov.Xr p_candebug 9 .
7517f494c0SSergey Kandaurov.It Dv PGET_ISCURRENT
7617f494c0SSergey KandaurovIf set, the found process will be checked that it matches the current
7717f494c0SSergey Kandaurovprocess context.
7817f494c0SSergey Kandaurov.It Dv PGET_NOTWEXIT
7917f494c0SSergey KandaurovIf set, the found process will be checked that it does not have the process
8017f494c0SSergey Kandaurovflag
8117f494c0SSergey Kandaurov.Dv P_WEXIT
8217f494c0SSergey Kandaurovset.
8317f494c0SSergey Kandaurov.It Dv PGET_NOTINEXEC
8417f494c0SSergey KandaurovIf set, the found process will be checked that it does not have the process
8517f494c0SSergey Kandaurovflag
8617f494c0SSergey Kandaurov.Dv P_INEXEC
8717f494c0SSergey Kandaurovset.
8817f494c0SSergey Kandaurov.It Dv PGET_NOTID
8917f494c0SSergey KandaurovIf set,
9017f494c0SSergey Kandaurov.Fa pid
9117f494c0SSergey Kandaurovis not assumed as a thread id for values larger than
9217f494c0SSergey Kandaurov.Dv PID_MAX .
9317f494c0SSergey Kandaurov.It Dv PGET_WANTREAD
94*4688952cSSergey KandaurovIf set, the found process will be checked that the caller may get
95*4688952cSSergey Kandaurova read access to its structure.
9617f494c0SSergey KandaurovA shorthand for
9717f494c0SSergey Kandaurov.Pq Dv PGET_HOLD | PGET_CANDEBUG | PGET_NOTWEXIT .
9817f494c0SSergey Kandaurov.El
9917f494c0SSergey Kandaurov.Sh RETURN VALUES
10017f494c0SSergey KandaurovIf the process is found in the specified way, then zero is returned,
10117f494c0SSergey Kandaurovotherwise an appropriate error code is returned.
10217f494c0SSergey Kandaurov.Sh SEE ALSO
10317f494c0SSergey Kandaurov.Xr p_candebug 9 ,
10417f494c0SSergey Kandaurov.Xr p_cansee 9 ,
10517f494c0SSergey Kandaurov.Xr pfind 9
106