xref: /illumos-gate/usr/src/man/man5/proc.5 (revision a14132db566b083c26658ccbf0a1ba8885fc5c27)
1bbf21555SRichard Lowe.\" Copyright 1989 AT&T
2bbf21555SRichard Lowe.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
3bbf21555SRichard Lowe.\" Copyright 2019, Joyent, Inc.
4bbf21555SRichard Lowe.\" Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
5ed093b41SRobert Mustacchi.\" Copyright 2023 Oxide computer Company
6bbf21555SRichard Lowe.\"
7bbf21555SRichard Lowe.\" The contents of this file are subject to the terms of the
8bbf21555SRichard Lowe.\" Common Development and Distribution License (the "License").
9bbf21555SRichard Lowe.\" You may not use this file except in compliance with the License.
10bbf21555SRichard Lowe.\"
11bbf21555SRichard Lowe.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
12bbf21555SRichard Lowe.\" or http://www.opensolaris.org/os/licensing.
13bbf21555SRichard Lowe.\" See the License for the specific language governing permissions
14bbf21555SRichard Lowe.\" and limitations under the License.
15bbf21555SRichard Lowe.\"
16bbf21555SRichard Lowe.\" When distributing Covered Code, include this CDDL HEADER in each
17bbf21555SRichard Lowe.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
18bbf21555SRichard Lowe.\" If applicable, add the following below this CDDL HEADER, with the
19bbf21555SRichard Lowe.\" fields enclosed by brackets "[]" replaced with your own identifying
20bbf21555SRichard Lowe.\" information: Portions Copyright [yyyy] [name of copyright owner]
21bbf21555SRichard Lowe.\"
22*a14132dbSRobert Mustacchi.Dd May 8, 2023
23bbf21555SRichard Lowe.Dt PROC 5
24bbf21555SRichard Lowe.Os
25bbf21555SRichard Lowe.Sh NAME
26bbf21555SRichard Lowe.Nm proc
27bbf21555SRichard Lowe.Nd /proc, the process file system
28bbf21555SRichard Lowe.Sh DESCRIPTION
29bbf21555SRichard Lowe.Pa /proc
30bbf21555SRichard Loweis a file system that provides access to the state of each process
31bbf21555SRichard Loweand light-weight process (lwp) in the system.
32bbf21555SRichard LoweThe name of each entry in the
33bbf21555SRichard Lowe.Pa /proc
34bbf21555SRichard Lowedirectory is a decimal number corresponding to a process-ID.
35bbf21555SRichard LoweThese entries are themselves subdirectories.
36bbf21555SRichard LoweAccess to process state is provided by additional files contained within each
37bbf21555SRichard Lowesubdirectory; the hierarchy is described more completely below.
38bbf21555SRichard LoweIn this document,
39bbf21555SRichard Lowe.Dq Pa /proc file
40bbf21555SRichard Lowerefers to a non-directory file within the hierarchy rooted at
41bbf21555SRichard Lowe.Pa /proc .
42bbf21555SRichard LoweThe owner of each
43bbf21555SRichard Lowe.Pa /proc
44bbf21555SRichard Lowefile and subdirectory is determined by the user-ID of the process.
45bbf21555SRichard Lowe.Pp
46bbf21555SRichard Lowe.Pa /proc
47bbf21555SRichard Lowecan be mounted on any mount point, in addition to the standard
48bbf21555SRichard Lowe.Pa /proc
49bbf21555SRichard Lowemount point, and can be mounted several places at once.
50bbf21555SRichard LoweSuch additional mounts are allowed in order to facilitate the confinement of
51bbf21555SRichard Loweprocesses to subtrees of the file system via
52bbf21555SRichard Lowe.Xr chroot 2
53bbf21555SRichard Loweand yet allow such processes access to commands like
54bbf21555SRichard Lowe.Xr ps 1 .
55bbf21555SRichard Lowe.Pp
56bbf21555SRichard LoweStandard system calls are used to access
57bbf21555SRichard Lowe.Pa /proc
58bbf21555SRichard Lowefiles:
59bbf21555SRichard Lowe.Xr open 2 ,
60bbf21555SRichard Lowe.Xr close 2 ,
61bbf21555SRichard Lowe.Xr read 2 ,
62bbf21555SRichard Loweand
63bbf21555SRichard Lowe.Xr write 2
64bbf21555SRichard Lowe(including
65bbf21555SRichard Lowe.Xr readv 2 ,
66bbf21555SRichard Lowe.Xr writev 2 ,
67bbf21555SRichard Lowe.Xr pread 2 ,
68bbf21555SRichard Loweand
69bbf21555SRichard Lowe.Xr pwrite 2 ) .
70bbf21555SRichard LoweMost files describe process state and can only be opened for reading.
71bbf21555SRichard Lowe.Pa ctl
72bbf21555SRichard Loweand
73bbf21555SRichard Lowe.Pa lwpctl
74bbf21555SRichard Lowe(control) files permit manipulation of process state and can only be opened for
75bbf21555SRichard Lowewriting.
76bbf21555SRichard Lowe.Pa as
77bbf21555SRichard Lowe(address space) files contain the image of the running process and can be
78bbf21555SRichard Loweopened for both reading and writing.
79bbf21555SRichard LoweAn open for writing allows process control; a read-only open allows inspection
80bbf21555SRichard Lowebut not control.
81bbf21555SRichard LoweIn this document, we refer to the process as open for reading or writing if
82bbf21555SRichard Loweany of its associated
83bbf21555SRichard Lowe.Pa /proc
84bbf21555SRichard Lowefiles is open for reading or writing.
85bbf21555SRichard Lowe.Pp
86bbf21555SRichard LoweIn general, more than one process can open the same
87bbf21555SRichard Lowe.Pa /proc
88bbf21555SRichard Lowefile at the same time. \fIExclusive\fR \fIopen\fR is an advisory mechanism provided to
89bbf21555SRichard Loweallow controlling processes to avoid collisions with each other.
90bbf21555SRichard LoweA process can obtain exclusive control of a target process, with respect to
91bbf21555SRichard Loweother cooperating processes, if it successfully opens any
92bbf21555SRichard Lowe.Pa /proc
93bbf21555SRichard Lowefile in the target process for writing (the
94bbf21555SRichard Lowe.Pa as
95bbf21555SRichard Loweor
96bbf21555SRichard Lowe.Pa ctl
97bbf21555SRichard Lowefiles, or the
98bbf21555SRichard Lowe.Pa lwpctl
99bbf21555SRichard Lowefile of any lwp) while specifying
100bbf21555SRichard Lowe.Sy O_EXCL
101bbf21555SRichard Lowein the
102bbf21555SRichard Lowe.Xr open 2 .
103bbf21555SRichard LoweSuch an open will fail if the target process is already open for writing (that
104bbf21555SRichard Loweis, if an
105bbf21555SRichard Lowe.Pa as ,
106bbf21555SRichard Lowe.Pa ctl ,
107bbf21555SRichard Loweor
108bbf21555SRichard Lowe.Pa lwpctl
109bbf21555SRichard Lowefile is already open for writing).
110bbf21555SRichard LoweThere can be any number of concurrent read-only opens;
111bbf21555SRichard Lowe.Sy O_EXCL
112bbf21555SRichard Loweis ignored on opens for reading.
113bbf21555SRichard LoweIt is recommended that the first open for writing by a controlling
114bbf21555SRichard Loweprocess use the
115bbf21555SRichard Lowe.Sy O_EXCL
116bbf21555SRichard Loweflag; multiple controlling processes usually result in chaos.
117bbf21555SRichard Lowe.Pp
118bbf21555SRichard LoweIf a process opens one of its own
119bbf21555SRichard Lowe.Pa /proc
120bbf21555SRichard Lowefiles for writing, the open
121bbf21555SRichard Lowesucceeds regardless of
122bbf21555SRichard Lowe.Sy O_EXCL
123bbf21555SRichard Loweand regardless of whether some other process has the process open for writing.
124bbf21555SRichard LoweSelf-opens do not count when another process attempts an exclusive open.
125bbf21555SRichard Lowe(A process cannot exclude a debugger by opening itself for writing and the
126bbf21555SRichard Loweapplication of a debugger cannot prevent a process from opening itself.)
127bbf21555SRichard LoweAll self-opens for writing are forced to be close-on-exec (see the
128bbf21555SRichard Lowe.Sy F_SETFD
129bbf21555SRichard Loweoperation of
130bbf21555SRichard Lowe.Xr fcntl 2 ) .
131bbf21555SRichard Lowe.Pp
132bbf21555SRichard LoweData may be transferred from or to any locations in the address space of the
133bbf21555SRichard Lowetraced process by applying
134bbf21555SRichard Lowe.Xr lseek 2
135bbf21555SRichard Loweto position the
136bbf21555SRichard Lowe.Pa as
137bbf21555SRichard Lowefile at the virtual address of interest followed by
138bbf21555SRichard Lowe.Xr read 2
139bbf21555SRichard Loweor
140bbf21555SRichard Lowe.Xr write 2
141bbf21555SRichard Lowe(or by using
142bbf21555SRichard Lowe.Xr pread 2
143bbf21555SRichard Loweor
144bbf21555SRichard Lowe.Xr pwrite 2
145bbf21555SRichard Lowefor the combined operation).
146bbf21555SRichard LoweThe address-map files
147bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /map
148bbf21555SRichard Loweand
149bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /xmap
150bbf21555SRichard Lowecan be read to determine the accessible areas (mappings) of the address space.
151bbf21555SRichard Lowe.Sy I/O
152bbf21555SRichard Lowetransfers may span contiguous mappings.
153bbf21555SRichard LoweAn
154bbf21555SRichard Lowe.Sy I/O
155bbf21555SRichard Lowerequest extending into an unmapped area is truncated at the boundary.
156bbf21555SRichard LoweA write request beginning at an unmapped virtual address fails with
157bbf21555SRichard Lowe.Er EIO ;
158bbf21555SRichard Lowea read request beginning at an unmapped virtual address returns zero (an
159bbf21555SRichard Loweend-of-file indication).
160bbf21555SRichard Lowe.Pp
161bbf21555SRichard LoweInformation and control operations are provided through additional files.
162bbf21555SRichard Lowe.In procfs.h
163bbf21555SRichard Lowecontains definitions of data structures and message formats
164bbf21555SRichard Loweused with these files.
165bbf21555SRichard LoweSome of these definitions involve the use of sets of flags.
166bbf21555SRichard LoweThe set types
167bbf21555SRichard Lowe.Sy sigset_t ,
168bbf21555SRichard Lowe.Sy fltset_t ,
169bbf21555SRichard Loweand
170bbf21555SRichard Lowe.Sy sysset_t
171bbf21555SRichard Lowecorrespond, respectively, to signal, fault, and system call enumerations
172bbf21555SRichard Lowedefined in
173bbf21555SRichard Lowe.In sys/signal.h ,
174bbf21555SRichard Lowe.In sys/fault.h ,
175bbf21555SRichard Loweand
176bbf21555SRichard Lowe.In sys/syscall.h .
177bbf21555SRichard LoweEach set type is large enough to hold flags for its own enumeration.
178bbf21555SRichard LoweAlthough they are of different sizes, they have a common
179bbf21555SRichard Lowestructure and can be manipulated by these macros:
180bbf21555SRichard Lowe.Bd -literal -offset indent
181bbf21555SRichard Loweprfillset(&set);             /* turn on all flags in set */
182bbf21555SRichard Lowepremptyset(&set);            /* turn off all flags in set */
183bbf21555SRichard Lowepraddset(&set, flag);        /* turn on the specified flag */
184bbf21555SRichard Loweprdelset(&set, flag);        /* turn off the specified flag */
185bbf21555SRichard Lower = prismember(&set, flag);  /* != 0 iff flag is turned on */
186bbf21555SRichard Lowe.Ed
187bbf21555SRichard Lowe.Pp
188bbf21555SRichard LoweOne of
189bbf21555SRichard Lowe.Fn prfillset
190bbf21555SRichard Loweor
191bbf21555SRichard Lowe.Fn premptyset
192bbf21555SRichard Lowemust be used to initialize
193bbf21555SRichard Lowe.Fa set
194bbf21555SRichard Lowebefore it is used in any other operation.
195bbf21555SRichard Lowe.Fa flag
196bbf21555SRichard Lowemust be a member of the enumeration corresponding to
197bbf21555SRichard Lowe.Fa set .
198bbf21555SRichard Lowe.Pp
199bbf21555SRichard LoweEvery process contains at least one
200bbf21555SRichard Lowe.Em light-weight process ,
201bbf21555SRichard Loweor
202bbf21555SRichard Lowe.Sy lwp .
203bbf21555SRichard LoweEach lwp represents a flow of execution that is independently scheduled by the
204bbf21555SRichard Loweoperating system.
205bbf21555SRichard LoweAll lwps in a process share its address space as well as many other attributes.
206bbf21555SRichard LoweThrough the use of
207bbf21555SRichard Lowe.Pa lwpctl
208bbf21555SRichard Loweand
209bbf21555SRichard Lowe.Pa ctl
210bbf21555SRichard Lowefiles as described below, it is possible to affect individual lwps in a
211bbf21555SRichard Loweprocess or to affect all of them at once, depending on the operation.
212bbf21555SRichard Lowe.Pp
213bbf21555SRichard LoweWhen the process has more than one lwp, a representative lwp is chosen by the
214bbf21555SRichard Lowesystem for certain process status files and control operations.
215bbf21555SRichard LoweThe representative lwp is a stopped lwp only if all of the process's lwps are
216bbf21555SRichard Lowestopped; is stopped on an event of interest only if all of the lwps are so
217bbf21555SRichard Lowestopped (excluding
218bbf21555SRichard Lowe.Sy PR_SUSPENDED
219bbf21555SRichard Lowelwps); is in a
220bbf21555SRichard Lowe.Sy PR_REQUESTED
221bbf21555SRichard Lowestop only if there are no other events of interest to be found; or, failing
222bbf21555SRichard Loweeverything else, is in a
223bbf21555SRichard Lowe.Sy PR_SUSPENDED
224bbf21555SRichard Lowestop (implying that the process is deadlocked).
225bbf21555SRichard LoweSee the description of the
226bbf21555SRichard Lowe.Pa status
227bbf21555SRichard Lowefile for definitions of stopped states.
228bbf21555SRichard LoweSee the
229bbf21555SRichard Lowe.Sy PCSTOP
230bbf21555SRichard Lowecontrol operation for the definition of
231bbf21555SRichard Lowe.Dq event of interest .
232bbf21555SRichard Lowe.Pp
233bbf21555SRichard LoweThe representative lwp remains fixed (it will be chosen again on the next
234bbf21555SRichard Loweoperation) as long as all of the lwps are stopped on events of interest or are
235bbf21555SRichard Lowein a
236bbf21555SRichard Lowe.Sy PR_SUSPENDED
237bbf21555SRichard Lowestop and the
238bbf21555SRichard Lowe.Sy PCRUN
239bbf21555SRichard Lowecontrol operation is not applied to any of them.
240bbf21555SRichard Lowe.Pp
241bbf21555SRichard LoweWhen applied to the process control file, every
242bbf21555SRichard Lowe.Pa /proc
243bbf21555SRichard Lowecontrol operation
244bbf21555SRichard Lowethat must act on an lwp uses the same algorithm to choose which lwp to act
245bbf21555SRichard Loweupon.
246bbf21555SRichard LoweTogether with synchronous stopping (see
247bbf21555SRichard Lowe.Sy PCSET ) ,
248bbf21555SRichard Lowethis enables a debugger to control a multiple-lwp process using only the
249bbf21555SRichard Loweprocess-level status and control files if it so chooses.
250bbf21555SRichard LoweMore fine-grained control can be achieved using the lwp-specific files.
251bbf21555SRichard Lowe.Pp
252bbf21555SRichard LoweThe system supports two process data models, the traditional 32-bit data model
253bbf21555SRichard Lowein which ints, longs and pointers are all 32 bits wide (the ILP32 data model),
254bbf21555SRichard Loweand on some platforms the 64-bit data model in which longs and pointers, but
255bbf21555SRichard Lowenot ints, are 64 bits in width (the LP64 data model).
256bbf21555SRichard LoweIn the LP64 data model some system data types, notably
257bbf21555SRichard Lowe.Sy size_t ,
258bbf21555SRichard Lowe.Sy off_t ,
259bbf21555SRichard Lowe.Sy time_t
260bbf21555SRichard Loweand
261bbf21555SRichard Lowe.Sy dev_t ,
262bbf21555SRichard Lowegrow from 32 bits to 64 bits as well.
263bbf21555SRichard Lowe.Pp
264bbf21555SRichard LoweThe
265bbf21555SRichard Lowe.Pa /proc
266bbf21555SRichard Loweinterfaces described here are available to both 32-bit and
267bbf21555SRichard Lowe64-bit controlling processes.
268bbf21555SRichard LoweHowever, many operations attempted by a 32-bit
269bbf21555SRichard Lowecontrolling process on a 64-bit target process will fail with
270bbf21555SRichard Lowe.Er EOVERFLOW
271bbf21555SRichard Lowebecause the address space range of a 32-bit process cannot encompass a 64-bit
272bbf21555SRichard Loweprocess or because the data in some 64-bit system data type cannot be
273bbf21555SRichard Lowecompressed to fit into the corresponding 32-bit type without loss of
274bbf21555SRichard Loweinformation.
275bbf21555SRichard LoweOperations that fail in this circumstance include reading and
276bbf21555SRichard Lowewriting the address space, reading the address-map files, and setting the
277bbf21555SRichard Lowetarget process's registers.
278bbf21555SRichard LoweThere is no restriction on operations applied by a
279bbf21555SRichard Lowe64-bit process to either a 32-bit or a 64-bit target processes.
280bbf21555SRichard Lowe.Pp
281bbf21555SRichard LoweThe format of the contents of any
282bbf21555SRichard Lowe.Pa /proc
283bbf21555SRichard Lowefile depends on the data model of the observer (the controlling process), not
284bbf21555SRichard Loweon the data model of the target process.
285bbf21555SRichard LoweA 64-bit debugger does not have to translate the information it reads from a
286bbf21555SRichard Lowe.Pa /proc
287bbf21555SRichard Lowefile for a 32-bit process from 32-bit format to 64-bit format.
288bbf21555SRichard LoweHowever, it usually has to be aware of the data model of the target process.
289bbf21555SRichard LoweThe
290bbf21555SRichard Lowe.Sy pr_dmodel
291bbf21555SRichard Lowefield of the
292bbf21555SRichard Lowe.Pa status
293bbf21555SRichard Lowefiles indicates the target process's data model.
294bbf21555SRichard Lowe.Pp
295bbf21555SRichard LoweTo help deal with system data structures that are read from 32-bit processes, a
296bbf21555SRichard Lowe64-bit controlling program can be compiled with the C preprocessor symbol
297bbf21555SRichard Lowe.Dv _SYSCALL32
298bbf21555SRichard Lowedefined before system header files are included.
299bbf21555SRichard LoweThis makes explicit 32-bit fixed-width data structures (like
300bbf21555SRichard Lowe.Sy struct stat32 )
301bbf21555SRichard Lowevisible to the 64-bit program.
302bbf21555SRichard LoweSee
303bbf21555SRichard Lowe.Xr types32.h 3HEAD .
304bbf21555SRichard Lowe.Sh DIRECTORY STRUCTURE
305bbf21555SRichard LoweAt the top level, the directory
306bbf21555SRichard Lowe.Pa /proc
307bbf21555SRichard Lowecontains entries each of which names an existing process in the system.
308bbf21555SRichard LoweThese entries are themselves directories.
309bbf21555SRichard LoweExcept where otherwise noted, the files described below can be
310bbf21555SRichard Loweopened for reading only.
311bbf21555SRichard LoweIn addition, if a process becomes a
312bbf21555SRichard Lowe.Em zombie
313bbf21555SRichard Lowe(one that has exited but whose parent has not yet performed a
314bbf21555SRichard Lowe.Xr wait 3C
315bbf21555SRichard Loweupon it), most of its associated
316bbf21555SRichard Lowe.Pa /proc
317bbf21555SRichard Lowefiles disappear from the hierarchy; subsequent attempts to open them, or to
318bbf21555SRichard Loweread or write files opened before the process exited, will elicit the error
319bbf21555SRichard Lowe.Er ENOENT .
320bbf21555SRichard Lowe.Pp
321bbf21555SRichard LoweAlthough process state and consequently the contents of
322bbf21555SRichard Lowe.Pa /proc
323bbf21555SRichard Lowefiles can change from instant to instant, a single
324bbf21555SRichard Lowe.Xr read 2
325bbf21555SRichard Loweof a
326bbf21555SRichard Lowe.Pa /proc
327bbf21555SRichard Lowefile is guaranteed to return a sane representation of state; that is, the read
328bbf21555SRichard Lowewill be atomic with respect to the state of the process.
329bbf21555SRichard LoweNo such guarantee applies to successive reads applied to a
330bbf21555SRichard Lowe.Pa /proc
331bbf21555SRichard Lowefile for a running process.
332bbf21555SRichard LoweIn addition, atomicity is not guaranteed for
333bbf21555SRichard Lowe.Sy I/O
334bbf21555SRichard Loweapplied to the
335bbf21555SRichard Lowe.Pa as
336bbf21555SRichard Lowe(address-space) file for a running process or for a process whose address space
337bbf21555SRichard Lowecontains memory shared by another running process.
338bbf21555SRichard Lowe.Pp
339bbf21555SRichard LoweA number of structure definitions are used to describe the files.
340bbf21555SRichard LoweThese structures may grow by the addition of elements at the end in future
341bbf21555SRichard Lowereleases of the system and it is not legitimate for a program to assume that
342bbf21555SRichard Lowethey will not.
343bbf21555SRichard Lowe.Sh STRUCTURE OF Pa /proc/ Ns Em pid
344bbf21555SRichard LoweA given directory
345bbf21555SRichard Lowe.Pa /proc/ Ns Em pid
346bbf21555SRichard Lowecontains the following entries.
347bbf21555SRichard LoweA process can use the invisible alias
348bbf21555SRichard Lowe.Pa /proc/self
349bbf21555SRichard Loweif it wishes to open one of its own
350bbf21555SRichard Lowe.Pa /proc
351bbf21555SRichard Lowefiles (invisible in the sense that the name
352bbf21555SRichard Lowe.Dq self
353bbf21555SRichard Lowedoes not appear in a directory listing of
354bbf21555SRichard Lowe.Pa /proc
355bbf21555SRichard Loweobtained from
356bbf21555SRichard Lowe.Xr ls 1 ,
357bbf21555SRichard Lowe.Xr getdents 2 ,
358bbf21555SRichard Loweor
359bbf21555SRichard Lowe.Xr readdir 3C ) .
360bbf21555SRichard Lowe.Ss contracts
361bbf21555SRichard LoweA directory containing references to the contracts held by the process.
362bbf21555SRichard LoweEach entry is a symlink to the contract's directory under
363bbf21555SRichard Lowe.Pa /system/contract .
364bbf21555SRichard LoweSee
365bbf21555SRichard Lowe.Xr contract 5 .
366bbf21555SRichard Lowe.Ss as
367bbf21555SRichard LoweContains the address-space image of the process; it can be opened for both
368bbf21555SRichard Lowereading and writing.
369bbf21555SRichard Lowe.Xr lseek 2
370bbf21555SRichard Loweis used to position the file at the virtual address of interest and then the
371bbf21555SRichard Loweaddress space can be examined or changed through
372bbf21555SRichard Lowe.Xr read 2
373bbf21555SRichard Loweor
374bbf21555SRichard Lowe.Xr write 2
375bbf21555SRichard Lowe(or by using
376bbf21555SRichard Lowe.Xr pread 2
377bbf21555SRichard Loweor
378bbf21555SRichard Lowe.Xr pwrite 2
379bbf21555SRichard Lowefor the combined operation).
380bbf21555SRichard Lowe.Ss ctl
381bbf21555SRichard LoweA write-only file to which structured messages are written directing the system
382bbf21555SRichard Loweto change some aspect of the process's state or control its behavior in some
383bbf21555SRichard Loweway.
384bbf21555SRichard LoweThe seek offset is not relevant when writing to this file.
385bbf21555SRichard LoweIndividual lwps also have associated
386bbf21555SRichard Lowe.Pa lwpctl
387bbf21555SRichard Lowefiles in the lwp subdirectories.
388bbf21555SRichard LoweA control message may be written either to the process's
389bbf21555SRichard Lowe.Pa ctl
390bbf21555SRichard Lowefile or to a specific
391bbf21555SRichard Lowe.Pa lwpctl
392bbf21555SRichard Lowefile with operation-specific effects.
393bbf21555SRichard LoweThe effect of a control message is immediately reflected in the state of the
394bbf21555SRichard Loweprocess visible through appropriate status and information files.
395bbf21555SRichard LoweThe types of control messages are described in detail later.
396bbf21555SRichard LoweSee
397bbf21555SRichard Lowe.Sx CONTROL MESSAGES .
398bbf21555SRichard Lowe.Ss status
399bbf21555SRichard LoweContains state information about the process and the representative lwp.
400bbf21555SRichard LoweThe file contains a
401bbf21555SRichard Lowe.Sy pstatus
402bbf21555SRichard Lowestructure which contains an embedded
403bbf21555SRichard Lowe.Sy lwpstatus
404bbf21555SRichard Lowestructure for the representative lwp, as follows:
405bbf21555SRichard Lowe.Bd -literal -offset 2
406bbf21555SRichard Lowetypedef struct pstatus {
407bbf21555SRichard Lowe     int pr_flags;            /* flags (see below) */
408bbf21555SRichard Lowe     int pr_nlwp;             /* number of active lwps in the process */
409bbf21555SRichard Lowe     int pr_nzomb;            /* number of zombie lwps in the process */
410bbf21555SRichard Lowe     pid_tpr_pid;             /* process id */
411bbf21555SRichard Lowe     pid_tpr_ppid;            /* parent process id */
412bbf21555SRichard Lowe     pid_tpr_pgid;            /* process group id */
413bbf21555SRichard Lowe     pid_tpr_sid;             /* session id */
414bbf21555SRichard Lowe     id_t pr_aslwpid;         /* obsolete */
415bbf21555SRichard Lowe     id_t pr_agentid;         /* lwp-id of the agent lwp, if any */
416bbf21555SRichard Lowe     sigset_t pr_sigpend;     /* set of process pending signals */
417bbf21555SRichard Lowe     uintptr_t pr_brkbase;    /* virtual address of the process heap */
418bbf21555SRichard Lowe     size_t pr_brksize;       /* size of the process heap, in bytes */
419bbf21555SRichard Lowe     uintptr_t pr_stkbase;    /* virtual address of the process stack */
420bbf21555SRichard Lowe     size_tpr_stksize;        /* size of the process stack, in bytes */
421bbf21555SRichard Lowe     timestruc_t pr_utime;    /* process user cpu time */
422bbf21555SRichard Lowe     timestruc_t pr_stime;    /* process system cpu time */
423bbf21555SRichard Lowe     timestruc_t pr_cutime;   /* sum of children's user times */
424bbf21555SRichard Lowe     timestruc_t pr_cstime;   /* sum of children's system times */
425bbf21555SRichard Lowe     sigset_t pr_sigtrace;    /* set of traced signals */
426bbf21555SRichard Lowe     fltset_t pr_flttrace;    /* set of traced faults */
427bbf21555SRichard Lowe     sysset_t pr_sysentry;    /* set of system calls traced on entry */
428bbf21555SRichard Lowe     sysset_t pr_sysexit;     /* set of system calls traced on exit */
429bbf21555SRichard Lowe     char pr_dmodel;          /* data model of the process */
430bbf21555SRichard Lowe     taskid_t pr_taskid;      /* task id */
431bbf21555SRichard Lowe     projid_t pr_projid;      /* project id */
432bbf21555SRichard Lowe     zoneid_t pr_zoneid;      /* zone id */
433bbf21555SRichard Lowe     lwpstatus_t pr_lwp;      /* status of the representative lwp */
434bbf21555SRichard Lowe} pstatus_t;
435bbf21555SRichard Lowe.Ed
436bbf21555SRichard Lowe.Pp
437bbf21555SRichard Lowe.Sy pr_flags
438bbf21555SRichard Loweis a bit-mask holding the following process flags.
439bbf21555SRichard LoweFor convenience, it also contains the lwp flags for the representative lwp,
440bbf21555SRichard Lowedescribed later.
441bbf21555SRichard Lowe.Bl -tag -width "PR_MSACCT" -offset indent
442bbf21555SRichard Lowe.It Sy PR_ISSYS
443bbf21555SRichard Loweprocess is a system process (see
444bbf21555SRichard Lowe.Sx PCSTOP ) .
445bbf21555SRichard Lowe.It Sy PR_VFORKP
446bbf21555SRichard Loweprocess is the parent of a vforked child (see
447bbf21555SRichard Lowe.Sx PCWATCH ) .
448bbf21555SRichard Lowe.It Sy PR_FORK
449bbf21555SRichard Loweprocess has its inherit-on-fork mode set (see
450bbf21555SRichard Lowe.Sx PCSET ) .
451bbf21555SRichard Lowe.It Sy PR_RLC
452bbf21555SRichard Loweprocess has its run-on-last-close mode set (see
453bbf21555SRichard Lowe.Sx PCSET ) .
454bbf21555SRichard Lowe.It Sy PR_KLC
455bbf21555SRichard Loweprocess has its kill-on-last-close mode set (see
456bbf21555SRichard Lowe.Sx PCSET ) .
457bbf21555SRichard Lowe.It Sy PR_ASYNC
458bbf21555SRichard Loweprocess has its asynchronous-stop mode set (see
459bbf21555SRichard Lowe.Sx PCSET ) .
460bbf21555SRichard Lowe.It Sy PR_MSACCT
461bbf21555SRichard LoweSet by default in all processes to indicate that microstate accounting is
462bbf21555SRichard Loweenabled.
463bbf21555SRichard LoweHowever, this flag has been deprecated and no longer has any effect.
464bbf21555SRichard LoweMicrostate accounting may not be disabled; however, it is still possible to
465bbf21555SRichard Lowetoggle the flag.
466bbf21555SRichard Lowe.It Sy PR_MSFORK
467bbf21555SRichard LoweSet by default in all processes to indicate that microstate accounting will be
468bbf21555SRichard Loweenabled for processes that this parent
469bbf21555SRichard Lowe.Xr fork 2 Ns s .
470bbf21555SRichard LoweHowever, this flag has been deprecated and no longer has any effect.
471bbf21555SRichard LoweIt is possible to toggle this flag; however, it is not possible to disable
472bbf21555SRichard Lowemicrostate accounting.
473bbf21555SRichard Lowe.It Sy PR_BPTADJ
474bbf21555SRichard Loweprocess has its breakpoint adjustment mode set (see
475bbf21555SRichard Lowe.Sx PCSET ) .
476bbf21555SRichard Lowe.It Sy PR_PTRACE
477bbf21555SRichard Loweprocess has its ptrace-compatibility mode set (see
478bbf21555SRichard Lowe.Sx PCSET ) .
479bbf21555SRichard Lowe.El
480bbf21555SRichard Lowe.Pp
481bbf21555SRichard Lowe.Sy pr_nlwp
482bbf21555SRichard Loweis the total number of active lwps in the process.
483bbf21555SRichard Lowe.Sy pr_nzomb
484bbf21555SRichard Loweis the total number of zombie lwps in the process.
485bbf21555SRichard LoweA zombie lwp is a non-detached lwp that has terminated but has not been reaped
486bbf21555SRichard Lowewith
487bbf21555SRichard Lowe.Xr thr_join 3C
488bbf21555SRichard Loweor
489bbf21555SRichard Lowe.Xr pthread_join 3C .
490bbf21555SRichard Lowe.Pp
491bbf21555SRichard Lowe.Sy pr_pid ,
492bbf21555SRichard Lowe.Sy pr_ppi ,
493bbf21555SRichard Lowe.Sy pr_pgid ,
494bbf21555SRichard Loweand
495bbf21555SRichard Lowe.Sy pr_sid
496bbf21555SRichard Loweare, respectively, the process ID, the ID of the process's parent, the
497bbf21555SRichard Loweprocess's process group ID, and the process's session ID.
498bbf21555SRichard Lowe.Pp
499bbf21555SRichard Lowe.Sy pr_aslwpid
500bbf21555SRichard Loweis obsolete and is always zero.
501bbf21555SRichard Lowe.Pp
502bbf21555SRichard Lowe.Sy pr_agentid
503bbf21555SRichard Loweis the lwp-ID for the
504bbf21555SRichard Lowe.Pa /proc
505bbf21555SRichard Loweagent lwp (see the
506bbf21555SRichard Lowe.Sx PCAGENT
507bbf21555SRichard Lowecontrol operation).
508bbf21555SRichard LoweIt is zero if there is no agent lwp in the process.
509bbf21555SRichard Lowe.Pp
510bbf21555SRichard Lowe.Sy pr_sigpend
511bbf21555SRichard Loweidentifies asynchronous signals pending for the process.
512bbf21555SRichard Lowe.Pp
513bbf21555SRichard Lowe.Sy pr_brkbase
514bbf21555SRichard Loweis the virtual address of the process heap and
515bbf21555SRichard Lowe.Sy pr_brksize
516bbf21555SRichard Loweis its size in bytes.
517bbf21555SRichard LoweThe address formed by the sum of these values is the process
518bbf21555SRichard Lowe.Sy break
519bbf21555SRichard Lowe(see
520bbf21555SRichard Lowe.Xr brk 2 ) .
521bbf21555SRichard Lowe.Sy pr_stkbase
522bbf21555SRichard Loweand
523bbf21555SRichard Lowe.Sy pr_stksize
524bbf21555SRichard Loweare, respectively, the virtual address of the process stack and its size in
525bbf21555SRichard Lowebytes.
526bbf21555SRichard Lowe(Each lwp runs on a separate stack; the distinguishing characteristic of the
527bbf21555SRichard Loweprocess stack is that the operating system will grow it when necessary.)
528bbf21555SRichard Lowe.Pp
529bbf21555SRichard Lowe.Sy pr_utime ,
530bbf21555SRichard Lowe.Sy pr_stime ,
531bbf21555SRichard Lowe.Sy pr_cutime ,
532bbf21555SRichard Lowe.Sy and pr_cstime
533bbf21555SRichard Loweare, respectively, the user
534bbf21555SRichard Lowe.Sy CPU
535bbf21555SRichard Loweand system
536bbf21555SRichard Lowe.Sy CPU
537bbf21555SRichard Lowetime consumed by the process, and the cumulative user
538bbf21555SRichard Lowe.Sy CPU
539bbf21555SRichard Loweand system
540bbf21555SRichard Lowe.Sy CPU
541bbf21555SRichard Lowetime consumed by the process's children, in seconds and nanoseconds.
542bbf21555SRichard Lowe.Pp
543bbf21555SRichard Lowe.Sy pr_sigtrace
544bbf21555SRichard Loweand
545bbf21555SRichard Lowe.Sy pr_flttrace
546bbf21555SRichard Lowecontain, respectively, the set of signals and the set of hardware faults that
547bbf21555SRichard Loweare being traced (see
548bbf21555SRichard Lowe.Sx PCSTRACE
549bbf21555SRichard Loweand
550bbf21555SRichard Lowe.Sx PCSFAULT ) .
551bbf21555SRichard Lowe.Pp
552bbf21555SRichard Lowe.Sy pr_sysentry
553bbf21555SRichard Loweand
554bbf21555SRichard Lowe.Sy pr_sysexit
555bbf21555SRichard Lowecontain, respectively, the sets of system calls being traced on entry and exit
556bbf21555SRichard Lowe(see
557bbf21555SRichard Lowe.Sx PCSENTRY
558bbf21555SRichard Loweand
559bbf21555SRichard Lowe.Sx PCSEXIT ) .
560bbf21555SRichard Lowe.Pp
561bbf21555SRichard Lowe.Sy pr_dmodel
562bbf21555SRichard Loweindicates the data model of the process.
563bbf21555SRichard LowePossible values are:
564bbf21555SRichard Lowe.Bl -tag -width "PR_MODEL_NATIVE" -offset indent
565bbf21555SRichard Lowe.It Sy PR_MODEL_ILP32
566bbf21555SRichard Loweprocess data model is ILP32.
567bbf21555SRichard Lowe.It Sy PR_MODEL_LP64
568bbf21555SRichard Loweprocess data model is LP64.
569bbf21555SRichard Lowe.It Sy PR_MODEL_NATIVE
570bbf21555SRichard Loweprocess data model is native.
571bbf21555SRichard Lowe.El
572bbf21555SRichard Lowe.Pp
573bbf21555SRichard LoweThe
574bbf21555SRichard Lowe.Sy pr_taskid ,
575bbf21555SRichard Lowe.Sy pr_projid ,
576bbf21555SRichard Loweand
577bbf21555SRichard Lowe.Sy pr_zoneid
578bbf21555SRichard Lowefields contain respectively, the numeric
579bbf21555SRichard Lowe.Sy ID Ns s
580bbf21555SRichard Loweof the task, project, and zone in which the process was running.
581bbf21555SRichard Lowe.Pp
582bbf21555SRichard LoweThe constant
583bbf21555SRichard Lowe.Sy PR_MODEL_NATIVE
584bbf21555SRichard Lowereflects the data model of the controlling process,
585bbf21555SRichard Lowe.Em that is ,
586bbf21555SRichard Loweits value is
587bbf21555SRichard Lowe.Sy PR_MODEL_ILP32
588bbf21555SRichard Loweor
589bbf21555SRichard Lowe.Sy PR_MODEL_LP64
590bbf21555SRichard Loweaccording to whether the controlling process has been
591bbf21555SRichard Lowecompiled as a 32-bit program or a 64-bit program, respectively.
592bbf21555SRichard Lowe.Pp
593bbf21555SRichard Lowe.Sy pr_lwp
594bbf21555SRichard Lowecontains the status information for the representative lwp:
595bbf21555SRichard Lowe.Bd -literal -offset 2
596bbf21555SRichard Lowetypedef struct lwpstatus {
597bbf21555SRichard Lowe  int pr_flags;              /* flags (see below) */
598bbf21555SRichard Lowe  id_t pr_lwpid;             /* specific lwp identifier */
599bbf21555SRichard Lowe  short pr_why;              /* reason for lwp stop, if stopped */
600bbf21555SRichard Lowe  short pr_what;             /* more detailed reason */
601bbf21555SRichard Lowe  short pr_cursig;           /* current signal, if any */
602bbf21555SRichard Lowe  siginfo_t pr_info;         /* info associated with signal or fault */
603bbf21555SRichard Lowe  sigset_t pr_lwppend;       /* set of signals pending to the lwp */
604bbf21555SRichard Lowe  sigset_t pr_lwphold;       /* set of signals blocked by the lwp */
605bbf21555SRichard Lowe  struct sigaction pr_action;/* signal action for current signal */
606bbf21555SRichard Lowe  stack_t pr_altstack;       /* alternate signal stack info */
607bbf21555SRichard Lowe  uintptr_t pr_oldcontext;   /* address of previous ucontext */
608bbf21555SRichard Lowe  short pr_syscall;          /* system call number (if in syscall) */
609bbf21555SRichard Lowe  short pr_nsysarg;          /* number of arguments to this syscall */
610bbf21555SRichard Lowe  int pr_errno;              /* errno for failed syscall */
611bbf21555SRichard Lowe  long pr_sysarg[PRSYSARGS]; /* arguments to this syscall */
612bbf21555SRichard Lowe  long pr_rval1;             /* primary syscall return value */
613bbf21555SRichard Lowe  long pr_rval2;             /* second syscall return value, if any */
614bbf21555SRichard Lowe  char pr_clname[PRCLSZ];    /* scheduling class name */
615bbf21555SRichard Lowe  timestruc_t pr_tstamp;     /* real-time time stamp of stop */
616bbf21555SRichard Lowe  timestruc_t pr_utime;      /* lwp user cpu time */
617bbf21555SRichard Lowe  timestruc_t pr_stime;      /* lwp system cpu time */
618bbf21555SRichard Lowe  uintptr_t pr_ustack;       /* stack boundary data (stack_t) address */
619bbf21555SRichard Lowe  ulong_t pr_instr;          /* current instruction */
620bbf21555SRichard Lowe  prgregset_t pr_reg;        /* general registers */
621bbf21555SRichard Lowe  prfpregset_t pr_fpreg;     /* floating-point registers */
622bbf21555SRichard Lowe} lwpstatus_t;
623bbf21555SRichard Lowe.Ed
624bbf21555SRichard Lowe.Pp
625bbf21555SRichard Lowe.Sy pr_flags
626bbf21555SRichard Loweis a bit-mask holding the following lwp flags.
627bbf21555SRichard LoweFor convenience, it also contains the process flags, described previously.
628bbf21555SRichard Lowe.Bl -tag -width "PR_STOPPED" -offset indent
629bbf21555SRichard Lowe.It Sy PR_STOPPED
630bbf21555SRichard LoweThe lwp is stopped.
631bbf21555SRichard Lowe.It Sy PR_ISTOP
632bbf21555SRichard LoweThe lwp is stopped on an event of interest (see
633bbf21555SRichard Lowe.Sx PCSTOP ) .
634bbf21555SRichard Lowe.It Sy PR_DSTOP
635bbf21555SRichard LoweThe lwp has a stop directive in effect (see
636bbf21555SRichard Lowe.Sx PCSTOP ) .
637bbf21555SRichard Lowe.It Sy PR_STEP
638bbf21555SRichard LoweThe lwp has a single-step directive in effect (see
639bbf21555SRichard Lowe.Sx PCRUN ) .
640bbf21555SRichard Lowe.It Sy PR_ASLEEP
641bbf21555SRichard LoweThe lwp is in an interruptible sleep within a system call.
642bbf21555SRichard Lowe.It Sy PR_PCINVAL
643bbf21555SRichard LoweThe lwp's current instruction
644bbf21555SRichard Lowe.Pq Sy pr_instr
645bbf21555SRichard Loweis undefined.
646bbf21555SRichard Lowe.It Sy PR_DETACH
647bbf21555SRichard LoweThis is a detached lwp (see
648bbf21555SRichard Lowe.Xr pthread_create 3C
649bbf21555SRichard Loweand
650bbf21555SRichard Lowe.Xr pthread_join 3C ) .
651bbf21555SRichard Lowe.It Sy PR_DAEMON
652bbf21555SRichard LoweThis is a daemon lwp (see
653bbf21555SRichard Lowe.Xr pthread_create 3C ) .
654bbf21555SRichard Lowe.It Sy PR_ASLWP
655bbf21555SRichard LoweThis flag is obsolete and is never set.
656bbf21555SRichard Lowe.It Sy PR_AGENT
657bbf21555SRichard LoweThis is the
658bbf21555SRichard Lowe.Pa /proc
659bbf21555SRichard Loweagent lwp for the process.
660bbf21555SRichard Lowe.El
661bbf21555SRichard Lowe.Pp
662bbf21555SRichard Lowe.Sy pr_lwpid
663bbf21555SRichard Lowenames the specific lwp.
664bbf21555SRichard Lowe.Pp
665bbf21555SRichard Lowe.Sy pr_why
666bbf21555SRichard Lowe.Sy and
667bbf21555SRichard Lowepr_what
668bbf21555SRichard Lowetogether describe, for a stopped lwp, the reason for the stop.
669bbf21555SRichard LowePossible values of
670bbf21555SRichard Lowe.Sy pr_why
671bbf21555SRichard Loweand the associated
672bbf21555SRichard Lowe.Sy pr_what
673bbf21555SRichard Loweare:
674bbf21555SRichard Lowe.Bl -tag -width "PR_JOBCONTROL" -offset left
675bbf21555SRichard Lowe.It Sy PR_REQUESTED
676bbf21555SRichard Loweindicates that the stop occurred in response to a stop directive, normally
677bbf21555SRichard Lowebecause
678bbf21555SRichard Lowe.Sy PCSTOP
679bbf21555SRichard Lowewas applied or because another lwp stopped on an event of interest and the
680bbf21555SRichard Loweasynchronous-stop flag (see
681bbf21555SRichard Lowe.Sx PCSET )
682bbf21555SRichard Lowewas not set for the process.
683bbf21555SRichard Lowe.Sy pr_what
684bbf21555SRichard Loweis unused in this case.
685bbf21555SRichard Lowe.It Sy PR_SIGNALLED
686bbf21555SRichard Loweindicates that the lwp stopped on receipt of a signal (see
687bbf21555SRichard Lowe.Sx PCSTRACE ) ;
688bbf21555SRichard Lowe.Sy pr_what
689bbf21555SRichard Loweholds the signal number that caused the stop (for a newly-stopped
690bbf21555SRichard Lowelwp, the same value is in
691bbf21555SRichard Lowe.Sy pr_cursig ) .
692bbf21555SRichard Lowe.It Sy PR_FAULTED
693bbf21555SRichard Loweindicates that the lwp stopped on incurring a hardware fault (see
694bbf21555SRichard Lowe.Sx PCSFAULT ) ;
695bbf21555SRichard Lowe.Sy pr_what
696bbf21555SRichard Loweholds the fault number that caused the stop.
697bbf21555SRichard Lowe.It Sy PR_SYSENTRY
698bbf21555SRichard Lowe.It Sy PR_SYSEXIT
699bbf21555SRichard Loweindicate a stop on entry to or exit from a system call (see
700bbf21555SRichard Lowe.Sx PCSENTRY
701bbf21555SRichard Loweand
702bbf21555SRichard Lowe.Sx PCSEXIT ) ;
703bbf21555SRichard Lowe.Sy pr_what
704bbf21555SRichard Loweholds the system call number.
705bbf21555SRichard Lowe.It Sy PR_JOBCONTROL
706bbf21555SRichard Loweindicates that the lwp stopped due to the default action of a job control stop
707bbf21555SRichard Lowesignal (see
708bbf21555SRichard Lowe.Xr sigaction 2 ) ;
709bbf21555SRichard Lowe.Sy pr_what
710bbf21555SRichard Loweholds the stopping signal number.
711bbf21555SRichard Lowe.It Sy PR_SUSPENDED
712bbf21555SRichard Loweindicates that the lwp stopped due to internal synchronization of lwps within
713bbf21555SRichard Lowethe process.
714bbf21555SRichard Lowe.Sy pr_what
715bbf21555SRichard Loweis unused in this case.
716bbf21555SRichard Lowe.El
717bbf21555SRichard Lowe.Pp
718bbf21555SRichard Lowe.Sy pr_cursig
719bbf21555SRichard Lowenames the current signal, that is, the next signal to be delivered to the lwp,
720bbf21555SRichard Loweif any.
721bbf21555SRichard Lowe.Sy pr_info ,
722bbf21555SRichard Lowewhen the lwp is in a
723bbf21555SRichard Lowe.Sy PR_SIGNALLED
724bbf21555SRichard Loweor
725bbf21555SRichard Lowe.Sy PR_FAULTED
726bbf21555SRichard Lowestop, contains additional information pertinent to the particular signal or
727bbf21555SRichard Lowefault (see
728bbf21555SRichard Lowe.In sys/siginfo.h ) .
729bbf21555SRichard Lowe.Pp
730bbf21555SRichard Lowe.Sy pr_lwppend
731bbf21555SRichard Loweidentifies any synchronous or directed signals pending for the lwp.
732bbf21555SRichard Lowe.Sy pr_lwphold
733bbf21555SRichard Loweidentifies those signals whose delivery is being blocked by the lwp (the
734bbf21555SRichard Lowesignal mask).
735bbf21555SRichard Lowe.Pp
736bbf21555SRichard Lowe.Sy pr_action
737bbf21555SRichard Lowecontains the signal action information pertaining to the current signal (see
738bbf21555SRichard Lowe.Xr sigaction 2 ) ;
739bbf21555SRichard Loweit is undefined if
740bbf21555SRichard Lowe.Sy pr_cursig
741bbf21555SRichard Loweis zero.
742bbf21555SRichard Lowe.Sy pr_altstack
743bbf21555SRichard Lowecontains the alternate signal stack information for the lwp (see
744bbf21555SRichard Lowe.Xr sigaltstack 2 ) .
745bbf21555SRichard Lowe.Pp
746bbf21555SRichard Lowe.Sy pr_oldcontext ,
747bbf21555SRichard Loweif not zero, contains the address on the lwp stack of a
748bbf21555SRichard Lowe.Sy ucontext
749bbf21555SRichard Lowestructure describing the previous user-level context (see
750bbf21555SRichard Lowe.Xr ucontext.h 3HEAD ) .
751bbf21555SRichard LoweIt is non-zero only if the lwp is executing in the context of a signal handler.
752bbf21555SRichard Lowe.Pp
753bbf21555SRichard Lowe.Sy pr_syscall
754bbf21555SRichard Loweis the number of the system call, if any, being executed by
755bbf21555SRichard Lowethe lwp; it is non-zero if and only if the lwp is stopped on
756bbf21555SRichard Lowe.Sy PR_SYSENTRY
757bbf21555SRichard Loweor
758bbf21555SRichard Lowe.Sy PR_SYSEXIT ,
759bbf21555SRichard Loweor is asleep within a system call
760bbf21555SRichard Lowe.Pf ( Sy PR_ASLEEP
761bbf21555SRichard Loweis set).
762bbf21555SRichard LoweIf
763bbf21555SRichard Lowe.Sy pr_syscall
764bbf21555SRichard Loweis non-zero,
765bbf21555SRichard Lowe.Sy pr_nsysarg
766bbf21555SRichard Loweis the number of arguments to the system call and
767bbf21555SRichard Lowe.Sy pr_sysarg
768bbf21555SRichard Lowecontains the actual arguments.
769bbf21555SRichard Lowe.Pp
770bbf21555SRichard Lowe.Sy pr_rval1 ,
771bbf21555SRichard Lowe.Sy pr_rval2 ,
772bbf21555SRichard Loweand
773bbf21555SRichard Lowe.Sy pr_errno
774bbf21555SRichard Loweare defined only if the lwp
775bbf21555SRichard Loweis stopped on
776bbf21555SRichard Lowe.Sy PR_SYSEXIT
777bbf21555SRichard Loweor if the
778bbf21555SRichard Lowe.Sy PR_VFORKP
779bbf21555SRichard Loweflag is set.
780bbf21555SRichard LoweIf
781bbf21555SRichard Lowe.Sy pr_errno
782bbf21555SRichard Loweis zero,
783bbf21555SRichard Lowe.Sy pr_rval1
784bbf21555SRichard Loweand
785bbf21555SRichard Lowe.Sy pr_rval2
786bbf21555SRichard Lowecontain the return values from the system call.
787bbf21555SRichard LoweOtherwise,
788bbf21555SRichard Lowe.Sy pr_errno
789bbf21555SRichard Lowecontains the error number for the failing system call (see
790bbf21555SRichard Lowe.In sys/errno.h ) .
791bbf21555SRichard Lowe.Pp
792bbf21555SRichard Lowe.Sy pr_clname
793bbf21555SRichard Lowecontains the name of the lwp's scheduling class.
794bbf21555SRichard Lowe.Pp
795bbf21555SRichard Lowe.Sy pr_tstamp ,
796bbf21555SRichard Loweif the lwp is stopped, contains a time stamp marking when the
797bbf21555SRichard Lowelwp stopped, in real time seconds and nanoseconds since an arbitrary time in
798bbf21555SRichard Lowethe past.
799bbf21555SRichard Lowe.Pp
800bbf21555SRichard Lowe.Sy pr_utime
801bbf21555SRichard Loweis the amount of user level CPU time used by this LWP.
802bbf21555SRichard Lowe.Pp
803bbf21555SRichard Lowe.Sy pr_stime
804bbf21555SRichard Loweis the amount of system level CPU time used by this LWP.
805bbf21555SRichard Lowe.Pp
806bbf21555SRichard Lowe.Sy pr_ustack
807bbf21555SRichard Loweis the virtual address of the
808bbf21555SRichard Lowe.Sy stack_t
809bbf21555SRichard Lowethat contains the stack boundaries for this LWP.
810bbf21555SRichard LoweSee
811bbf21555SRichard Lowe.Xr getustack 2
812bbf21555SRichard Loweand
813bbf21555SRichard Lowe.Xr _stack_grow 3C .
814bbf21555SRichard Lowe.Pp
815bbf21555SRichard Lowe.Sy pr_instr
816bbf21555SRichard Lowecontains the machine instruction to which the lwp's program counter refers.
817bbf21555SRichard LoweThe amount of data retrieved from the process is machine-dependent.
818bbf21555SRichard LoweOn SPARC based machines, it is a 32-bit word.
819bbf21555SRichard LoweOn x86-based machines, it is a single byte.
820bbf21555SRichard LoweIn general, the size is that of the machine's smallest instruction.
821bbf21555SRichard LoweIf
822bbf21555SRichard Lowe.Sy PR_PCINVAL
823bbf21555SRichard Loweis set,
824bbf21555SRichard Lowe.Sy pr_instr
825bbf21555SRichard Loweis undefined; this occurs whenever the lwp is not stopped or when the program
826bbf21555SRichard Lowecounter refers to an invalid virtual address.
827bbf21555SRichard Lowe.Pp
828bbf21555SRichard Lowe.Sy pr_reg
829bbf21555SRichard Loweis an array holding the contents of a stopped lwp's general registers.
830bbf21555SRichard Lowe.Bl -tag -offset left -width "SPARC V8 (32-bit)"
831bbf21555SRichard Lowe.It Sy SPARC
832bbf21555SRichard LoweOn SPARC-based machines, the predefined constants
833bbf21555SRichard Lowe.Sy R_G0
834bbf21555SRichard Lowe\&.\&.\&.
835bbf21555SRichard Lowe.Sy R_G7 ,
836bbf21555SRichard Lowe.Sy R_O0
837bbf21555SRichard Lowe\&.\&.\&.
838bbf21555SRichard Lowe.Sy R_O7 ,
839bbf21555SRichard Lowe.Sy R_L0
840bbf21555SRichard Lowe\&.\&.\&.
841bbf21555SRichard Lowe.Sy R_L7 ,
842bbf21555SRichard Lowe.Sy R_I0
843bbf21555SRichard Lowe\&.\&.\&.
844bbf21555SRichard Lowe.Sy R_I7 ,
845bbf21555SRichard Lowe.Sy R_PC ,
846bbf21555SRichard Lowe.Sy R_nPC ,
847bbf21555SRichard Loweand
848bbf21555SRichard Lowe.Sy R_Y
849bbf21555SRichard Lowecan be used as indices to refer to the corresponding registers; previous
850bbf21555SRichard Loweregister windows can be read from their overflow locations on the stack
851bbf21555SRichard Lowe(however, see the
852bbf21555SRichard Lowe.Pa gwindows
853bbf21555SRichard Lowefile in the
854bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid
855bbf21555SRichard Lowesubdirectory).
856bbf21555SRichard Lowe.It Sy SPARC V8 (32-bit)
857bbf21555SRichard LoweFor SPARC V8 (32-bit) controlling processes, the predefined constants
858bbf21555SRichard Lowe.Sy R_PSR ,
859bbf21555SRichard Lowe.Sy R_WIM ,
860bbf21555SRichard Loweand
861bbf21555SRichard Lowe.Sy R_TBR
862bbf21555SRichard Lowecan be used as indices to refer to the corresponding special registers.
863bbf21555SRichard LoweFor SPARC V9 (64-bit) controlling processes, the predefined constants
864bbf21555SRichard Lowe.Sy R_CCR ,
865bbf21555SRichard Lowe.Sy R_ASI ,
866bbf21555SRichard Loweand
867bbf21555SRichard Lowe.Sy R_FPRS
868bbf21555SRichard Lowecan be used as indices to refer to the corresponding special registers.
869bbf21555SRichard Lowe.It Sy x86 (32-bit)
870bbf21555SRichard LoweFor 32-bit x86 processes, the predefined constants listed belowcan be used as
871bbf21555SRichard Loweindices to refer to the corresponding registers.
872bbf21555SRichard Lowe.Bl -tag -width "TRAPNO" -offset indent -compact
873bbf21555SRichard Lowe.It SS
874bbf21555SRichard Lowe.It UESP
875bbf21555SRichard Lowe.It EFL
876bbf21555SRichard Lowe.It CS
877bbf21555SRichard Lowe.It EIP
878bbf21555SRichard Lowe.It ERR
879bbf21555SRichard Lowe.It TRAPNO
880bbf21555SRichard Lowe.It EAX
881bbf21555SRichard Lowe.It ECX
882bbf21555SRichard Lowe.It EDX
883bbf21555SRichard Lowe.It EBX
884bbf21555SRichard Lowe.It ESP
885bbf21555SRichard Lowe.It EBP
886bbf21555SRichard Lowe.It ESI
887bbf21555SRichard Lowe.It EDI
888bbf21555SRichard Lowe.It DS
889bbf21555SRichard Lowe.It ES
890bbf21555SRichard Lowe.It GS
891bbf21555SRichard Lowe.El
892bbf21555SRichard Lowe.Pp
893bbf21555SRichard LoweThe preceding constants are listed in
894bbf21555SRichard Lowe.In sys/regset.h .
895bbf21555SRichard Lowe.Pp
896bbf21555SRichard LoweNote that a 32-bit process can run on an x86 64-bit system, using the constants
897bbf21555SRichard Lowelisted above.
898bbf21555SRichard Lowe.It Sy x86 (64-bit)
899bbf21555SRichard LoweTo read the registers of a 32-
900bbf21555SRichard Lowe.Em or
901bbf21555SRichard Lowea 64-bit process, a 64-bit x86 process should use the predefined constants
902bbf21555SRichard Lowelisted below.
903bbf21555SRichard Lowe.Bl -tag -width "REG_TRAPNO" -offset indent -compact
904bbf21555SRichard Lowe.It REG_GSBASE
905bbf21555SRichard Lowe.It REG_FSBASE
906bbf21555SRichard Lowe.It REG_DS
907bbf21555SRichard Lowe.It REG_ES
908bbf21555SRichard Lowe.It REG_GS
909bbf21555SRichard Lowe.It REG_FS
910bbf21555SRichard Lowe.It REG_SS
911bbf21555SRichard Lowe.It REG_RSP
912bbf21555SRichard Lowe.It REG_RFL
913bbf21555SRichard Lowe.It REG_CS
914bbf21555SRichard Lowe.It REG_RIP
915bbf21555SRichard Lowe.It REG_ERR
916bbf21555SRichard Lowe.It REG_TRAPNO
917bbf21555SRichard Lowe.It REG_RAX
918bbf21555SRichard Lowe.It REG_RCX
919bbf21555SRichard Lowe.It REG_RDX
920bbf21555SRichard Lowe.It REG_RBX
921bbf21555SRichard Lowe.It REG_RBP
922bbf21555SRichard Lowe.It REG_RSI
923bbf21555SRichard Lowe.It REG_RDI
924bbf21555SRichard Lowe.It REG_R8
925bbf21555SRichard Lowe.It REG_R9
926bbf21555SRichard Lowe.It REG_R10
927bbf21555SRichard Lowe.It REG_R11
928bbf21555SRichard Lowe.It REG_R12
929bbf21555SRichard Lowe.It REG_R13
930bbf21555SRichard Lowe.It REG_R14
931bbf21555SRichard Lowe.It REG_R15
932bbf21555SRichard Lowe.El
933bbf21555SRichard Lowe.Pp
934bbf21555SRichard LoweThe preceding constants are listed in
935bbf21555SRichard Lowe.In sys/regset.h .
936bbf21555SRichard Lowe.El
937bbf21555SRichard Lowe.Pp
938bbf21555SRichard Lowe.Sy pr_fpreg
939bbf21555SRichard Loweis a structure holding the contents of the floating-point registers.
940bbf21555SRichard Lowe.Pp
941bbf21555SRichard LoweSPARC registers, both general and floating-point, as seen by a 64-bit
942bbf21555SRichard Lowecontrolling process are the V9 versions of the registers, even if the target
943bbf21555SRichard Loweprocess is a 32-bit (V8) process.
944bbf21555SRichard LoweV8 registers are a subset of the V9 registers.
945bbf21555SRichard Lowe.Pp
946bbf21555SRichard LoweIf the lwp is not stopped, all register values are undefined.
947bbf21555SRichard Lowe.Ss psinfo
948bbf21555SRichard LoweContains miscellaneous information about the process and the representative lwp
949bbf21555SRichard Loweneeded by the
950bbf21555SRichard Lowe.Xr ps 1
951bbf21555SRichard Lowecommand.
952bbf21555SRichard Lowe.Sy psinfo
953bbf21555SRichard Loweremains accessible after a process becomes a
954bbf21555SRichard Lowe.Em zombie .
955bbf21555SRichard LoweThe file contains a
956bbf21555SRichard Lowe.Sy psinfo
957bbf21555SRichard Lowestructure which contains an embedded
958bbf21555SRichard Lowe.Sy lwpsinfo
959bbf21555SRichard Lowestructure for the representative lwp, as follows:
960bbf21555SRichard Lowe.Bd -literal -offset 2
961bbf21555SRichard Lowetypedef struct psinfo {
962bbf21555SRichard Lowe    int pr_flag;             /* process flags (DEPRECATED: see below) */
963bbf21555SRichard Lowe    int pr_nlwp;             /* number of active lwps in the process */
964bbf21555SRichard Lowe    int pr_nzomb;            /* number of zombie lwps in the process */
965bbf21555SRichard Lowe    pid_t pr_pid;            /* process id */
966bbf21555SRichard Lowe    pid_t pr_ppid;           /* process id of parent */
967bbf21555SRichard Lowe    pid_t pr_pgid;           /* process id of process group leader */
968bbf21555SRichard Lowe    pid_t pr_sid;            /* session id */
969bbf21555SRichard Lowe    uid_t pr_uid;            /* real user id */
970bbf21555SRichard Lowe    uid_t pr_euid;           /* effective user id */
971bbf21555SRichard Lowe    gid_t pr_gid;            /* real group id */
972bbf21555SRichard Lowe    gid_t pr_egid;           /* effective group id */
973bbf21555SRichard Lowe    uintptr_t pr_addr;       /* address of process */
974bbf21555SRichard Lowe    size_t pr_size;          /* size of process image in Kbytes */
975bbf21555SRichard Lowe    size_t pr_rssize;        /* resident set size in Kbytes */
976bbf21555SRichard Lowe    dev_t pr_ttydev;         /* controlling tty device (or PRNODEV) */
977bbf21555SRichard Lowe    ushort_t pr_pctcpu;      /* % of recent cpu time used by all lwps */
978bbf21555SRichard Lowe    ushort_t pr_pctmem;      /* % of system memory used by process */
979bbf21555SRichard Lowe    timestruc_t pr_start;    /* process start time, from the epoch */
980bbf21555SRichard Lowe    timestruc_t pr_time;     /* cpu time for this process */
981bbf21555SRichard Lowe    timestruc_t pr_ctime;    /* cpu time for reaped children */
982bbf21555SRichard Lowe    char pr_fname[PRFNSZ];   /* name of exec'ed file */
983bbf21555SRichard Lowe    char pr_psargs[PRARGSZ]; /* initial characters of arg list */
984bbf21555SRichard Lowe    int pr_wstat;            /* if zombie, the wait() status */
985bbf21555SRichard Lowe    int pr_argc;             /* initial argument count */
986bbf21555SRichard Lowe    uintptr_t pr_argv;       /* address of initial argument vector */
987bbf21555SRichard Lowe    uintptr_t pr_envp;       /* address of initial environment vector */
988bbf21555SRichard Lowe    char pr_dmodel;          /* data model of the process */
989bbf21555SRichard Lowe    taskid_t pr_taskid;      /* task id */
990bbf21555SRichard Lowe    projid_t pr_projid;      /* project id */
991bbf21555SRichard Lowe    poolid_t pr_poolid;      /* pool id */
992bbf21555SRichard Lowe    zoneid_t pr_zoneid;      /* zone id */
993bbf21555SRichard Lowe    ctid_t pr_contract;      /* process contract id */
994bbf21555SRichard Lowe    lwpsinfo_t pr_lwp;       /* information for representative lwp */
995bbf21555SRichard Lowe} psinfo_t;
996bbf21555SRichard Lowe.Ed
997bbf21555SRichard Lowe.Pp
998bbf21555SRichard LoweSome of the entries in
999bbf21555SRichard Lowe.Sy psinfo ,
1000bbf21555SRichard Lowesuch as
1001bbf21555SRichard Lowe.Sy pr_addr ,
1002bbf21555SRichard Lowerefer to internal kernel data structures and should not be expected to retain
1003bbf21555SRichard Lowetheir meanings across different versions of the operating system.
1004bbf21555SRichard Lowe.Pp
1005bbf21555SRichard Lowe.Sy psinfo_t.pr_flag
1006bbf21555SRichard Loweis a deprecated interface that should no longer be used.
1007bbf21555SRichard LoweApplications currently relying on the
1008bbf21555SRichard Lowe.Sy SSYS
1009bbf21555SRichard Lowebit in
1010bbf21555SRichard Lowe.Sy pr_flag
1011bbf21555SRichard Loweshould migrate to checking
1012bbf21555SRichard Lowe.Sy PR_ISSYS
1013bbf21555SRichard Lowein the
1014bbf21555SRichard Lowe.Sy pstatus
1015bbf21555SRichard Lowestructure's
1016bbf21555SRichard Lowe.Sy pr_flags
1017bbf21555SRichard Lowefield.
1018bbf21555SRichard Lowe.Pp
1019bbf21555SRichard Lowe.Sy pr_pctcpu
1020bbf21555SRichard Loweand
1021bbf21555SRichard Lowe.Sy pr_pctmem
1022bbf21555SRichard Loweare 16-bit binary fractions in the range 0.0 to 1.0 with the binary point to
1023bbf21555SRichard Lowethe right of the high-order bit (1.0 == 0x8000).
1024bbf21555SRichard Lowe.Sy pr_pctcpu
1025bbf21555SRichard Loweis the summation over all lwps in the process.
1026bbf21555SRichard Lowe.Pp
1027bbf21555SRichard Lowe.Sy pr_lwp
1028bbf21555SRichard Lowecontains the
1029bbf21555SRichard Lowe.Xr ps 1
1030bbf21555SRichard Loweinformation for the representative lwp.
1031bbf21555SRichard LoweIf the process is a
1032bbf21555SRichard Lowe.Em zombie ,
1033bbf21555SRichard Lowe.Sy pr_nlwp ,
1034bbf21555SRichard Lowe.Sy pr_nzomb ,
1035bbf21555SRichard Loweand
1036bbf21555SRichard Lowe.Sy pr_lwp.pr_lwpid
1037bbf21555SRichard Loweare zero and the other fields of
1038bbf21555SRichard Lowe.Sy pr_lwp
1039bbf21555SRichard Loweare undefined:
1040bbf21555SRichard Lowe.Bd -literal -offset 2
1041bbf21555SRichard Lowetypedef struct lwpsinfo {
1042bbf21555SRichard Lowe    int pr_flag;             /* lwp flags (DEPRECATED: see below) */
1043bbf21555SRichard Lowe    id_t pr_lwpid;           /* lwp id */
1044bbf21555SRichard Lowe    uintptr_t pr_addr;       /* internal address of lwp */
1045bbf21555SRichard Lowe    uintptr_t pr_wchan;      /* wait addr for sleeping lwp */
1046bbf21555SRichard Lowe    char pr_stype;           /* synchronization event type */
1047bbf21555SRichard Lowe    char pr_state;           /* numeric lwp state */
1048bbf21555SRichard Lowe    char pr_sname;           /* printable character for pr_state */
1049bbf21555SRichard Lowe    char pr_nice;            /* nice for cpu usage */
1050bbf21555SRichard Lowe    short pr_syscall;        /* system call number (if in syscall) */
1051bbf21555SRichard Lowe    char pr_oldpri;          /* pre-SVR4, low value is high priority */
1052bbf21555SRichard Lowe    char pr_cpu;             /* pre-SVR4, cpu usage for scheduling */
1053bbf21555SRichard Lowe    int pr_pri;              /* priority, high value = high priority */
1054bbf21555SRichard Lowe    ushort_t pr_pctcpu;      /* % of recent cpu time used by this lwp */
1055bbf21555SRichard Lowe    timestruc_t pr_start;    /* lwp start time, from the epoch */
1056bbf21555SRichard Lowe    timestruc_t pr_time;     /* cpu time for this lwp */
1057bbf21555SRichard Lowe    char pr_clname[PRCLSZ];  /* scheduling class name */
1058bbf21555SRichard Lowe    char pr_name[PRFNSZ];    /* name of system lwp */
1059bbf21555SRichard Lowe    processorid_t pr_onpro;  /* processor which last ran this lwp */
1060bbf21555SRichard Lowe    processorid_t pr_bindpro;/* processor to which lwp is bound */
1061bbf21555SRichard Lowe    psetid_t pr_bindpset;    /* processor set to which lwp is bound */
1062bbf21555SRichard Lowe    lgrp_id_t pr_lgrp;       /* home lgroup */
1063bbf21555SRichard Lowe} lwpsinfo_t;
1064bbf21555SRichard Lowe.Ed
1065bbf21555SRichard Lowe.Pp
1066bbf21555SRichard LoweSome of the entries in
1067bbf21555SRichard Lowe.Sy lwpsinfo ,
1068bbf21555SRichard Lowesuch as
1069bbf21555SRichard Lowe.Sy pr_addr ,
1070bbf21555SRichard Lowe.Sy pr_wchan ,
1071bbf21555SRichard Lowe.Sy pr_stype ,
1072bbf21555SRichard Lowe.Sy pr_state ,
1073bbf21555SRichard Loweand
1074bbf21555SRichard Lowe.Sy pr_name ,
1075bbf21555SRichard Lowerefer to internal kernel data structures and should not be expected to retain
1076bbf21555SRichard Lowetheir meanings across different versions of the operating system.
1077bbf21555SRichard Lowe.Pp
1078bbf21555SRichard Lowe.Sy lwpsinfo_t.pr_flag
1079bbf21555SRichard Loweis a deprecated interface that should no longer be used.
1080bbf21555SRichard Lowe.Pp
1081bbf21555SRichard Lowe.Sy pr_pctcpu
1082bbf21555SRichard Loweis a 16-bit binary fraction, as described above.
1083bbf21555SRichard LoweIt represents the
1084bbf21555SRichard Lowe.Sy CPU
1085bbf21555SRichard Lowetime used by the specific lwp.
1086bbf21555SRichard LoweOn a multi-processor machine, the maximum value is 1/N, where N is the number
1087bbf21555SRichard Loweof
1088bbf21555SRichard Lowe.Sy CPU Ns s .
1089bbf21555SRichard Lowe.Pp
1090bbf21555SRichard Lowe.Sy pr_contract
1091bbf21555SRichard Loweis the id of the process contract of which the process is a member.
1092bbf21555SRichard LoweSee
1093bbf21555SRichard Lowe.Xr contract 5
1094bbf21555SRichard Loweand
1095bbf21555SRichard Lowe.Xr process 5 .
1096bbf21555SRichard Lowe.Ss cred
1097bbf21555SRichard LoweContains a description of the credentials associated with the process:
1098bbf21555SRichard Lowe.Bd -literal -offset 2
1099bbf21555SRichard Lowetypedef struct prcred {
1100bbf21555SRichard Lowe	uid_t pr_euid;      /* effective user id */
1101bbf21555SRichard Lowe	uid_t pr_ruid;      /* real user id */
1102bbf21555SRichard Lowe	uid_t pr_suid;      /* saved user id (from exec) */
1103bbf21555SRichard Lowe	gid_t pr_egid;      /* effective group id */
1104bbf21555SRichard Lowe	gid_t pr_rgid;      /* real group id */
1105bbf21555SRichard Lowe	gid_t pr_sgid;      /* saved group id (from exec) */
1106bbf21555SRichard Lowe	int pr_ngroups;     /* number of supplementary groups */
1107bbf21555SRichard Lowe	gid_t pr_groups[1]; /* array of supplementary groups */
1108bbf21555SRichard Lowe} prcred_t;
1109bbf21555SRichard Lowe.Ed
1110bbf21555SRichard Lowe.Pp
1111bbf21555SRichard LoweThe array of associated supplementary groups in
1112bbf21555SRichard Lowe.Sy pr_groups
1113bbf21555SRichard Lowe is of variable
1114bbf21555SRichard Lowelength; the
1115bbf21555SRichard Lowe.Sy cred
1116bbf21555SRichard Lowefile contains all of the supplementary groups.
1117bbf21555SRichard Lowe.Sy pr_ngroups
1118bbf21555SRichard Loweindicates the number of supplementary groups. (See also the
1119bbf21555SRichard Lowe.Sy PCSCRED
1120bbf21555SRichard Loweand
1121bbf21555SRichard Lowe.Sy PCSCREDX
1122bbf21555SRichard Lowecontrol operations.)
1123bbf21555SRichard Lowe.Ss priv
1124bbf21555SRichard LoweContains a description of the privileges associated with the process:
1125bbf21555SRichard Lowe.Bd -literal -offset 2
1126bbf21555SRichard Lowetypedef struct prpriv {
1127bbf21555SRichard Lowe     uint32_t        pr_nsets;      /* number of privilege set */
1128bbf21555SRichard Lowe     uint32_t        pr_setsize;    /* size of privilege set */
1129bbf21555SRichard Lowe     uint32_t        pr_infosize;   /* size of supplementary data */
1130bbf21555SRichard Lowe     priv_chunk_t    pr_sets[1];    /* array of sets */
1131bbf21555SRichard Lowe} prpriv_t;
1132bbf21555SRichard Lowe.Ed
1133bbf21555SRichard Lowe.Pp
1134bbf21555SRichard LoweThe actual dimension of the
1135bbf21555SRichard Lowe.Sy pr_sets Ns []
1136bbf21555SRichard Lowefield is
1137bbf21555SRichard Lowe.D1 pr_sets[pr_nsets][pr_setsize]
1138bbf21555SRichard Lowe.Pp
1139bbf21555SRichard Lowewhich is followed by additional information about the process state
1140bbf21555SRichard Lowe.Sy pr_infosize
1141bbf21555SRichard Lowebytes in size.
1142bbf21555SRichard Lowe.Pp
1143bbf21555SRichard LoweThe full size of the structure can be computed using
1144bbf21555SRichard Lowe.Fn PRIV_PRPRIV_SIZE "prpriv_t *" .
1145bbf21555SRichard Lowe.Ss secflags
1146bbf21555SRichard LoweThis file contains the security-flags of the process.
1147bbf21555SRichard LoweIt contains a description of the security flags associated with the process.
1148bbf21555SRichard Lowe.Bd -literal -offset 2
1149bbf21555SRichard Lowetypedef struct prsecflags {
1150bbf21555SRichard Lowe	uint32_t pr_version;		/* ABI Versioning of this structure */
1151bbf21555SRichard Lowe	secflagset_t pr_effective;	/* Effective flags */
1152bbf21555SRichard Lowe	secflagset_t pr_inherit;	/* Inheritable flags */
1153bbf21555SRichard Lowe	secflagset_t pr_lower;		/* Lower flags */
1154bbf21555SRichard Lowe	secflagset_t pr_upper;		/* Upper flags */
1155bbf21555SRichard Lowe} prsecflags_t;
1156bbf21555SRichard Lowe.Ed
1157bbf21555SRichard Lowe.Pp
1158bbf21555SRichard LoweThe
1159bbf21555SRichard Lowe.Sy pr_version
1160bbf21555SRichard Lowefield is a version number for the structure, currently
1161bbf21555SRichard Lowe.Sy PRSECFLAGS_VERSION_1 .
1162bbf21555SRichard Lowe.Ss sigact
1163bbf21555SRichard LoweContains an array of
1164bbf21555SRichard Lowe.Sy sigaction structures
1165bbf21555SRichard Lowedescribing the current dispositions of all signals associated with the traced
1166bbf21555SRichard Loweprocess (see
1167bbf21555SRichard Lowe.Xr sigaction 2 ) .
1168bbf21555SRichard LoweSignal numbers are displaced by 1 from array indices, so that the action for
1169bbf21555SRichard Lowesignal number
1170bbf21555SRichard Lowe.Va n
1171bbf21555SRichard Loweappears in position
1172bbf21555SRichard Lowe.Va n Ns -1
1173bbf21555SRichard Loweof the array.
1174bbf21555SRichard Lowe.Ss auxv
1175bbf21555SRichard LoweContains the initial values of the process's aux vector in an array of
1176bbf21555SRichard Lowe.Sy auxv_t
1177bbf21555SRichard Lowestructures (see
1178bbf21555SRichard Lowe.In sys/auxv.h ) .
1179bbf21555SRichard LoweThe values are those that were passed by the operating system as startup
1180bbf21555SRichard Loweinformation to the dynamic linker.
1181bbf21555SRichard Lowe.Ss ldt
1182bbf21555SRichard LoweThis file exists only on x86-based machines.
1183bbf21555SRichard LoweIt is non-empty only if the process has established a local descriptor table
1184bbf21555SRichard Lowe.Pq Sy LDT .
1185bbf21555SRichard LoweIf non-empty, the file contains the array of currently active
1186bbf21555SRichard Lowe.Sy LDT
1187bbf21555SRichard Loweentries in an array of elements of type
1188bbf21555SRichard Lowe.Vt struct ssd ,
1189bbf21555SRichard Lowedefined in
1190bbf21555SRichard Lowe.In sys/sysi86.h ,
1191bbf21555SRichard Loweone element for each active
1192bbf21555SRichard Lowe.Sy LDT
1193bbf21555SRichard Loweentry.
1194bbf21555SRichard Lowe.Ss map, xmap
1195bbf21555SRichard LoweContain information about the virtual address map of the process.
1196bbf21555SRichard LoweThe map file contains an array of
1197bbf21555SRichard Lowe.Sy prmap
1198bbf21555SRichard Lowestructures while the xmap file contains an
1199bbf21555SRichard Lowearray of
1200bbf21555SRichard Lowe.Sy prxmap
1201bbf21555SRichard Lowestructures.
1202bbf21555SRichard LoweEach structure describes a contiguous virtual
1203bbf21555SRichard Loweaddress region in the address space of the traced process:
1204bbf21555SRichard Lowe.Bd -literal -offset 2
1205bbf21555SRichard Lowetypedef struct prmap {
1206bbf21555SRichard Lowe	uintptr_tpr_vaddr;         /* virtual address of mapping */
1207bbf21555SRichard Lowe	size_t pr_size;            /* size of mapping in bytes */
1208bbf21555SRichard Lowe	char pr_mapname[PRMAPSZ];  /* name in /proc/pid/object */
1209bbf21555SRichard Lowe	offset_t pr_offset;        /* offset into mapped object, if any */
1210bbf21555SRichard Lowe	int pr_mflags;             /* protection and attribute flags */
1211bbf21555SRichard Lowe	int pr_pagesize;           /* pagesize for this mapping in bytes */
1212bbf21555SRichard Lowe	int pr_shmid;              /* SysV shared memory identifier */
1213bbf21555SRichard Lowe} prmap_t;
1214bbf21555SRichard Lowe.Ed
1215bbf21555SRichard Lowe.Bd -literal -offset 2
1216bbf21555SRichard Lowetypedef struct prxmap {
1217bbf21555SRichard Lowe	uintptr_t pr_vaddr;        /* virtual address of mapping */
1218bbf21555SRichard Lowe	size_t pr_size;            /* size of mapping in bytes */
1219bbf21555SRichard Lowe	char pr_mapname[PRMAPSZ];  /* name in /proc/pid/object */
1220bbf21555SRichard Lowe	offset_t pr_offset;        /* offset into mapped object, if any */
1221bbf21555SRichard Lowe	int pr_mflags;             /* protection and attribute flags */
1222bbf21555SRichard Lowe	int pr_pagesize;           /* pagesize for this mapping in bytes */
1223bbf21555SRichard Lowe	int pr_shmid;              /* SysV shared memory identifier */
1224bbf21555SRichard Lowe	dev_t pr_dev;              /* device of mapped object, if any */
1225bbf21555SRichard Lowe	uint64_t pr_ino;           /* inode of mapped object, if any */
1226bbf21555SRichard Lowe	size_t pr_rss;             /* pages of resident memory */
1227bbf21555SRichard Lowe	size_t pr_anon;            /* pages of resident anonymous memory */
1228bbf21555SRichard Lowe	size_t pr_locked;          /* pages of locked memory */
1229bbf21555SRichard Lowe	uint64_t pr_hatpagesize;   /* pagesize of mapping */
1230bbf21555SRichard Lowe} prxmap_t;
1231bbf21555SRichard Lowe.Ed
1232bbf21555SRichard Lowe.Pp
1233bbf21555SRichard Lowe.Sy pr_vaddr
1234bbf21555SRichard Loweis the virtual address of the mapping within the traced process and
1235bbf21555SRichard Lowe.Sy pr_size
1236bbf21555SRichard Loweis its size in bytes.
1237bbf21555SRichard Lowe.Sy pr_mapname ,
1238bbf21555SRichard Loweif it does not contain a null string, contains the name of a file in the
1239bbf21555SRichard Lowe.Sy object
1240bbf21555SRichard Lowedirectory (see below) that can be opened read-only to obtain a file descriptor
1241bbf21555SRichard Lowefor the mapped file associated with the mapping.
1242bbf21555SRichard LoweThis enables a debugger to find object file symbol tables without having to
1243bbf21555SRichard Loweknow the real path names of the executable file and shared libraries of
1244bbf21555SRichard Lowethe process.
1245bbf21555SRichard Lowe.Sy pr_offset
1246bbf21555SRichard Loweis the 64-bit offset within the mapped file (if any) to which the virtual
1247bbf21555SRichard Loweaddress is mapped.
1248bbf21555SRichard Lowe.Pp
1249bbf21555SRichard Lowe.Sy pr_mflags
1250bbf21555SRichard Loweis a bit-mask of protection and attribute flags:
1251bbf21555SRichard Lowe.Bl -tag -width "MA_NORESERVE" -offset left
1252bbf21555SRichard Lowe.It Sy MA_READ
1253bbf21555SRichard Lowemapping is readable by the traced process.
1254bbf21555SRichard Lowe.It Sy MA_WRITE
1255bbf21555SRichard Lowemapping is writable by the traced process.
1256bbf21555SRichard Lowe.It Sy MA_EXEC
1257bbf21555SRichard Lowemapping is executable by the traced process.
1258bbf21555SRichard Lowe.It Sy MA_SHARED
1259bbf21555SRichard Lowemapping changes are shared by the mapped object.
1260bbf21555SRichard Lowe.It Sy MA_ISM
1261bbf21555SRichard Lowemapping is intimate shared memory (shared MMU resources)
1262bbf21555SRichard Lowe.It Sy MAP_NORESERVE
1263bbf21555SRichard Lowemapping does not have swap space reserved (mapped with MAP_NORESERVE)
1264bbf21555SRichard Lowe.It Sy MA_SHM
1265bbf21555SRichard Lowemapping System V shared memory
1266bbf21555SRichard Lowe.El
1267bbf21555SRichard Lowe.Pp
1268bbf21555SRichard LoweA contiguous area of the address space having the same underlying mapped object
1269bbf21555SRichard Lowemay appear as multiple mappings due to varying read, write, and execute
1270bbf21555SRichard Loweattributes.
1271bbf21555SRichard LoweThe underlying mapped object does not change over the range of a
1272bbf21555SRichard Lowesingle mapping.
1273bbf21555SRichard LoweAn
1274bbf21555SRichard Lowe.Sy I/O
1275bbf21555SRichard Loweoperation to a mapping marked
1276bbf21555SRichard Lowe.Sy MA_SHARED
1277bbf21555SRichard Lowefails if applied at a virtual address not corresponding to a valid page in the
1278bbf21555SRichard Loweunderlying mapped object.
1279bbf21555SRichard LoweA write to a
1280bbf21555SRichard Lowe.Sy MA_SHARED
1281bbf21555SRichard Lowemapping that is not marked
1282bbf21555SRichard Lowe.Sy MA_WRITE
1283bbf21555SRichard Lowefails.
1284bbf21555SRichard LoweReads and writes to private mappings always succeed.
1285bbf21555SRichard LoweReads and writes to unmapped addresses fail.
1286bbf21555SRichard Lowe.Pp
1287bbf21555SRichard Lowe.Sy pr_pagesize
1288bbf21555SRichard Loweis the page size for the mapping, currently always the system pagesize.
1289bbf21555SRichard Lowe.Pp
1290bbf21555SRichard Lowe.Sy pr_shmid
1291bbf21555SRichard Loweis the shared memory identifier, if any, for the mapping.
1292bbf21555SRichard LoweIts value is \-1
1293bbf21555SRichard Loweif the mapping is not System V shared memory.
1294bbf21555SRichard LoweSee
1295bbf21555SRichard Lowe.Xr shmget 2 .
1296bbf21555SRichard Lowe.Pp
1297bbf21555SRichard Lowe.Sy pr_dev
1298bbf21555SRichard Loweis the device of the mapped object, if any, for the mapping.
1299bbf21555SRichard LoweIts value is
1300bbf21555SRichard Lowe.Sy PRNODEV
1301bbf21555SRichard Lowe.Pq \-1
1302bbf21555SRichard Loweif the mapping does not have a device.
1303bbf21555SRichard Lowe.Pp
1304bbf21555SRichard Lowe.Sy pr_ino
1305bbf21555SRichard Loweis the inode of the mapped object, if any, for the mapping.
1306bbf21555SRichard LoweIts contents are only valid if
1307bbf21555SRichard Lowe.Sy pr_dev
1308bbf21555SRichard Loweis not
1309bbf21555SRichard Lowe.Sy PRNODEV .
1310bbf21555SRichard Lowe.Pp
1311bbf21555SRichard Lowe.Sy pr_rss
1312bbf21555SRichard Loweis the number of resident pages of memory for the mapping.
1313bbf21555SRichard LoweThe number of resident bytes for the mapping may be determined by multiplying
1314bbf21555SRichard Lowe.Sy pr_rss
1315bbf21555SRichard Loweby the page size given by
1316bbf21555SRichard Lowe.Sy pr_pagesize .
1317bbf21555SRichard Lowe.Pp
1318bbf21555SRichard Lowe.Sy pr_anon
1319bbf21555SRichard Loweis the number of resident anonymous memory pages (pages which are
1320bbf21555SRichard Loweprivate to this process) for the mapping.
1321bbf21555SRichard Lowe.Pp
1322bbf21555SRichard Lowe.Sy pr_locked
1323bbf21555SRichard Loweis the number of locked pages for the mapping.
1324bbf21555SRichard LowePages which are locked are always resident in memory.
1325bbf21555SRichard Lowe.Pp
1326bbf21555SRichard Lowe.Sy pr_hatpagesize
1327bbf21555SRichard Loweis the size, in bytes, of the
1328bbf21555SRichard Lowe.Sy HAT
1329bbf21555SRichard Lowe.Pq Sy MMU
1330bbf21555SRichard Lowetranslation for the mapping.
1331bbf21555SRichard Lowe.Sy pr_hatpagesize
1332bbf21555SRichard Lowemay be different than
1333bbf21555SRichard Lowe.Sy pr_pagesize .
1334bbf21555SRichard LoweThe possible values are hardware architecture specific, and
1335bbf21555SRichard Lowemay change over a mapping's lifetime.
1336bbf21555SRichard Lowe.Ss rmap
1337bbf21555SRichard LoweContains information about the reserved address ranges of the process.
1338bbf21555SRichard LoweThe file contains an array of
1339bbf21555SRichard Lowe.Sy prmap
1340bbf21555SRichard Lowestructures, as defined above for the
1341bbf21555SRichard Lowe.Sy map
1342bbf21555SRichard Lowefile.
1343bbf21555SRichard LoweEach structure describes a contiguous virtual address region in the
1344bbf21555SRichard Loweaddress space of the traced process that is reserved by the system in the sense
1345bbf21555SRichard Lowethat an
1346bbf21555SRichard Lowe.Xr mmap 2
1347bbf21555SRichard Lowesystem call that does not specify
1348bbf21555SRichard Lowe.Sy MAP_FIXED
1349bbf21555SRichard Lowewill not use any part of it for the new mapping.
1350bbf21555SRichard LoweExamples of such reservations include the address ranges reserved for the
1351bbf21555SRichard Loweprocess stack and the individual thread stacks of a multi-threaded process.
1352bbf21555SRichard Lowe.Ss cwd
1353bbf21555SRichard LoweA symbolic link to the process's current working directory.
1354bbf21555SRichard LoweSee
1355bbf21555SRichard Lowe.Xr chdir 2 .
1356bbf21555SRichard LoweA
1357bbf21555SRichard Lowe.Xr readlink 2
1358bbf21555SRichard Loweof
1359bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /cwd
1360bbf21555SRichard Loweyields a null string.
1361bbf21555SRichard LoweHowever, it can be opened, listed, and searched as a directory, and can be the
1362bbf21555SRichard Lowetarget of
1363bbf21555SRichard Lowe.Xr chdir 2 .
1364bbf21555SRichard Lowe.Ss root
1365bbf21555SRichard LoweA symbolic link to the process's root directory.
1366bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /root
1367bbf21555SRichard Lowecan differ from the system root directory if the process or one of its
1368bbf21555SRichard Loweancestors executed
1369bbf21555SRichard Lowe.Xr chroot 2
1370bbf21555SRichard Loweas super user.
1371bbf21555SRichard LoweIt has the same semantics as
1372bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /cwd .
1373bbf21555SRichard Lowe.Ss fd
1374bbf21555SRichard LoweA directory containing references to the open files of the process.
1375bbf21555SRichard LoweEach entry is a decimal number corresponding to an open file descriptor in the
1376bbf21555SRichard Loweprocess.
1377bbf21555SRichard Lowe.Pp
1378bbf21555SRichard LoweIf an entry refers to a regular file, it can be opened with normal file system
1379bbf21555SRichard Lowesemantics but, to ensure that the controlling process cannot gain greater
1380bbf21555SRichard Loweaccess than the controlled process, with no file access modes other than its
1381bbf21555SRichard Loweread/write open modes in the controlled process.
1382bbf21555SRichard LoweIf an entry refers to a directory, it can be accessed with the same semantics
1383bbf21555SRichard Loweas
1384bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /cwd .
1385bbf21555SRichard LoweAn attempt to open any other type of entry fails with
1386bbf21555SRichard Lowe.Er EACCES .
1387bbf21555SRichard Lowe.Ss fdinfo
1388bbf21555SRichard LoweA directory containing information about each of the process's open files.
1389bbf21555SRichard LoweEach entry is a decimal number corresponding to an open file descriptor in the
1390bbf21555SRichard Loweprocess.
1391bbf21555SRichard LoweEach file contains a
1392bbf21555SRichard Lowe.Sy prfdinfo_t
1393bbf21555SRichard Lowestructure defined as follows:
1394bbf21555SRichard Lowe.Bd -literal -offset 2
1395bbf21555SRichard Lowetypedef struct prfdinfo {
1396bbf21555SRichard Lowe    int     pr_fd;          /* file descriptor number */
1397bbf21555SRichard Lowe    mode_t  pr_mode;        /* (see st_mode in stat(2)) */
1398bbf21555SRichard Lowe    uint64_t pr_ino;        /* inode number */
1399bbf21555SRichard Lowe    uint64_t pr_size;       /* file size */
1400bbf21555SRichard Lowe    int64_t pr_offset;      /* current offset of file descriptor */
1401bbf21555SRichard Lowe    uid_t   pr_uid;         /* owner's user id */
1402bbf21555SRichard Lowe    gid_t   pr_gid;         /* owner's group id */
1403bbf21555SRichard Lowe    major_t pr_major;       /* major number of device containing file */
1404bbf21555SRichard Lowe    minor_t pr_minor;       /* minor number of device containing file */
1405bbf21555SRichard Lowe    major_t pr_rmajor;      /* major number (if special file) */
1406bbf21555SRichard Lowe    minor_t pr_rminor;      /* minor number (if special file) */
1407bbf21555SRichard Lowe    int     pr_fileflags;   /* (see F_GETXFL in fcntl(2)) */
1408bbf21555SRichard Lowe    int     pr_fdflags;     /* (see F_GETFD in fcntl(2)) */
1409bbf21555SRichard Lowe    short   pr_locktype;    /* (see F_GETLK in fcntl(2)) */
1410bbf21555SRichard Lowe    pid_t   pr_lockpid;     /* process holding file lock (see F_GETLK) */
1411bbf21555SRichard Lowe    int     pr_locksysid;   /* sysid of locking process (see F_GETLK) */
1412bbf21555SRichard Lowe    pid_t   pr_peerpid;     /* peer process (socket, door) */
1413bbf21555SRichard Lowe    int     pr_filler[25];  /* reserved for future use */
1414bbf21555SRichard Lowe    char    pr_peername[PRFNSZ]; /* peer process name */
1415bbf21555SRichard Lowe#if __STDC_VERSION__ >= 199901L
1416bbf21555SRichard Lowe    char    pr_misc[];      /* self describing structures */
1417bbf21555SRichard Lowe#else
1418bbf21555SRichard Lowe    char    pr_misc[1];
1419bbf21555SRichard Lowe#endif
1420bbf21555SRichard Lowe} prfdinfo_t;
1421bbf21555SRichard Lowe.Ed
1422bbf21555SRichard Lowe.Pp
1423bbf21555SRichard LoweThe
1424bbf21555SRichard Lowe.Sy pr_misc
1425bbf21555SRichard Loweelement points to a list of additional miscellaneous data items, each of which
1426bbf21555SRichard Lowehas a header of type
1427bbf21555SRichard Lowe.Sy pr_misc_header_t
1428bbf21555SRichard Lowespecifying the size and type, and some data which immediately follow
1429bbf21555SRichard Lowethe header.
1430bbf21555SRichard Lowe.Bd -literal -offset 2
1431bbf21555SRichard Lowetypedef struct pr_misc_header {
1432bbf21555SRichard Lowe    uint_t          pr_misc_size;
1433bbf21555SRichard Lowe    uint_t          pr_misc_type;
1434bbf21555SRichard Lowe} pr_misc_header_t;
1435bbf21555SRichard Lowe.Ed
1436bbf21555SRichard Lowe.Pp
1437bbf21555SRichard LoweThe
1438bbf21555SRichard Lowe.Sy pr_misc_size
1439bbf21555SRichard Lowefield is the sum of the sizes of the header and the associated data and any
1440bbf21555SRichard Lowetrailing padding bytes which will be set to zero.
1441bbf21555SRichard LoweThe end of the list is indicated by a header with a zero size and a type with
1442bbf21555SRichard Loweall bits set.
1443bbf21555SRichard Lowe.Pp
1444bbf21555SRichard LoweThe following miscellaneous data types can be present:
1445bbf21555SRichard Lowe.Bl -tag -width "PR_SOCKOPT_TCP_CONGESTION" -offset left
1446bbf21555SRichard Lowe.It Sy PR_PATHNAME
1447bbf21555SRichard LoweThe file descriptor's path in the filesystem.
1448bbf21555SRichard LoweThis is a NUL-terminated sequence of characters.
1449bbf21555SRichard Lowe.It Sy PR_SOCKETNAME
1450bbf21555SRichard LoweA
1451bbf21555SRichard Lowe.Sy sockaddr
1452bbf21555SRichard Lowestructure representing the local socket name for this file descriptor, as
1453bbf21555SRichard Lowewould be returned by calling
1454bbf21555SRichard Lowe.Fn getsockname
1455bbf21555SRichard Lowewithin the process.
1456bbf21555SRichard Lowe.It Sy PR_PEERSOCKNAME
1457bbf21555SRichard LoweA
1458bbf21555SRichard Lowe.Sy sockaddr
1459bbf21555SRichard Lowestructure representing the peer socket name for this file descriptor, as
1460bbf21555SRichard Lowewould be returned by calling
1461bbf21555SRichard Lowe.Fn getpeername
1462bbf21555SRichard Lowewithin the process.
1463bbf21555SRichard Lowe.It Sy PR_SOCKOPTS_BOOL_OPTS
1464bbf21555SRichard LoweAn unsigned integer which has bits set corresponding to options which are
1465bbf21555SRichard Loweset on the underlying socket.
1466bbf21555SRichard LoweThe following bits may be set:
1467bbf21555SRichard Lowe.Bl -tag -width "PR_SO_PASSIVE_CONNECT"
1468bbf21555SRichard Lowe.It Sy PR_SO_DEBUG
1469bbf21555SRichard Lowe.It Sy PR_SO_REUSEADDR
1470bbf21555SRichard Lowe.It Sy PR_SO_REUSEPORT
1471bbf21555SRichard Lowe.It Sy PR_SO_KEEPALIVE
1472bbf21555SRichard Lowe.It Sy PR_SO_DONTROUTE
1473bbf21555SRichard Lowe.It Sy PR_SO_BROADCAST
1474bbf21555SRichard Lowe.It Sy PR_SO_OOBINLINE
1475bbf21555SRichard Lowe.It Sy PR_SO_DGRAM_ERRIND
1476bbf21555SRichard Lowe.It Sy PR_SO_ALLZONES
1477bbf21555SRichard Lowe.It Sy PR_SO_MAC_EXEMPT
1478bbf21555SRichard Lowe.It Sy PR_SO_EXCLBIND
1479bbf21555SRichard Lowe.It Sy PR_SO_PASSIVE_CONNECT
1480bbf21555SRichard Lowe.It Sy PR_SO_ACCEPTCONN
1481bbf21555SRichard Lowe.It Sy PR_UDP_NAT_T_ENDPOINT
1482bbf21555SRichard Lowe.It Sy PR_SO_VRRP
1483bbf21555SRichard Lowe.It Sy PR_SO_MAC_IMPLICIT
1484bbf21555SRichard Lowe.El
1485bbf21555SRichard Lowe.It Sy PR_SOCKOPT_LINGER
1486bbf21555SRichard LoweA
1487bbf21555SRichard Lowe.Sy struct linger
1488bbf21555SRichard Loweas would be returned by calling
1489bbf21555SRichard Lowe.Fn getsockopt SO_LINGER
1490bbf21555SRichard Lowewithin the process.
1491bbf21555SRichard Lowe.It Sy PR_SOCKOPT_SNDBUF
1492bbf21555SRichard LoweThe data that would be returned by calling
1493bbf21555SRichard Lowe.Fn getsockopt SO_SNDBUF
1494bbf21555SRichard Lowewithin the process.
1495bbf21555SRichard Lowe.It Sy PR_SOCKOPT_RCVBUF
1496bbf21555SRichard LoweThe data that would be returned by calling
1497bbf21555SRichard Lowe.Fn getsockopt SO_RCVBUF
1498bbf21555SRichard Lowewithin the process.
1499bbf21555SRichard Lowe.It Sy PR_SOCKOPT_IP_NEXTHOP
1500bbf21555SRichard LoweThe data that would be returned by calling
1501bbf21555SRichard Lowe.Fn getsockopt IPPROTO_IP IP_NEXTHOP
1502bbf21555SRichard Lowewithin the process.
1503bbf21555SRichard Lowe.It Sy PR_SOCKOPT_IPV6_NEXTHOP
1504bbf21555SRichard LoweThe data that would be returned by calling
1505bbf21555SRichard Lowe.Fn getsockopt IPPROTO_IPV6 IPV6_NEXTHOP
1506bbf21555SRichard Lowewithin the process.
1507bbf21555SRichard Lowe.It Sy PR_SOCKOPT_TYPE
1508bbf21555SRichard LoweThe data that would be returned by calling
1509bbf21555SRichard Lowe.Fn getsockopt SO_TYPE
1510bbf21555SRichard Lowewithin the process.
1511bbf21555SRichard Lowe.It Sy PR_SOCKOPT_TCP_CONGESTION
1512bbf21555SRichard LoweFor TCP sockets, the data that would be returned by calling
1513bbf21555SRichard Lowe.Fn getsockopt IPPROTO_TCP TCP_CONGESTION
1514bbf21555SRichard Lowewithin the process.
1515bbf21555SRichard LoweThis is a NUL-terminated character array containing the name of the congestion
1516bbf21555SRichard Lowealgorithm in use for the socket.
1517bbf21555SRichard Lowe.It Sy PR_SOCKFILTERS_PRIV
1518bbf21555SRichard LowePrivate data relating to up to the first 32 socket filters pushed on this
1519bbf21555SRichard Lowedescriptor.
1520bbf21555SRichard Lowe.El
1521bbf21555SRichard Lowe.Ss object
1522bbf21555SRichard LoweA directory containing read-only files with names corresponding to the
1523bbf21555SRichard Lowe.Sy pr_mapname
1524bbf21555SRichard Loweentries in the
1525bbf21555SRichard Lowe.Sy map
1526bbf21555SRichard Loweand
1527bbf21555SRichard Lowe.Sy pagedata
1528bbf21555SRichard Lowefiles.
1529bbf21555SRichard LoweOpening such a file yields a file descriptor for the underlying mapped file
1530bbf21555SRichard Loweassociated with an address-space mapping in the process.
1531bbf21555SRichard LoweThe file name
1532bbf21555SRichard Lowe.Pa a.out
1533bbf21555SRichard Loweappears in the directory as an alias for the process's executable file.
1534bbf21555SRichard Lowe.Pp
1535bbf21555SRichard LoweThe
1536bbf21555SRichard Lowe.Pa object
1537bbf21555SRichard Lowedirectory makes it possible for a controlling process to gain
1538bbf21555SRichard Loweaccess to the object file and any shared libraries (and consequently the symbol
1539bbf21555SRichard Lowetables) without having to know the actual path names of the executable files.
1540bbf21555SRichard Lowe.Ss path
1541bbf21555SRichard LoweA directory containing symbolic links to files opened by the process.
1542bbf21555SRichard LoweThe directory includes one entry for
1543bbf21555SRichard Lowe.Pa cwd
1544bbf21555SRichard Loweand
1545bbf21555SRichard Lowe.Pa root .
1546bbf21555SRichard LoweThe directory also contains a numerical entry for each file descriptor in the
1547bbf21555SRichard Lowe.Pa fd
1548bbf21555SRichard Lowedirectory, and entries matching those in the
1549bbf21555SRichard Lowe.Pa object
1550bbf21555SRichard Lowedirectory.
1551bbf21555SRichard LoweIf this information is not available, any attempt to read the contents of the
1552bbf21555SRichard Lowesymbolic link will fail.
1553bbf21555SRichard LoweThis is most common for files that do not exist in the filesystem namespace
1554bbf21555SRichard Lowe(such as
1555bbf21555SRichard Lowe.Sy FIFO Ns s
1556bbf21555SRichard Loweand sockets), but can also happen for regular files.
1557bbf21555SRichard LoweFor the file descriptor entries, the path may be different from the one
1558bbf21555SRichard Loweused by the process to open the file.
1559bbf21555SRichard Lowe.Ss pagedata
1560bbf21555SRichard LoweOpening the page data file enables tracking of address space references and
1561bbf21555SRichard Lowemodifications on a per-page basis.
1562bbf21555SRichard Lowe.Pp
1563bbf21555SRichard LoweA
1564bbf21555SRichard Lowe.Xr read 2
1565bbf21555SRichard Loweof the page data file descriptor returns structured page data
1566bbf21555SRichard Loweand atomically clears the page data maintained for the file by the system.
1567bbf21555SRichard LoweThat is to say, each read returns data collected since the last read; the
1568bbf21555SRichard Lowefirst read returns data collected since the file was opened.
1569bbf21555SRichard LoweWhen the call completes, the read buffer contains the following structure as
1570bbf21555SRichard Loweits header and thereafter contains a number of section header structures and
1571bbf21555SRichard Loweassociated byte arrays that must be accessed by walking linearly through the
1572bbf21555SRichard Lowebuffer.
1573bbf21555SRichard Lowe.Bd -literal -offset 2
1574bbf21555SRichard Lowetypedef struct prpageheader {
1575bbf21555SRichard Lowe    timestruc_t pr_tstamp; /* real time stamp, time of read() */
1576bbf21555SRichard Lowe    ulong_t pr_nmap;       /* number of address space mappings */
1577bbf21555SRichard Lowe    ulong_t pr_npage;      /* total number of pages */
1578bbf21555SRichard Lowe} prpageheader_t;
1579bbf21555SRichard Lowe.Ed
1580bbf21555SRichard Lowe.Pp
1581bbf21555SRichard LoweThe header is followed by
1582bbf21555SRichard Lowe.Sy "pr_nmap prasmap"
1583bbf21555SRichard Lowestructures and associated data arrays.
1584bbf21555SRichard LoweThe
1585bbf21555SRichard Lowe.Sy prasmap
1586bbf21555SRichard Lowestructure contains the following elements:
1587bbf21555SRichard Lowe.Bd -literal -offset 2
1588bbf21555SRichard Lowetypedef struct prasmap {
1589bbf21555SRichard Lowe    uintptr_t pr_vaddr;        /* virtual address of mapping */
1590bbf21555SRichard Lowe    ulong_t pr_npage;          /* number of pages in mapping */
1591bbf21555SRichard Lowe    char pr_mapname[PRMAPSZ];  /* name in /proc/pid/object */
1592bbf21555SRichard Lowe    offset_t pr_offset;        /* offset into mapped object, if any */
1593bbf21555SRichard Lowe    int pr_mflags;             /* protection and attribute flags */
1594bbf21555SRichard Lowe    int pr_pagesize;           /* pagesize for this mapping in bytes */
1595bbf21555SRichard Lowe    int pr_shmid;              /* SysV shared memory identifier */
1596bbf21555SRichard Lowe} prasmap_t;
1597bbf21555SRichard Lowe.Ed
1598bbf21555SRichard Lowe.Pp
1599bbf21555SRichard LoweEach section header is followed by
1600bbf21555SRichard Lowe.Sy pr_npage
1601bbf21555SRichard Lowebytes, one byte for each page in the mapping, plus 0-7 null bytes at the end
1602bbf21555SRichard Loweso that the next
1603bbf21555SRichard Lowe.Sy prasmap
1604bbf21555SRichard Lowestructure begins on an eight-byte aligned boundary.
1605bbf21555SRichard LoweEach data byte may contain these flags:
1606bbf21555SRichard Lowe.Bl -tag -width "PG_REFERENCED" -offset 2
1607bbf21555SRichard Lowe.It Sy PG_REFERENCED
1608bbf21555SRichard Lowepage has been referenced.
1609bbf21555SRichard Lowe.It Sy PG_MODIFIED
1610bbf21555SRichard Lowepage has been modified.
1611bbf21555SRichard Lowe.El
1612bbf21555SRichard Lowe.Pp
1613bbf21555SRichard LoweIf the read buffer is not large enough to contain all of the page data, the
1614bbf21555SRichard Loweread fails with
1615bbf21555SRichard Lowe.Er E2BIG
1616bbf21555SRichard Loweand the page data is not cleared.
1617bbf21555SRichard LoweThe required size of the read buffer can be determined through
1618bbf21555SRichard Lowe.Xr fstat 2 .
1619bbf21555SRichard LoweApplication of
1620bbf21555SRichard Lowe.Xr lseek 2
1621bbf21555SRichard Loweto the page data file descriptor is ineffective; every read
1622bbf21555SRichard Lowestarts from the beginning of the file.
1623bbf21555SRichard LoweClosing the page data file descriptor
1624bbf21555SRichard Loweterminates the system overhead associated with collecting the data.
1625bbf21555SRichard Lowe.Pp
1626bbf21555SRichard LoweMore than one page data file descriptor for the same process can be opened, up
1627bbf21555SRichard Loweto a system-imposed limit per traced process.
1628bbf21555SRichard LoweA read of one does not affect the data being collected by the system for the
1629bbf21555SRichard Loweothers.
1630bbf21555SRichard LoweAn open of the page data file will fail with
1631bbf21555SRichard Lowe.Er ENOMEM
1632bbf21555SRichard Loweif the system-imposed limit would be exceeded.
1633bbf21555SRichard Lowe.Ss watch
1634bbf21555SRichard LoweContains an array of
1635bbf21555SRichard Lowe.Vt prwatch
1636bbf21555SRichard Lowestructures, one for each watched area established by the
1637bbf21555SRichard Lowe.Sy PCWATCH
1638bbf21555SRichard Lowecontrol operation.
1639bbf21555SRichard LoweSee
1640bbf21555SRichard Lowe.Sx PCWATCH
1641bbf21555SRichard Lowefor details.
1642bbf21555SRichard Lowe.Ss usage
1643bbf21555SRichard LoweContains process usage information described by a
1644bbf21555SRichard Lowe.Vt prusage
1645bbf21555SRichard Lowestructure which contains at least the following fields:
1646bbf21555SRichard Lowe.Bd -literal -offset 2
1647bbf21555SRichard Lowetypedef struct prusage {
1648bbf21555SRichard Lowe    id_t pr_lwpid;           /* lwp id.  0: process or defunct */
1649bbf21555SRichard Lowe    int pr_count;            /* number of contributing lwps */
1650bbf21555SRichard Lowe    timestruc_t pr_tstamp;   /* real time stamp, time of read() */
1651bbf21555SRichard Lowe    timestruc_t pr_create;   /* process/lwp creation time stamp */
1652bbf21555SRichard Lowe    timestruc_t pr_term;     /* process/lwp termination time stamp */
1653bbf21555SRichard Lowe    timestruc_t pr_rtime;    /* total lwp real (elapsed) time */
1654bbf21555SRichard Lowe    timestruc_t pr_utime;    /* user level CPU time */
1655bbf21555SRichard Lowe    timestruc_t pr_stime;    /* system call CPU time */
1656bbf21555SRichard Lowe    timestruc_t pr_ttime;    /* other system trap CPU time */
1657bbf21555SRichard Lowe    timestruc_t pr_tftime;   /* text page fault sleep time */
1658bbf21555SRichard Lowe    timestruc_t pr_dftime;   /* data page fault sleep time */
1659bbf21555SRichard Lowe    timestruc_t pr_kftime;   /* kernel page fault sleep time */
1660bbf21555SRichard Lowe    timestruc_t pr_ltime;    /* user lock wait sleep time */
1661bbf21555SRichard Lowe    timestruc_t pr_slptime;  /* all other sleep time */
1662bbf21555SRichard Lowe    timestruc_t pr_wtime;    /* wait-cpu (latency) time */
1663bbf21555SRichard Lowe    timestruc_t pr_stoptime; /* stopped time */
1664bbf21555SRichard Lowe    ulong_t pr_minf;         /* minor page faults */
1665bbf21555SRichard Lowe    ulong_t pr_majf;         /* major page faults */
1666bbf21555SRichard Lowe    ulong_t pr_nswap;        /* swaps */
1667bbf21555SRichard Lowe    ulong_t pr_inblk;        /* input blocks */
1668bbf21555SRichard Lowe    ulong_t pr_oublk;        /* output blocks */
1669bbf21555SRichard Lowe    ulong_t pr_msnd;         /* messages sent */
1670bbf21555SRichard Lowe    ulong_t pr_mrcv;         /* messages received */
1671bbf21555SRichard Lowe    ulong_t pr_sigs;         /* signals received */
1672bbf21555SRichard Lowe    ulong_t pr_vctx;         /* voluntary context switches */
1673bbf21555SRichard Lowe    ulong_t pr_ictx;         /* involuntary context switches */
1674bbf21555SRichard Lowe    ulong_t pr_sysc;         /* system calls */
1675bbf21555SRichard Lowe    ulong_t pr_ioch;         /* chars read and written */
1676bbf21555SRichard Lowe} prusage_t;
1677bbf21555SRichard Lowe.Ed
1678bbf21555SRichard Lowe.Pp
1679bbf21555SRichard LoweMicrostate accounting is now continuously enabled.
1680bbf21555SRichard LoweWhile this information was
1681bbf21555SRichard Lowepreviously an estimate, if microstate accounting were not enabled, the current
1682bbf21555SRichard Loweinformation is now never an estimate represents time the process has spent in
1683bbf21555SRichard Lowevarious states.
1684bbf21555SRichard Lowe.Ss lstatus
1685bbf21555SRichard LoweContains a
1686bbf21555SRichard Lowe.Vt prheader
1687bbf21555SRichard Lowestructure followed by an array of
1688bbf21555SRichard Lowe.Vt lwpstatus
1689bbf21555SRichard Lowestructures, one for each active lwp in the process (see also
1690bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid Ns Pa /lwpstatus ,
1691bbf21555SRichard Lowebelow).
1692bbf21555SRichard LoweThe
1693bbf21555SRichard Lowe.Vt prheader
1694bbf21555SRichard Lowestructure describes the number and size of the array entries that follow.
1695bbf21555SRichard Lowe.Bd -literal -offset 2
1696bbf21555SRichard Lowetypedef struct prheader {
1697bbf21555SRichard Lowe    long pr_nent;        /* number of entries */
1698bbf21555SRichard Lowe    size_t pr_entsize;   /* size of each entry, in bytes */
1699bbf21555SRichard Lowe} prheader_t;
1700bbf21555SRichard Lowe.Ed
1701bbf21555SRichard Lowe.Pp
1702bbf21555SRichard LoweThe
1703bbf21555SRichard Lowe.Vt lwpstatus
1704bbf21555SRichard Lowestructure may grow by the addition of elements at the end in future releases
1705bbf21555SRichard Loweof the system.
1706bbf21555SRichard LowePrograms must use
1707bbf21555SRichard Lowe.Sy pr_entsize
1708bbf21555SRichard Lowein the file header to index through the array.
1709bbf21555SRichard LoweThese comments apply to all
1710bbf21555SRichard Lowe.Pa /proc
1711bbf21555SRichard Lowefiles that include a
1712bbf21555SRichard Lowe.Vt prheader
1713bbf21555SRichard Lowestructure
1714bbf21555SRichard Lowe.Pf ( Pa lpsinfo
1715bbf21555SRichard Loweand
1716bbf21555SRichard Lowe.Pa lusage ,
1717bbf21555SRichard Lowebelow).
1718bbf21555SRichard Lowe.Ss lpsinfo
1719bbf21555SRichard LoweContains a
1720bbf21555SRichard Lowe.Vt prheader
1721bbf21555SRichard Lowestructure followed by an array of
1722bbf21555SRichard Lowe.Vt lwpsinfo
1723bbf21555SRichard Lowestructures, one for eachactive and zombie lwp in the process.
1724bbf21555SRichard LoweSee also
1725bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid Ns Pa /lwpsinfo ,
1726bbf21555SRichard Lowebelow.
1727bbf21555SRichard Lowe.Ss lusage
1728bbf21555SRichard LoweContains a
1729bbf21555SRichard Lowe.Vt prheader
1730bbf21555SRichard Lowestructure followed by an array of
1731bbf21555SRichard Lowe.Vt prusage
1732bbf21555SRichard Lowestructures, one for each active lwp in the process, plus an additional element
1733bbf21555SRichard Loweat the beginning that contains the summation over all defunct lwps (lwps that
1734bbf21555SRichard Loweonce existed but no longer exist in the process).
1735bbf21555SRichard LoweExcluding the
1736bbf21555SRichard Lowe.Sy pr_lwpid ,
1737bbf21555SRichard Lowe.Sy pr_tstamp ,
1738bbf21555SRichard Lowe.Sy pr_create ,
1739bbf21555SRichard Loweand
1740bbf21555SRichard Lowe.Sy pr_term
1741bbf21555SRichard Loweentries, the entry-by-entry summation over all these structures is the
1742bbf21555SRichard Lowedefinition of the process usage information obtained from the
1743bbf21555SRichard Lowe.Pa usage
1744bbf21555SRichard Lowefile. (See also
1745bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid Ns Pa /lwpusage ,
1746bbf21555SRichard Lowebelow.)
1747bbf21555SRichard Lowe.Ss lwp
1748bbf21555SRichard LoweA directory containing entries each of which names an active or zombie lwp
1749bbf21555SRichard Lowewithin the process.
1750bbf21555SRichard LoweThese entries are themselves directories containing additional files as
1751bbf21555SRichard Lowedescribed below.
1752bbf21555SRichard LoweOnly the
1753bbf21555SRichard Lowe.Pa lwpsinfo
1754bbf21555SRichard Lowefile exists in the directory of a zombie lwp.
1755bbf21555SRichard Lowe.Sh "STRUCTURE OF" Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid
1756bbf21555SRichard LoweA given directory
1757bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid
1758bbf21555SRichard Lowecontains the following entries:
1759bbf21555SRichard Lowe.Ss lwpctl
1760bbf21555SRichard LoweWrite-only control file.
1761bbf21555SRichard LoweThe messages written to this file affect the specific
1762bbf21555SRichard Lowelwp rather than the representative lwp, as is the case for the process's
1763bbf21555SRichard Lowe.Pa ctl
1764bbf21555SRichard Lowefile.
1765bbf21555SRichard Lowe.Ss lwpname
1766bbf21555SRichard LoweA buffer of
1767bbf21555SRichard Lowe.Dv THREAD_NAME_MAX
1768bbf21555SRichard Lowebytes representing the LWP name; the buffer is
1769bbf21555SRichard Lowezero-filled if the thread name is shorter than the buffer.
1770bbf21555SRichard LoweIf no thread name is set, the buffer contains the empty string.
1771bbf21555SRichard LoweA read with a buffer shorter than
1772bbf21555SRichard Lowe.Dv THREAD_NAME_MAX
1773bbf21555SRichard Lowebytes is not guaranteed to be NUL-terminated.
1774bbf21555SRichard LoweWriting to this file will set the LWP name for the specific lwp.
1775bbf21555SRichard LoweThis file may not be present in older operating system versions.
1776bbf21555SRichard Lowe.Dv THREAD_NAME_MAX
1777bbf21555SRichard Lowemay increase in the future; clients should be prepared for this.
1778bbf21555SRichard Lowe.Ss lwpstatus
1779bbf21555SRichard Lowelwp-specific state information.
1780bbf21555SRichard LoweThis file contains the
1781bbf21555SRichard Lowe.Vt lwpstatus
1782bbf21555SRichard Lowestructure for the specific lwp as described above for the representative lwp in
1783bbf21555SRichard Lowethe process's
1784bbf21555SRichard Lowe.Pa status
1785bbf21555SRichard Lowefile.
1786bbf21555SRichard Lowe.Ss lwpsinfo
1787bbf21555SRichard Lowelwp-specific
1788bbf21555SRichard Lowe.Xr ps 1
1789bbf21555SRichard Loweinformation.
1790bbf21555SRichard LoweThis file contains the
1791bbf21555SRichard Lowe.Vt lwpsinfo
1792bbf21555SRichard Lowestructure for the specific lwp as described above for the representative lwp in
1793bbf21555SRichard Lowethe process's
1794bbf21555SRichard Lowe.Pa psinfo
1795bbf21555SRichard Lowefile.
1796bbf21555SRichard LoweThe
1797bbf21555SRichard Lowe.Pa lwpsinfo
1798bbf21555SRichard Lowefile remains accessible after an lwp becomes a zombie.
1799bbf21555SRichard Lowe.Ss lwpusage
1800bbf21555SRichard LoweThis file contains the
1801bbf21555SRichard Lowe.Vt prusage
1802bbf21555SRichard Lowestructure for the specific lwp as described above for the process's
1803bbf21555SRichard Lowe.Pa usage
1804bbf21555SRichard Lowefile.
1805bbf21555SRichard Lowe.Ss gwindows
1806bbf21555SRichard LoweThis file exists only on SPARC based machines.
1807bbf21555SRichard LoweIf it is non-empty, it contains a
1808bbf21555SRichard Lowe.Vt gwindows_t
1809bbf21555SRichard Lowestructure, defined in
1810bbf21555SRichard Lowe.In sys/regset.h ,
1811bbf21555SRichard Lowewith the values of those SPARC register windows that could not be stored on
1812bbf21555SRichard Lowethe stack when the lwp stopped.
1813bbf21555SRichard LoweConditions under which register windows are not stored on the
1814bbf21555SRichard Lowestack are: the stack pointer refers to nonexistent process memory or the stack
1815bbf21555SRichard Lowepointer is improperly aligned.
1816bbf21555SRichard LoweIf the lwp is not stopped or if there are no
1817bbf21555SRichard Loweregister windows that could not be stored on the stack, the file is empty (the
1818bbf21555SRichard Loweusual case).
1819bbf21555SRichard Lowe.Ss xregs
1820bbf21555SRichard LoweExtra state registers.
1821bbf21555SRichard LoweThe extra state register set is architecture dependent;
1822bbf21555SRichard Lowethis file is empty if the system does not support extra state registers.
1823bbf21555SRichard LoweIf the file is non-empty, it contains an architecture dependent structure of
1824bbf21555SRichard Lowetype
1825bbf21555SRichard Lowe.Vt prxregset_t ,
1826bbf21555SRichard Lowedefined in
1827bbf21555SRichard Lowe.In procfs.h ,
1828bbf21555SRichard Lowewith the values of the lwp's extra state registers.
1829bbf21555SRichard LoweIf the lwp is not stopped, all register values are undefined.
1830bbf21555SRichard LoweSee also the
1831bbf21555SRichard Lowe.Sx PCSXREG
1832bbf21555SRichard Lowecontrol operation, below.
1833*a14132dbSRobert MustacchiReading this data currently requires that the process be stopped.
1834bbf21555SRichard Lowe.Ss asrs
1835bbf21555SRichard LoweThis file exists only for 64-bit SPARC V9 processes.
1836bbf21555SRichard LoweIt contains an
1837bbf21555SRichard Lowe.Vt asrset_t
1838bbf21555SRichard Lowestructure, defined in
1839bbf21555SRichard Lowe.In sys/regset.h ,
1840bbf21555SRichard Lowecontaining the values of the lwp's platform-dependent ancillary state registers.
1841bbf21555SRichard LoweIf the lwp is not stopped, all register values are undefined.
1842bbf21555SRichard LoweSee also the
1843bbf21555SRichard Lowe.Sx PCSASRS
1844bbf21555SRichard Lowecontrol operation, below.
1845bbf21555SRichard Lowe.Ss spymaster
1846bbf21555SRichard LoweFor an agent lwp (see
1847bbf21555SRichard Lowe.Sx PCAGENT ) ,
1848bbf21555SRichard Lowethis file contains a
1849bbf21555SRichard Lowe.Vt psinfo_t
1850bbf21555SRichard Lowestructure that corresponds to the process that created the agent lwp at the
1851bbf21555SRichard Lowetime the agent was created.
1852bbf21555SRichard LoweThis structure is identical to that retrieved via the
1853bbf21555SRichard Lowe.Pa psinfo
1854bbf21555SRichard Lowefile, with one modification: the
1855bbf21555SRichard Lowe.Sy pr_time
1856bbf21555SRichard Lowefield does not correspond to the CPU time for the process, but rather to the
1857bbf21555SRichard Lowecreation time of the agent lwp.
1858bbf21555SRichard Lowe.Ss templates
1859bbf21555SRichard LoweA directory which contains references to the active templates for the lwp,
1860bbf21555SRichard Lowenamed by the contract type.
1861bbf21555SRichard LoweChanges made to an active template descriptor do
1862bbf21555SRichard Lowenot affect the original template which was activated, though they do affect the
1863bbf21555SRichard Loweactive template.
1864bbf21555SRichard LoweIt is not possible to activate an active template descriptor.
1865bbf21555SRichard LoweSee
1866bbf21555SRichard Lowe.Xr contract 5 .
1867ed093b41SRobert Mustacchi.Sh ARCHITECTURE-SPECIFIC STRUCTURES
1868ed093b41SRobert Mustacchi.Ss x86
1869ed093b41SRobert MustacchiWhile the x86
1870ed093b41SRobert Mustacchi.Vt prxregset_t
1871ed093b41SRobert Mustacchistructure is opaque to consumers, it is made up of several different
1872ed093b41SRobert Mustacchicomponents due to the fact that different x86 processors enumerate
1873ed093b41SRobert Mustacchidifferent architectural extensions.
1874ed093b41SRobert Mustacchi.Pp
1875ed093b41SRobert MustacchiThe structure begins with a header, the
1876ed093b41SRobert Mustacchi.Vt prxregset_hdr_t ,
1877ed093b41SRobert Mustacchiwhich is followed by a number of different information sections which
1878ed093b41SRobert Mustacchidescribe different possible extended registers.
1879ed093b41SRobert MustacchiEach of those is covered by a
1880ed093b41SRobert Mustacchi.Vt prxregset_info_t ,
1881ed093b41SRobert Mustacchiand then finally there are different data payloads that represent each
1882ed093b41SRobert Mustacchiextended register.
1883ed093b41SRobert Mustacchi.Pp
1884ed093b41SRobert MustacchiThe number of different informational entries varies from system to
1885ed093b41SRobert Mustacchisystem based on the set of architectural features that the system
1886ed093b41SRobert Mustacchisupports and the corresponding OS enablement for them.
1887ed093b41SRobert MustacchiThis structure is built around the idea of the x86
1888ed093b41SRobert Mustacchi.Sy xsave
1889ed093b41SRobert Mustacchistructure.
1890ed093b41SRobert MustacchiThat is, there is a central header which describes a bit-vector of what
1891ed093b41SRobert Mustacchiextended features are present and have valid state.
1892ed093b41SRobert Mustacchi.Pp
1893ed093b41SRobert MustacchiEach x86 xregs file begins with the
1894ed093b41SRobert Mustacchi.Vt prxregset_hdr_t
1895ed093b41SRobert Mustacchiwhich looks like:
1896ed093b41SRobert Mustacchi.Bd -literal -offset 2
1897ed093b41SRobert Mustacchitypedef struct prxregset_hdr {
1898ed093b41SRobert Mustacchi	uint32_t	pr_type;
1899ed093b41SRobert Mustacchi	uint32_t	pr_size;
1900ed093b41SRobert Mustacchi	uint32_t	pr_flags;
1901ed093b41SRobert Mustacchi	uint32_t	pr_pad[4];
1902ed093b41SRobert Mustacchi	uint32_t	pr_ninfo;
1903ed093b41SRobert Mustacchi	prxregset_info_t pr_info[];
1904ed093b41SRobert Mustacchi} prxregset_hdr_t;
1905ed093b41SRobert Mustacchi.Ed
1906ed093b41SRobert Mustacchi.Pp
1907ed093b41SRobert MustacchiThe
1908ed093b41SRobert Mustacchi.Fa pr_type
1909ed093b41SRobert Mustacchimember is always set to
1910ed093b41SRobert Mustacchi.Dv PR_TYPE_XSAVE .
1911ed093b41SRobert MustacchiThis is used to indicate the type of file that is present.
1912ed093b41SRobert MustacchiThere may be different file types in the future on x86 so this value
1913ed093b41SRobert Mustacchishould always be checked.
1914ed093b41SRobert MustacchiIf it is not
1915ed093b41SRobert Mustacchi.Dv PR_TYPE_XSAVE
1916ed093b41SRobert Mustacchithen the rest of the structure may look different.
1917ed093b41SRobert MustacchiThe
1918ed093b41SRobert Mustacchi.Fa pr_size
1919ed093b41SRobert Mustacchimember indicates the size in bytes of the overall structure.
1920ed093b41SRobert MustacchiThe
1921ed093b41SRobert Mustacchi.Fa pr_flags
1922ed093b41SRobert Mustacchiand
1923ed093b41SRobert Mustacchi.Fa pr_pad
1924ed093b41SRobert Mustacchivalues are currently reserved for future use.
1925ed093b41SRobert MustacchiThey will be set to zero right now when read and must be set to zero when
1926ed093b41SRobert Mustacchiwriting the data.
1927ed093b41SRobert MustacchiThe
1928ed093b41SRobert Mustacchi.Fa pr_ninfo
1929ed093b41SRobert Mustacchimember indicates the number of informational items are present in
1930ed093b41SRobert Mustacchi.Fa pr_info.
1931ed093b41SRobert MustacchiThere will be one informational item for each register set that exists.
1932ed093b41SRobert Mustacchi.Pp
1933ed093b41SRobert MustacchiThe
1934ed093b41SRobert Mustacchi.Fa pr_info
1935ed093b41SRobert Mustacchimember points to an array of informational members.
1936ed093b41SRobert MustacchiThese immediately follow the structure, though the
1937ed093b41SRobert Mustacchi.Fa pr_info
1938ed093b41SRobert Mustacchimember may not be available directly if not in an environment compatible with
1939ed093b41SRobert Mustacchisome C99 features.
1940ed093b41SRobert MustacchiEach
1941ed093b41SRobert Mustacchi.Vt prxregset_info_t
1942ed093b41SRobert Mustacchistructure looks like:
1943ed093b41SRobert Mustacchi.Bd -literal -offset 2
1944ed093b41SRobert Mustacchitypedef struct prxregset_info {
1945ed093b41SRobert Mustacchi	uint32_t pri_type;
1946ed093b41SRobert Mustacchi	uint32_t pri_flags;
1947ed093b41SRobert Mustacchi	uint32_t pri_size;
1948ed093b41SRobert Mustacchi	uint32_t pri_offset;
1949ed093b41SRobert Mustacchi} prxregset_info_t;
1950ed093b41SRobert Mustacchi.Ed
1951ed093b41SRobert Mustacchi.Pp
1952ed093b41SRobert MustacchiThe
1953ed093b41SRobert Mustacchi.Fa pri_type
1954ed093b41SRobert Mustacchimember is used to indicate the type of data and its format that this represents.
1955ed093b41SRobert MustacchiTypes are listed below.
1956ed093b41SRobert MustacchiThe
1957ed093b41SRobert Mustacchi.Fa pri_flags
1958ed093b41SRobert Mustacchimember is used to indicate future extensions or information about these items.
1959ed093b41SRobert MustacchiRight now, these are all zero.
1960ed093b41SRobert MustacchiThe
1961ed093b41SRobert Mustacchi.Fa pri_size
1962ed093b41SRobert Mustacchimember indicates the size in bytes of the type's data.
1963ed093b41SRobert MustacchiThe
1964ed093b41SRobert Mustacchi.Fa pri_offset
1965ed093b41SRobert Mustacchimember indicates the offset to the start of the data section from the beginning
1966ed093b41SRobert Mustacchiof the xregs file.
1967ed093b41SRobert MustacchiThat is an offset of 0 would be the first byte of the
1968ed093b41SRobert Mustacchi.Vt prxregset_hdr_t .
1969ed093b41SRobert Mustacchi.Pp
1970ed093b41SRobert MustacchiThe following types of structures and their corresponding data structures are
1971ed093b41SRobert Mustacchicurrently defined:
1972ed093b41SRobert Mustacchi.Bl -tag -width Ds
1973ed093b41SRobert Mustacchi.It Dv PRX_INFO_XCR - Vt prxregset_xcr_t
1974ed093b41SRobert MustacchiThis structure provides read-only access to understanding the CPU's settings for
1975ed093b41SRobert Mustacchithis thread.
1976ed093b41SRobert MustacchiIn particular, it lets you see what is set in the x86 %xcr0 register which is
1977ed093b41SRobert Mustacchithe extended feature control register and controls what extended features the
1978ed093b41SRobert MustacchiCPU actually uses.
1979ed093b41SRobert MustacchiIt also contains the x86 extended feature disable MSR which controls features
1980ed093b41SRobert Mustacchithat are ignored.
1981ed093b41SRobert MustacchiThe
1982ed093b41SRobert Mustacchi.Vt prxregset_xcr_t
1983ed093b41SRobert Mustacchilooks like:
1984ed093b41SRobert Mustacchi.Bd -literal -offset -indent
1985ed093b41SRobert Mustacchitypedef struct prxregset_xcr {
1986ed093b41SRobert Mustacchi	uint64_t	prx_xcr_xcr0;
1987ed093b41SRobert Mustacchi	uint64_t	prx_xcr_xfd;
1988ed093b41SRobert Mustacchi	uint64_t	prx_xcr_pad[2];
1989ed093b41SRobert Mustacchi} prxregset_xcr_t;
1990ed093b41SRobert Mustacchi.Ed
1991ed093b41SRobert Mustacchi.Pp
1992ed093b41SRobert MustacchiWhen setting the xregs, this entry can be left out.
1993ed093b41SRobert MustacchiIf it is included, it must match the existing entries, otherwise an error will
1994ed093b41SRobert Mustacchibe generated.
1995ed093b41SRobert Mustacchi.It Dv PRX_INFO_XSAVE - Vt prxregset_xsave_t
1996ed093b41SRobert MustacchiThis structure represents the same as the actual Intel xsave structure, which
1997ed093b41SRobert Mustacchihas both the traditional XMM state that comes from the fxsave instruction and
1998ed093b41SRobert Mustacchithen also contains the xsave header itself.
1999ed093b41SRobert MustacchiThe structure varies between 32-bit and 64-bit applications.
2000ed093b41SRobert MustacchiThe structure itself looks like:
2001ed093b41SRobert Mustacchi.Bd -literal
2002ed093b41SRobert Mustacchitypedef struct prxregset_xsave {
2003ed093b41SRobert Mustacchi	uint16_t	prx_fx_fcw;
2004ed093b41SRobert Mustacchi	uint16_t	prx_fx_fsw;
2005ed093b41SRobert Mustacchi	uint16_t	prx_fx_fctw;	/* compressed tag word */
2006ed093b41SRobert Mustacchi	uint16_t	prx_fx_fop;
2007ed093b41SRobert Mustacchi#if defined(__amd64)
2008ed093b41SRobert Mustacchi	uint64_t	prx_fx_rip;
2009ed093b41SRobert Mustacchi	uint64_t	prx_fx_rdp;
2010ed093b41SRobert Mustacchi#else
2011ed093b41SRobert Mustacchi	uint32_t	prx_fx_eip;
2012ed093b41SRobert Mustacchi	uint16_t	prx_fx_cs;
2013ed093b41SRobert Mustacchi	uint16_t	__prx_fx_ign0;
2014ed093b41SRobert Mustacchi	uint32_t	prx_fx_dp;
2015ed093b41SRobert Mustacchi	uint16_t	prx_fx_ds;
2016ed093b41SRobert Mustacchi	uint16_t	__prx_fx_ign1;
2017ed093b41SRobert Mustacchi#endif
2018ed093b41SRobert Mustacchi	uint32_t	prx_fx_mxcsr;
2019ed093b41SRobert Mustacchi	uint32_t	prx_fx_mxcsr_mask;
2020ed093b41SRobert Mustacchi	union {
2021ed093b41SRobert Mustacchi		uint16_t prx_fpr_16[5];	/* 80-bits of x87 state */
2022ed093b41SRobert Mustacchi		u_longlong_t prx_fpr_mmx;	/* 64-bit mmx register */
2023ed093b41SRobert Mustacchi		uint32_t _prx__fpr_pad[4];	/* (pad out to 128-bits) */
2024ed093b41SRobert Mustacchi	} fx_st[8];
2025ed093b41SRobert Mustacchi#if defined(__amd64)
2026ed093b41SRobert Mustacchi	upad128_t	prx_fx_xmm[16];	/* 128-bit registers */
2027ed093b41SRobert Mustacchi	upad128_t	__prx_fx_ign2[6];
2028ed093b41SRobert Mustacchi#else
2029ed093b41SRobert Mustacchi	upad128_t	prx_fx_xmm[8];	/* 128-bit registers */
2030ed093b41SRobert Mustacchi	upad128_t	__prx_fx_ign2[14];
2031ed093b41SRobert Mustacchi#endif
2032ed093b41SRobert Mustacchi	uint64_t	prx_xsh_xstate_bv;
2033ed093b41SRobert Mustacchi	uint64_t	prx_xsh_xcomp_bv;
2034ed093b41SRobert Mustacchi	uint64_t	prx_xsh_reserved[6];
2035ed093b41SRobert Mustacchi} prxregset_xsave_t;
2036ed093b41SRobert Mustacchi.Ed
2037ed093b41SRobert Mustacchi.Pp
2038ed093b41SRobert MustacchiIn the classical fxsave portion of the structure, most of the members follow the
2039ed093b41SRobert Mustacchisame meaning and match their presence in the fpregs file and their use as
2040ed093b41SRobert Mustacchidiscussed in the Intel and AMD software developer manuals.
2041ed093b41SRobert MustacchiThe one exception is that when setting the
2042ed093b41SRobert Mustacchi.Fa prx_fx_mxcsr
2043ed093b41SRobert Mustacchimember reserved bits that are set will be masked off and ignored.
2044ed093b41SRobert Mustacchi.Pp
2045ed093b41SRobert MustacchiThe most notable fields to consider here right now are the last few members
2046ed093b41SRobert Mustacchiwhich are part of the xsave header itself.
2047ed093b41SRobert MustacchiIn particular, the
2048ed093b41SRobert Mustacchi.Fa prx_xsh_xstate_bv
2049ed093b41SRobert Mustacchicomponent is used to track the actual features whose content are valid.
2050ed093b41SRobert MustacchiWhen reading the registers, if a given entry is not valid, the register state
2051ed093b41SRobert Mustacchiwill write out the informational entry in its default state.
2052ed093b41SRobert MustacchiWhen setting the extended registers, this notes which features will be loaded
2053ed093b41SRobert Mustacchifrom their default state
2054ed093b41SRobert Mustacchi.Pq as defined by Intel and AMD's manuals
2055ed093b41SRobert Mustacchiand which will be loaded from the informational entries.
2056ed093b41SRobert MustacchiIf a bit is set in the
2057ed093b41SRobert Mustacchi.Fa prx_xsh_xstate_bv
2058ed093b41SRobert Mustacchientry, then it must be present as its own informational entry otherwise a write
2059ed093b41SRobert Mustacchiwill fail.
2060ed093b41SRobert MustacchiIf an informational entry is present in a write, but not set in the
2061ed093b41SRobert Mustacchi.Fa prx_xsh_xstate_bv
2062ed093b41SRobert Mustacchithen its contents will be ignored.
2063ed093b41SRobert Mustacchi.Pp
2064ed093b41SRobert MustacchiThe xregs format currently does not support any compressed items being specified
2065ed093b41SRobert Mustacchinor does it specify any, so the
2066ed093b41SRobert Mustacchi.Fa prx_xsh_xcomp_bv
2067ed093b41SRobert Mustacchimember will be always set to zero and it and the reserved members
2068ed093b41SRobert Mustacchi.Fa prx_xsh_reserved
2069ed093b41SRobert Mustacchimust all be left as zero.
2070ed093b41SRobert Mustacchi.It Dv PRX_INFO_YMM - Vt prxregset_ymm_t
2071ed093b41SRobert MustacchiThis structure contains the upper 128-bits of the first 16 %ymm registers
2072ed093b41SRobert Mustacchi.Pq 8 for 32-bit applications .
2073ed093b41SRobert MustacchiTo construct a full vector register, it must be combined with the
2074ed093b41SRobert Mustacchi.Fa prx_fx_xmm
2075ed093b41SRobert Mustacchimember of the
2076ed093b41SRobert Mustacchi.Dv PRX_INFO_XSAVE
2077ed093b41SRobert Mustacchidata.
2078ed093b41SRobert MustacchiIn 32-bit applications, the reserved registers must be written as zero.
2079ed093b41SRobert MustacchiThe structure itself looks like:
2080ed093b41SRobert Mustacchi.Bd -literal -offset 2
2081ed093b41SRobert Mustacchitypedef struct prxregset_ymm {
2082ed093b41SRobert Mustacchi#if defined(__amd64)
2083ed093b41SRobert Mustacchi	upad128_t	prx_ymm[16];
2084ed093b41SRobert Mustacchi#else
2085ed093b41SRobert Mustacchi	upad128_t	prx_ymm[8];
2086ed093b41SRobert Mustacchi	upad128_t	prx_rsvd[8];
2087ed093b41SRobert Mustacchi#endif
2088ed093b41SRobert Mustacchi} prxregset_ymm_t;
2089ed093b41SRobert Mustacchi.Ed
2090ed093b41SRobert Mustacchi.It Dv PRX_INFO_OPMASK - Vt prxregset_opmask_t
2091ed093b41SRobert MustacchiThis structure represents one portion of Intel's AVX-512 state: the 8 64-bit
2092ed093b41SRobert Mustacchimask registers, %k0 through %k7.
2093ed093b41SRobert MustacchiThe structure looks like:
2094ed093b41SRobert Mustacchi.Bd -literal -offset 2
2095ed093b41SRobert Mustacchitypedef struct prxregset_opmask {
2096ed093b41SRobert Mustacchi	uint64_t	prx_opmask[8];
2097ed093b41SRobert Mustacchi} prxregset_opmask_t;
2098ed093b41SRobert Mustacchi.Ed
2099ed093b41SRobert Mustacchi.It Dv PRX_INFO_ZMM - Vt prxregset_zmm_t
2100ed093b41SRobert MustacchiThis structure represents one portion of Intel's AVX-512 state: the upper
2101ed093b41SRobert Mustacchi256 bits of the 512-bit %zmm0 through %zmm15 registers.
2102ed093b41SRobert MustacchiBits 0-127 are found in the
2103ed093b41SRobert Mustacchi.Fa prx_fx_xmm
2104ed093b41SRobert Mustacchimember of the
2105ed093b41SRobert Mustacchi.Dv PRX_INFO_XSAVE
2106ed093b41SRobert Mustacchidata and bits 128-255 are found in the
2107ed093b41SRobert Mustacchi.Fa prx_ymm
2108ed093b41SRobert Mustacchimember of the
2109ed093b41SRobert Mustacchi.Dv PRX_INFO_YMM .
2110ed093b41SRobert Mustacchi32-bit applications only have access to %zmm0 through %zmm7.
2111ed093b41SRobert MustacchiThis structure looks like:
2112ed093b41SRobert Mustacchi.Bd -literal -offset 2
2113ed093b41SRobert Mustacchitypedef struct prxregset_zmm {
2114ed093b41SRobert Mustacchi#if defined(__amd64)
2115ed093b41SRobert Mustacchi	upad256_t	prx_zmm[16];
2116ed093b41SRobert Mustacchi#else
2117ed093b41SRobert Mustacchi	upad256_t	prx_zmm[8];
2118ed093b41SRobert Mustacchi	upad256_t	prx_rsvd[8];
2119ed093b41SRobert Mustacchi#endif
2120ed093b41SRobert Mustacchi} prxregset_zmm_t;
2121ed093b41SRobert Mustacchi.Ed
2122ed093b41SRobert Mustacchi.It Dv PRX_INFO_HI_ZMM - Vt prxregset_hi_zmm_t
2123ed093b41SRobert MustacchiThis structure represents the third portion of Intel's AVX-512 state: the
2124ed093b41SRobert Mustacchiadditional 16 512-bit registers that are available to 64-bit applications, but
2125ed093b41SRobert Mustacchinot 32-bit applications.
2126ed093b41SRobert MustacchiThis represents %zmm16 through %zmm31.
2127ed093b41SRobert MustacchiThis structure looks like:
2128ed093b41SRobert Mustacchi.Bd -literal -offset indent
2129ed093b41SRobert Mustacchitypedef struct prxregset_hi_zmm {
2130ed093b41SRobert Mustacchi#if defined(__amd64)
2131ed093b41SRobert Mustacchi	upad512_t	prx_hi_zmm[16];
2132ed093b41SRobert Mustacchi#else
2133ed093b41SRobert Mustacchi	upad512_t	prx_rsvd[16];
2134ed093b41SRobert Mustacchi#endif
2135ed093b41SRobert Mustacchi} prxregset_hi_zmm_t;
2136ed093b41SRobert Mustacchi.Pp
2137ed093b41SRobert MustacchiUnlike the other lower %zmm registers of %zmm0 through %zmm15, this contains the
2138ed093b41SRobert Mustacchientire 512-bit register in one spot and there is no need to look at other
2139ed093b41SRobert Mustacchiinformation items to reconstitute the entire vector.
2140ed093b41SRobert Mustacchi.Ed
2141ed093b41SRobert Mustacchi.Pp
2142ed093b41SRobert MustacchiWhen setting the extended registers, at least the
2143ed093b41SRobert Mustacchi.Dv PRX_INFO_XSAVE
2144ed093b41SRobert Mustacchicomponent must be present.
2145ed093b41SRobert MustacchiNone of the component offsets may overlap with the
2146ed093b41SRobert Mustacchi.Vt prxregset_hdr_t
2147ed093b41SRobert Mustacchior any of the
2148ed093b41SRobert Mustacchi.Vt prxregset_info_t
2149ed093b41SRobert Mustacchistructures.
2150ed093b41SRobert MustacchiWhen constructing the overall payload, it is expected that the various
2151ed093b41SRobert Mustacchistructures start with their naturally expected alignment, which is most
2152ed093b41SRobert Mustacchioften 16 bytes
2153ed093b41SRobert Mustacchi.Po
2154ed093b41SRobert Mustacchithat is the value that the C
2155ed093b41SRobert Mustacchi.Fn alignof
2156ed093b41SRobert Mustacchikeyword will return
2157ed093b41SRobert Mustacchi.Pc .
2158ed093b41SRobert MustacchiThe structures that we use are all multiples of 16 bytes to make this easier.
2159ed093b41SRobert MustacchiNote, when reading the x86 xregs file, the kernel will write out these
2160ed093b41SRobert Mustacchistructures with increased alignment beyond the natural alignment of the
2161ed093b41SRobert Mustacchistructure.
2162ed093b41SRobert MustacchiThe kernel does this so that the structure's data may be more easily used
2163ed093b41SRobert Mustacchidirectly by x86 instructions that require alignment such as vmovdqu64.
2164ed093b41SRobert Mustacchi.El
2165bbf21555SRichard Lowe.Sh CONTROL MESSAGES
2166bbf21555SRichard LoweProcess state changes are effected through messages written to a process's
2167bbf21555SRichard Lowe.Sy ctl
2168bbf21555SRichard Lowefile or to an individual lwp's
2169bbf21555SRichard Lowe.Sy lwpctl
2170bbf21555SRichard Lowefile.
2171bbf21555SRichard LoweAll control messages consist of a
2172bbf21555SRichard Lowe.Sy long
2173bbf21555SRichard Lowethat names the specific operation followed by
2174bbf21555SRichard Loweadditional data containing the operand, if any.
2175bbf21555SRichard Lowe.Pp
2176bbf21555SRichard LoweMultiple control messages may be combined in a single
2177bbf21555SRichard Lowe.Xr write 2
2178bbf21555SRichard Lowe(or
2179bbf21555SRichard Lowe.Xr writev 2 )
2180bbf21555SRichard Loweto a control file, but no partial writes are permitted.
2181bbf21555SRichard LoweThat is, each control message, operation code plus operand, if any, must be
2182bbf21555SRichard Lowepresented in its entirety to the
2183bbf21555SRichard Lowe.Xr write 2
2184bbf21555SRichard Loweand not in pieces over several system calls.
2185bbf21555SRichard LoweIf a control operation fails, no subsequent operations contained in the same
2186bbf21555SRichard Lowe.Xr write 2
2187bbf21555SRichard Loweare attempted.
2188bbf21555SRichard Lowe.Pp
2189bbf21555SRichard LoweDescriptions of the allowable control messages follow.
2190bbf21555SRichard LoweIn all cases, writing a message to a control file for a process or lwp that
2191bbf21555SRichard Lowehas terminated elicits the error
2192bbf21555SRichard Lowe.Er ENOENT .
2193bbf21555SRichard Lowe.Ss PCSTOP PCDSTOP PCWSTOP PCTWSTOP
2194bbf21555SRichard LoweWhen applied to the process control file,
2195bbf21555SRichard Lowe.Sy PCSTOP
2196bbf21555SRichard Lowedirects all lwps to stop and waits for them to stop,
2197bbf21555SRichard Lowe.Sy PCDSTOP
2198bbf21555SRichard Lowedirects all lwps to stop without waiting for them to stop, and
2199bbf21555SRichard Lowe.Sy PCWSTOP
2200bbf21555SRichard Lowesimply waits for all lwps to stop.
2201bbf21555SRichard LoweWhen applied to an lwp control file,
2202bbf21555SRichard Lowe.Sy PCSTOP
2203bbf21555SRichard Lowedirects the specific lwp to stop and waits until it has stopped,
2204bbf21555SRichard Lowe.Sy PCDSTOP
2205bbf21555SRichard Lowedirects the specific lwp to stop without waiting for it to stop, and
2206bbf21555SRichard Lowe.Sy PCWSTOP
2207bbf21555SRichard Lowesimply waits for the specific lwp to stop.
2208bbf21555SRichard LoweWhen applied to an lwp control file,
2209bbf21555SRichard Lowe.Sy PCSTOP
2210bbf21555SRichard Loweand
2211bbf21555SRichard Lowe.Sy PCWSTOP
2212bbf21555SRichard Lowecomplete when the lwp stops on an event of interest, immediately
2213bbf21555SRichard Loweif already so stopped; when applied to the process control file, they complete
2214bbf21555SRichard Lowewhen every lwp has stopped either on an event of interest or on a
2215bbf21555SRichard Lowe.Sy PR_SUSPENDED
2216bbf21555SRichard Lowestop.
2217bbf21555SRichard Lowe.Pp
2218bbf21555SRichard Lowe.Sy PCTWSTOP
2219bbf21555SRichard Loweis identical to
2220bbf21555SRichard Lowe.Sy PCWSTOP
2221bbf21555SRichard Loweexcept that it enables the operation to time out, to avoid waiting forever for
2222bbf21555SRichard Lowea process or lwp that may never stop on an event of interest.
2223bbf21555SRichard Lowe.Sy PCTWSTOP
2224bbf21555SRichard Lowetakes a
2225bbf21555SRichard Lowe.Sy long
2226bbf21555SRichard Loweoperand specifying a number of milliseconds; the wait will terminate
2227bbf21555SRichard Lowesuccessfully after the specified number of milliseconds even if the process or
2228bbf21555SRichard Lowelwp has not stopped; a timeout value of zero makes the operation identical to
2229bbf21555SRichard Lowe.Sy PCWSTOP .
2230bbf21555SRichard Lowe.Pp
2231bbf21555SRichard LoweAn
2232bbf21555SRichard Lowe.Dq event of interest
2233bbf21555SRichard Loweis either a
2234bbf21555SRichard Lowe.Sy PR_REQUESTED
2235bbf21555SRichard Lowestop or a stop that has been specified in the process's tracing flags (set by
2236bbf21555SRichard Lowe.Sy PCSTRACE ,
2237bbf21555SRichard Lowe.Sy PCSFAULT ,
2238bbf21555SRichard Lowe.Sy PCSENTRY ,
2239bbf21555SRichard Loweand
2240bbf21555SRichard Lowe.Sy PCSEXIT ) .
2241bbf21555SRichard Lowe.Sy PR_JOBCONTROL
2242bbf21555SRichard Loweand
2243bbf21555SRichard Lowe.Sy PR_SUSPENDED
2244bbf21555SRichard Lowestops are specifically not events of interest.
2245bbf21555SRichard Lowe(An lwp may stop twice due to a stop signal, first showing
2246bbf21555SRichard Lowe.Sy PR_SIGNALLED
2247bbf21555SRichard Loweif the signal is traced and again showing
2248bbf21555SRichard Lowe.Sy PR_JOBCONTROL
2249bbf21555SRichard Loweif the lwp is set running without clearing the signal.)
2250bbf21555SRichard LoweIf
2251bbf21555SRichard Lowe.Sy PCSTOP
2252bbf21555SRichard Loweor
2253bbf21555SRichard Lowe.Sy PCDSTOP
2254bbf21555SRichard Loweis applied to an
2255bbf21555SRichard Lowelwp that is stopped, but not on an event of interest, the stop directive takes
2256bbf21555SRichard Loweeffect when the lwp is restarted by the competing mechanism.
2257bbf21555SRichard LoweAt that time, the lwp enters a
2258bbf21555SRichard Lowe.Sy PR_REQUESTED
2259bbf21555SRichard Lowestop before executing any user-level code.
2260bbf21555SRichard Lowe.Pp
2261bbf21555SRichard LoweA write of a control message that blocks is interruptible by a signal so that,
2262bbf21555SRichard Lowefor example, an
2263bbf21555SRichard Lowe.Xr alarm 2
2264bbf21555SRichard Lowecan be set to avoid waiting forever for a
2265bbf21555SRichard Loweprocess or lwp that may never stop on an event of interest.
2266bbf21555SRichard LoweIf
2267bbf21555SRichard Lowe.Sy PCSTOP
2268bbf21555SRichard Loweis interrupted, the lwp stop directives remain in effect even though the
2269bbf21555SRichard Lowe.Xr write 2
2270bbf21555SRichard Lowereturns an error.
2271bbf21555SRichard Lowe(Use of
2272bbf21555SRichard Lowe.Sy PCTWSTOP
2273bbf21555SRichard Lowewith a non-zero timeout is recommended over
2274bbf21555SRichard Lowe.Sy PCWSTOP
2275bbf21555SRichard Lowewith an
2276bbf21555SRichard Lowe.Xr alarm 2 . )
2277bbf21555SRichard Lowe.Pp
2278bbf21555SRichard LoweA system process (indicated by the
2279bbf21555SRichard Lowe.Sy PR_ISSYS
2280bbf21555SRichard Loweflag) never executes at user level, has no user-level address space visible
2281bbf21555SRichard Lowethrough
2282bbf21555SRichard Lowe.Pa /proc ,
2283bbf21555SRichard Loweand cannot be stopped.
2284bbf21555SRichard LoweApplying one of these operations to a system process or any of its
2285bbf21555SRichard Lowelwps elicits the error
2286bbf21555SRichard Lowe.Er EBUSY .
2287bbf21555SRichard Lowe.Ss PCRUN
2288bbf21555SRichard LoweMake an lwp runnable again after a stop.
2289bbf21555SRichard LoweThis operation takes a
2290bbf21555SRichard Lowe.Vt long
2291bbf21555SRichard Loweoperand containing zero or more of the following flags:
2292bbf21555SRichard Lowe.Bl -tag -width "PRSABORT" -offset left
2293bbf21555SRichard Lowe.It Sy PRCSIG
2294bbf21555SRichard Loweclears the current signal, if any (see
2295bbf21555SRichard Lowe.Sx PCCSIG ) .
2296bbf21555SRichard Lowe.It Sy PRCFAULT
2297bbf21555SRichard Loweclears the current fault, if any (see
2298bbf21555SRichard Lowe.Sx PCCFAULT ) .
2299bbf21555SRichard Lowe.It Sy PRSTEP
2300bbf21555SRichard Lowedirects the lwp to execute a single machine instruction.
2301bbf21555SRichard LoweOn completion of the instruction, a trace trap occurs.
2302bbf21555SRichard LoweIf
2303bbf21555SRichard Lowe.Sy FLTTRACE
2304bbf21555SRichard Loweis being traced, the lwp stops; otherwise, it is sent
2305bbf21555SRichard Lowe.Sy SIGTRAP .
2306bbf21555SRichard LoweIf
2307bbf21555SRichard Lowe.Sy SIGTRAP
2308bbf21555SRichard Loweis being traced and is not blocked, the lwp stops.
2309bbf21555SRichard LoweWhen the lwp stops on an event of interest,
2310bbf21555SRichard Lowethe single-step directive is cancelled, even if the stop occurs before the
2311bbf21555SRichard Loweinstruction is executed.
2312bbf21555SRichard LoweThis operation requires hardware and operating system
2313bbf21555SRichard Lowesupport and may not be implemented on all processors.
2314bbf21555SRichard LoweIt is implemented on SPARC and x86-based machines.
2315bbf21555SRichard Lowe.It Sy PRSABORT
2316bbf21555SRichard Loweis meaningful only if the lwp is in a
2317bbf21555SRichard Lowe.Sy PR_SYSENTRY
2318bbf21555SRichard Lowestop or is marked
2319bbf21555SRichard Lowe.Sy PR_ASLEEP ;
2320bbf21555SRichard Loweit instructs the lwp to abort execution of the system call (see
2321bbf21555SRichard Lowe.Sx PCSENTRY
2322bbf21555SRichard Loweand
2323bbf21555SRichard Lowe.Sx PCSEXIT ) .
2324bbf21555SRichard Lowe.It Sy PRSTOP
2325bbf21555SRichard Lowedirects the lwp to stop again as soon as possible after resuming execution (see
2326bbf21555SRichard Lowe.Sx PCDSTOP ) .
2327bbf21555SRichard LoweIn particular, if the lwp is stopped on
2328bbf21555SRichard Lowe.Sy PR_SIGNALLED
2329bbf21555SRichard Loweor
2330bbf21555SRichard Lowe.Sy PR_FAULTED ,
2331bbf21555SRichard Lowethe next stop will show
2332bbf21555SRichard Lowe.Sy PR_REQUESTED ,
2333bbf21555SRichard Loweno other stop
2334bbf21555SRichard Lowewill have intervened, and the lwp will not have executed any user-level code.
2335bbf21555SRichard Lowe.El
2336bbf21555SRichard Lowe.Pp
2337bbf21555SRichard LoweWhen applied to an lwp control file,
2338bbf21555SRichard Lowe.Sy PCRUN
2339bbf21555SRichard Loweclears any outstanding
2340bbf21555SRichard Lowedirected-stop request and makes the specific lwp runnable.
2341bbf21555SRichard LoweThe operation fails with
2342bbf21555SRichard Lowe.Er EBUSY
2343bbf21555SRichard Loweif the specific lwp is not stopped on an event of interest or
2344bbf21555SRichard Lowehas not been directed to stop or if the agent lwp exists and this is not the
2345bbf21555SRichard Loweagent lwp (see
2346bbf21555SRichard Lowe.Sx PCAGENT ) .
2347bbf21555SRichard Lowe.Pp
2348bbf21555SRichard LoweWhen applied to the process control file, a representative lwp is chosen for
2349bbf21555SRichard Lowethe operation as described for
2350bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /status .
2351bbf21555SRichard LoweThe operation fails with
2352bbf21555SRichard Lowe.Er EBUSY
2353bbf21555SRichard Loweif the representative lwp is not stopped on an
2354bbf21555SRichard Loweevent of interest or has not been directed to stop or if the agent lwp exists.
2355bbf21555SRichard LoweIf
2356bbf21555SRichard Lowe.Sy PRSTEP
2357bbf21555SRichard Loweor
2358bbf21555SRichard Lowe.Sy PRSTOP
2359bbf21555SRichard Lowewas requested, the representative lwp is made
2360bbf21555SRichard Lowerunnable and its outstanding directed-stop request is cleared; otherwise all
2361bbf21555SRichard Loweoutstanding directed-stop requests are cleared and, if it was stopped on an
2362bbf21555SRichard Loweevent of interest, the representative lwp is marked
2363bbf21555SRichard Lowe.Sy PR_REQUESTED .
2364bbf21555SRichard LoweIf, as a consequence, all lwps are in the
2365bbf21555SRichard Lowe.Sy PR_REQUESTED
2366bbf21555SRichard Loweor
2367bbf21555SRichard Lowe.Sy PR_SUSPENDED
2368bbf21555SRichard Lowestop state, all lwps showing
2369bbf21555SRichard Lowe.Sy PR_REQUESTED
2370bbf21555SRichard Loweare made runnable.
2371bbf21555SRichard Lowe.Ss PCSTRACE
2372bbf21555SRichard LoweDefine a set of signals to be traced in the process.
2373bbf21555SRichard LoweThe receipt of one of these signals by an lwp causes the lwp to stop.
2374bbf21555SRichard LoweThe set of signals is defined using an operand
2375bbf21555SRichard Lowe.Sy sigset_t
2376bbf21555SRichard Lowecontained in the control message.
2377bbf21555SRichard LoweReceipt of
2378bbf21555SRichard Lowe.Sy SIGKILL
2379bbf21555SRichard Lowecannot be traced; if specified, it is silently ignored.
2380bbf21555SRichard Lowe.Pp
2381bbf21555SRichard LoweIf a signal that is included in an lwp's held signal set (the signal mask) is
2382bbf21555SRichard Lowesent to the lwp, the signal is not received and does not cause a stop until it
2383bbf21555SRichard Loweis removed from the held signal set, either by the lwp itself or by setting the
2384bbf21555SRichard Loweheld signal set with
2385bbf21555SRichard Lowe.Sy PCSHOLD .
2386bbf21555SRichard Lowe.Ss PCCSIG
2387bbf21555SRichard LoweThe current signal, if any, is cleared from the specific or representative lwp.
2388bbf21555SRichard Lowe.Ss PCSSIG
2389bbf21555SRichard LoweThe current signal and its associated signal information for the specific or
2390bbf21555SRichard Lowerepresentative lwp are set according to the contents of the operand
2391bbf21555SRichard Lowe.Vt siginfo
2392bbf21555SRichard Lowestructure (see
2393bbf21555SRichard Lowe.In sys/siginfo.h ) .
2394bbf21555SRichard LoweIf the specified signal number is zero, the current signal is cleared.
2395bbf21555SRichard LoweThe semantics of this operation are different from those of
2396bbf21555SRichard Lowe.Xr kill 2
2397bbf21555SRichard Lowein that the signal is delivered to the lwp immediately after execution is
2398bbf21555SRichard Loweresumed (even if it is being blocked) and an additional
2399bbf21555SRichard Lowe.Sy PR_SIGNALLED
2400bbf21555SRichard Lowestop does not intervene even if the signal is traced.
2401bbf21555SRichard LoweSetting the current signal to
2402bbf21555SRichard Lowe.Sy SIGKILL
2403bbf21555SRichard Loweterminates the process immediately.
2404bbf21555SRichard Lowe.Ss PCKILL
2405bbf21555SRichard LoweIf applied to the process control file, a signal is sent to the process with
2406bbf21555SRichard Lowesemantics identical to those of
2407bbf21555SRichard Lowe.Xr kill 2
2408bbf21555SRichard LoweIf applied to an lwp control file, a directed signal is sent to the specific
2409bbf21555SRichard Lowelwp.
2410bbf21555SRichard LoweThe signal is named in a
2411bbf21555SRichard Lowe.Vt long
2412bbf21555SRichard Loweoperand contained in the message.
2413bbf21555SRichard LoweSending
2414bbf21555SRichard Lowe.Sy SIGKILL
2415bbf21555SRichard Loweterminates the process immediately.
2416bbf21555SRichard Lowe.Ss PCUNKILL
2417bbf21555SRichard LoweA signal is deleted, that is, it is removed from the set of pending signals.
2418bbf21555SRichard LoweIf applied to the process control file, the signal is deleted from the process's
2419bbf21555SRichard Lowepending signals.
2420bbf21555SRichard LoweIf applied to an lwp control file, the signal is deleted from
2421bbf21555SRichard Lowethe lwp's pending signals.
2422bbf21555SRichard LoweThe current signal (if any) is unaffected.
2423bbf21555SRichard LoweThe signal is named in a
2424bbf21555SRichard Lowe.Sy long
2425bbf21555SRichard Loweoperand in the control message.
2426bbf21555SRichard LoweIt is an error
2427bbf21555SRichard Lowe.Pq Er EINVAL
2428bbf21555SRichard Loweto attempt to delete
2429bbf21555SRichard Lowe.Sy SIGKILL .
2430bbf21555SRichard Lowe.Ss PCSHOLD
2431bbf21555SRichard LoweSet the set of held signals for the specific or representative lwp (signals
2432bbf21555SRichard Lowewhose delivery will be blocked if sent to the lwp).
2433bbf21555SRichard LoweThe set of signals is specified with a
2434bbf21555SRichard Lowe.Vt sigset_t
2435bbf21555SRichard Loweoperand.
2436bbf21555SRichard Lowe.Sy SIGKILL
2437bbf21555SRichard Loweand
2438bbf21555SRichard Lowe.Sy SIGSTOP
2439bbf21555SRichard Lowecannot be held; if specified, they are silently ignored.
2440bbf21555SRichard Lowe.Ss PCSFAULT
2441bbf21555SRichard LoweDefine a set of hardware faults to be traced in the process.
2442bbf21555SRichard LoweOn incurring one of these faults, an lwp stops.
2443bbf21555SRichard LoweThe set is defined via the operand
2444bbf21555SRichard Lowe.Vt fltset_t
2445bbf21555SRichard Lowestructure.
2446bbf21555SRichard LoweFault names are defined in
2447bbf21555SRichard Lowe.In sys/fault.h
2448bbf21555SRichard Loweand include the following.
2449bbf21555SRichard LoweSome of these may not occur on all processors; there may
2450bbf21555SRichard Lowebe processor-specific faults in addition to these.
2451bbf21555SRichard Lowe.Bl -tag -width "FLTACCESS" -offset indent
2452bbf21555SRichard Lowe.It Sy FLTILL
2453bbf21555SRichard Loweillegal instruction
2454bbf21555SRichard Lowe.It Sy FLTPRIV
2455bbf21555SRichard Loweprivileged instruction
2456bbf21555SRichard Lowe.It Sy FLTBPT
2457bbf21555SRichard Lowebreakpoint trap
2458bbf21555SRichard Lowe.It Sy FLTTRACE
2459bbf21555SRichard Lowetrace trap (single-step)
2460bbf21555SRichard Lowe.It Sy FLTWATCH
2461bbf21555SRichard Lowewatchpoint trap
2462bbf21555SRichard Lowe.It Sy FLTACCESS
2463bbf21555SRichard Lowememory access fault (bus error)
2464bbf21555SRichard Lowe.It Sy FLTBOUNDS
2465bbf21555SRichard Lowememory bounds violation
2466bbf21555SRichard Lowe.It Sy FLTIOVF
2467bbf21555SRichard Loweinteger overflow
2468bbf21555SRichard Lowe.It Sy FLTIZDIV
2469bbf21555SRichard Loweinteger zero divide
2470bbf21555SRichard Lowe.It Sy FLTFPE
2471bbf21555SRichard Lowefloating-point exception
2472bbf21555SRichard Lowe.It Sy FLTSTACK
2473bbf21555SRichard Loweunrecoverable stack fault
2474bbf21555SRichard Lowe.It Sy FLTPAGE
2475bbf21555SRichard Lowerecoverable page fault
2476bbf21555SRichard Lowe.El
2477bbf21555SRichard Lowe.Pp
2478bbf21555SRichard LoweWhen not traced, a fault normally results in the posting of a signal to the lwp
2479bbf21555SRichard Lowethat incurred the fault.
2480bbf21555SRichard LoweIf an lwp stops on a fault, the signal is posted to
2481bbf21555SRichard Lowethe lwp when execution is resumed unless the fault is cleared by
2482bbf21555SRichard Lowe.Sy PCCFAULT
2483bbf21555SRichard Loweor by the
2484bbf21555SRichard Lowe.Sy PRCFAULT
2485bbf21555SRichard Loweoption of
2486bbf21555SRichard Lowe.Sy PCRUN .
2487bbf21555SRichard Lowe.Sy FLTPAGE
2488bbf21555SRichard Loweis an exception; no signal is posted.
2489bbf21555SRichard LoweThe
2490bbf21555SRichard Lowe.Sy pr_info
2491bbf21555SRichard Lowefield in the
2492bbf21555SRichard Lowe.Vt lwpstatus
2493bbf21555SRichard Lowestructure identifies the signal to be sent and contains machine-specific
2494bbf21555SRichard Loweinformation about the fault.
2495bbf21555SRichard Lowe.Ss PCCFAULT
2496bbf21555SRichard LoweThe current fault, if any, is cleared; the associated signal will not be sent
2497bbf21555SRichard Loweto the specific or representative lwp.
2498bbf21555SRichard Lowe.Ss PCSENTRY PCSEXIT
2499bbf21555SRichard LoweThese control operations instruct the process's lwps to stop on entry to or
2500bbf21555SRichard Loweexit from specified system calls.
2501bbf21555SRichard LoweThe set of system calls to be traced is defined via an operand
2502bbf21555SRichard Lowe.Vt sysset_t
2503bbf21555SRichard Lowestructure.
2504bbf21555SRichard Lowe.Pp
2505bbf21555SRichard LoweWhen entry to a system call is being traced, an lwp stops after having begun
2506bbf21555SRichard Lowethe call to the system but before the system call arguments have been fetched
2507bbf21555SRichard Lowefrom the lwp.
2508bbf21555SRichard LoweWhen exit from a system call is being traced, an lwp stops on completion of
2509bbf21555SRichard Lowethe system call just prior to checking for signals and returning to user level.
2510bbf21555SRichard LoweAt this point, all return values have been stored into the lwp's registers.
2511bbf21555SRichard Lowe.Pp
2512bbf21555SRichard LoweIf an lwp is stopped on entry to a system call
2513bbf21555SRichard Lowe.Pq Sy PR_SYSENTRY
2514bbf21555SRichard Loweor when sleeping in an interruptible system call
2515bbf21555SRichard Lowe.Pf ( Sy PR_ASLEEP
2516bbf21555SRichard Loweis set), it may be instructed to go directly to system call exit by specifying
2517bbf21555SRichard Lowethe
2518bbf21555SRichard Lowe.Sy PRSABORT
2519bbf21555SRichard Loweflag in a
2520bbf21555SRichard Lowe.Sy PCRUN
2521bbf21555SRichard Lowecontrol message.
2522bbf21555SRichard LoweUnless exit from the system call is being traced, the lwp returns to user
2523bbf21555SRichard Lowelevel showing
2524bbf21555SRichard Lowe.Er EINTR .
2525bbf21555SRichard Lowe.Ss PCWATCH
2526bbf21555SRichard LoweSet or clear a watched area in the controlled process from a
2527bbf21555SRichard Lowe.Vt prwatch
2528bbf21555SRichard Lowestructure operand:
2529bbf21555SRichard Lowe.Bd -literal -offset 2
2530bbf21555SRichard Lowetypedef struct prwatch {
2531bbf21555SRichard Lowe    uintptr_t pr_vaddr;  /* virtual address of watched area */
2532bbf21555SRichard Lowe    size_t pr_size;      /* size of watched area in bytes */
2533bbf21555SRichard Lowe    int pr_wflags;       /* watch type flags */
2534bbf21555SRichard Lowe} prwatch_t;
2535bbf21555SRichard Lowe.Ed
2536bbf21555SRichard Lowe.Pp
2537bbf21555SRichard Lowe.Sy pr_vaddr
2538bbf21555SRichard Lowespecifies the virtual address of an area of memory to be watched
2539bbf21555SRichard Lowein the controlled process.
2540bbf21555SRichard Lowe.Sy pr_size
2541bbf21555SRichard Lowespecifies the size of the area, in bytes.
2542bbf21555SRichard Lowe.Sy pr_wflags
2543bbf21555SRichard Lowespecifies the type of memory access to be monitored as a
2544bbf21555SRichard Lowebit-mask of the following flags:
2545bbf21555SRichard Lowe.Bl -tag -width "WA_TRAPAFTER" -offset indent
2546bbf21555SRichard Lowe.It Sy WA_READ
2547bbf21555SRichard Loweread access
2548bbf21555SRichard Lowe.It Sy WA_WRITE
2549bbf21555SRichard Lowewrite access
2550bbf21555SRichard Lowe.It Sy WA_EXEC
2551bbf21555SRichard Loweexecution access
2552bbf21555SRichard Lowe.It Sy WA_TRAPAFTER
2553bbf21555SRichard Lowetrap after the instruction completes
2554bbf21555SRichard Lowe.El
2555bbf21555SRichard Lowe.Pp
2556bbf21555SRichard LoweIf
2557bbf21555SRichard Lowe.Sy pr_wflags
2558bbf21555SRichard Loweis non-empty, a watched area is established for the virtual
2559bbf21555SRichard Loweaddress range specified by
2560bbf21555SRichard Lowe.Sy pr_vaddr
2561bbf21555SRichard Loweand
2562bbf21555SRichard Lowe.Sy pr_size .
2563bbf21555SRichard LoweIf
2564bbf21555SRichard Lowe.Sy pr_wflags
2565bbf21555SRichard Loweis empty, any previously-established watched area starting at the specified
2566bbf21555SRichard Lowevirtual address is cleared;
2567bbf21555SRichard Lowe.Sy pr_size
2568bbf21555SRichard Loweis ignored.
2569bbf21555SRichard Lowe.Pp
2570bbf21555SRichard LoweA watchpoint is triggered when an lwp in the traced process makes a memory
2571bbf21555SRichard Lowereference that covers at least one byte of a watched area and the memory
2572bbf21555SRichard Lowereference is as specified in
2573bbf21555SRichard Lowe.Sy pr_wflags .
2574bbf21555SRichard LoweWhen an lwp triggers a watchpoint, it incurs a watchpoint trap.
2575bbf21555SRichard LoweIf
2576bbf21555SRichard Lowe.Sy FLTWATCH
2577bbf21555SRichard Loweis being traced, the lwp stops; otherwise, it is sent a
2578bbf21555SRichard Lowe.Sy SIGTRAP
2579bbf21555SRichard Lowesignal; if
2580bbf21555SRichard Lowe.Sy SIGTRAP
2581bbf21555SRichard Loweis being traced and is not blocked, the lwp stops.
2582bbf21555SRichard Lowe.Pp
2583bbf21555SRichard LoweThe watchpoint trap occurs before the instruction completes unless
2584bbf21555SRichard Lowe.Sy WA_TRAPAFTER
2585bbf21555SRichard Lowewas specified, in which case it occurs after the instruction completes.
2586bbf21555SRichard LoweIf it occurs before completion, the memory is not modified.
2587bbf21555SRichard LoweIf it occurs after completion, the memory is modified (if the access is a write
2588bbf21555SRichard Loweaccess).
2589bbf21555SRichard Lowe.Pp
2590bbf21555SRichard LowePhysical i/o is an exception for watchpoint traps.
2591bbf21555SRichard LoweIn this instance, there is no guarantee that memory before the watched area
2592bbf21555SRichard Lowehas already been modified (or in the case of
2593bbf21555SRichard Lowe.Sy WA_TRAPAFTER ,
2594bbf21555SRichard Lowethat the memory following the watched area
2595bbf21555SRichard Lowehas not been modified) when the watchpoint trap occurs and the lwp stops.
2596bbf21555SRichard Lowe.Pp
2597bbf21555SRichard Lowe.Sy pr_info
2598bbf21555SRichard Lowein the
2599bbf21555SRichard Lowe.Vt lwpstatus
2600bbf21555SRichard Lowestructure contains information pertinent to the watchpoint trap.
2601bbf21555SRichard LoweIn particular, the
2602bbf21555SRichard Lowe.Sy si_addr
2603bbf21555SRichard Lowefield contains the
2604bbf21555SRichard Lowevirtual address of the memory reference that triggered the watchpoint, and the
2605bbf21555SRichard Lowe.Sy si_code
2606bbf21555SRichard Lowefield contains one of
2607bbf21555SRichard Lowe.Sy TRAP_RWATCH ,
2608bbf21555SRichard Lowe.Sy TRAP_WWATCH ,
2609bbf21555SRichard Loweor
2610bbf21555SRichard Lowe.Sy TRAP_XWATCH ,
2611bbf21555SRichard Loweindicating read, write, or execute access, respectively.
2612bbf21555SRichard LoweThe
2613bbf21555SRichard Lowe.Sy si_trapafter
2614bbf21555SRichard Lowefield is zero unless
2615bbf21555SRichard Lowe.Sy WA_TRAPAFTER
2616bbf21555SRichard Loweis in effect for this watched area; non-zero indicates that the current
2617bbf21555SRichard Loweinstruction is not the instruction that incurred the watchpoint trap.
2618bbf21555SRichard LoweThe
2619bbf21555SRichard Lowe.Sy si_pc
2620bbf21555SRichard Lowefield contains the virtual address of the instruction that incurred the trap.
2621bbf21555SRichard Lowe.Pp
2622bbf21555SRichard LoweA watchpoint trap may be triggered while executing a system call that makes
2623bbf21555SRichard Lowereference to the traced process's memory.
2624bbf21555SRichard LoweThe lwp that is executing the system call incurs the watchpoint trap while
2625bbf21555SRichard Lowestill in the system call.
2626bbf21555SRichard LoweIf it stops as a result, the
2627bbf21555SRichard Lowe.Vt lwpstatus
2628bbf21555SRichard Lowestructure contains the system call number and its arguments.
2629bbf21555SRichard LoweIf the lwp does not stop, or if it is set running again without
2630bbf21555SRichard Loweclearing the signal or fault, the system call fails with
2631bbf21555SRichard Lowe.Er EFAULT .
2632bbf21555SRichard LoweIf
2633bbf21555SRichard Lowe.Sy WA_TRAPAFTER
2634bbf21555SRichard Lowewas specified, the memory reference will have completed and
2635bbf21555SRichard Lowethe memory will have been modified (if the access was a write access) when the
2636bbf21555SRichard Lowewatchpoint trap occurs.
2637bbf21555SRichard Lowe.Pp
2638bbf21555SRichard LoweIf more than one of
2639bbf21555SRichard Lowe.Sy WA_READ ,
2640bbf21555SRichard Lowe.Sy WA_WRITE ,
2641bbf21555SRichard Loweand
2642bbf21555SRichard Lowe.Sy WA_EXEC
2643bbf21555SRichard Loweis specified for a watched area, and a single instruction incurs more than one
2644bbf21555SRichard Loweof the specified types, only one is reported when the watchpoint trap occurs.
2645bbf21555SRichard LoweThe precedence is
2646bbf21555SRichard Lowe.Sy WA_EXEC ,
2647bbf21555SRichard Lowe.Sy WA_READ ,
2648bbf21555SRichard Lowe.Sy WA_WRITE
2649bbf21555SRichard Lowe.Pf ( Sy WA_EXEC
2650bbf21555SRichard Loweand
2651bbf21555SRichard Lowe.Sy WA_READ
2652bbf21555SRichard Lowetake precedence over
2653bbf21555SRichard Lowe.Sy WA_WRITE ) ,
2654bbf21555SRichard Loweunless
2655bbf21555SRichard Lowe.Sy WA_TRAPAFTER
2656bbf21555SRichard Lowewas specified, in which case it is
2657bbf21555SRichard Lowe.Sy WA_WRITE ,
2658bbf21555SRichard Lowe.Sy WA_READ ,
2659bbf21555SRichard Lowe.Sy WA_EXEC
2660bbf21555SRichard Lowe.Pf ( Sy WA_WRITE
2661bbf21555SRichard Lowetakes precedence).
2662bbf21555SRichard Lowe.Pp
2663bbf21555SRichard Lowe.Sy PCWATCH
2664bbf21555SRichard Lowefails with
2665bbf21555SRichard Lowe.Er EINVAL
2666bbf21555SRichard Loweif an attempt is made to specify overlapping watched areas or if
2667bbf21555SRichard Lowe.Sy pr_wflags
2668bbf21555SRichard Lowecontains flags other than those specified above.
2669bbf21555SRichard LoweIt fails with
2670bbf21555SRichard Lowe.Er ENOMEM
2671bbf21555SRichard Loweif an attempt is made to establish more watched areas than the system can
2672bbf21555SRichard Lowesupport (the system can support thousands).
2673bbf21555SRichard Lowe.Pp
2674bbf21555SRichard LoweThe child of a
2675bbf21555SRichard Lowe.Xr vfork 2
2676bbf21555SRichard Loweborrows the parent's address space.
2677bbf21555SRichard LoweWhen a
2678bbf21555SRichard Lowe.Xr vfork 2
2679bbf21555SRichard Loweis executed by a traced process, all watched areas established
2680bbf21555SRichard Lowefor the parent are suspended until the child terminates or performs an
2681bbf21555SRichard Lowe.Xr exec 2 .
2682bbf21555SRichard LoweAny watched areas established independently in the child are
2683bbf21555SRichard Lowecancelled when the parent resumes after the child's termination or
2684bbf21555SRichard Lowe.Xr exec 2 .
2685bbf21555SRichard Lowe.Sy PCWATCH
2686bbf21555SRichard Lowefails with
2687bbf21555SRichard Lowe.Er EBUSY
2688bbf21555SRichard Loweif applied to the parent of a
2689bbf21555SRichard Lowe.Xr vfork 2
2690bbf21555SRichard Lowebefore the child has terminated or performed an
2691bbf21555SRichard Lowe.Xr exec 2 .
2692bbf21555SRichard LoweThe
2693bbf21555SRichard Lowe.Sy PR_VFORKP
2694bbf21555SRichard Loweflag is set in the
2695bbf21555SRichard Lowe.Sy pstatus
2696bbf21555SRichard Lowestructure for such a parent process.
2697bbf21555SRichard Lowe.Pp
2698bbf21555SRichard LoweCertain accesses of the traced process's address space by the operating system
2699bbf21555SRichard Loweare immune to watchpoints.
2700bbf21555SRichard LoweThe initial construction of a signal stack frame when a signal is delivered to
2701bbf21555SRichard Lowean lwp will not trigger a watchpoint trap even if the new frame covers watched
2702bbf21555SRichard Loweareas of the stack.
2703bbf21555SRichard LoweOnce the signal handler is entered, watchpoint traps occur normally.
2704bbf21555SRichard LoweOn SPARC based machines, register window overflow and underflow will not
2705bbf21555SRichard Lowetrigger watchpoint traps, even if the register window save areas cover watched
2706bbf21555SRichard Loweareas of the stack.
2707bbf21555SRichard Lowe.Pp
2708bbf21555SRichard LoweWatched areas are not inherited by child processes, even if the traced
2709bbf21555SRichard Loweprocess's inherit-on-fork mode,
2710bbf21555SRichard Lowe.Sy PR_FORK ,
2711bbf21555SRichard Loweis set (see
2712bbf21555SRichard Lowe.Sy PCSET ,
2713bbf21555SRichard Lowebelow).
2714bbf21555SRichard LoweAll watched areas are cancelled when the traced process performs a successful
2715bbf21555SRichard Lowe.Xr exec 2 .
2716bbf21555SRichard Lowe.Ss PCSET PCUNSET
2717bbf21555SRichard Lowe.Sy PCSET
2718bbf21555SRichard Lowesets one or more modes of operation for the traced process.
2719bbf21555SRichard Lowe.Sy PCUNSET
2720bbf21555SRichard Loweunsets these modes.
2721bbf21555SRichard LoweThe modes to be set or unset are specified by flags in an operand
2722bbf21555SRichard Lowe.Sy long
2723bbf21555SRichard Lowein the control message:
2724bbf21555SRichard Lowe.Bl -tag -offset left -width "PR_MSFORK"
2725bbf21555SRichard Lowe.It Sy PR_FORK
2726bbf21555SRichard Lowe(inherit-on-fork): When set, the process's tracing flags and its
2727bbf21555SRichard Loweinherit-on-fork mode are inherited by the child of a
2728bbf21555SRichard Lowe.Xr fork 2 ,
2729bbf21555SRichard Lowe.Xr fork1 2 ,
2730bbf21555SRichard Loweor
2731bbf21555SRichard Lowe.Xr vfork 2 .
2732bbf21555SRichard LoweWhen unset, child processes start with all tracing flags cleared.
2733bbf21555SRichard Lowe.It Sy PR_RLC
2734bbf21555SRichard Lowe(run-on-last-close): When set and the last writable
2735bbf21555SRichard Lowe.Pa /proc
2736bbf21555SRichard Lowefile descriptor referring to the traced process or any of its lwps is closed,
2737bbf21555SRichard Loweall of the process's tracing flags and watched areas are cleared, any
2738bbf21555SRichard Loweoutstanding stop directives are canceled, and if any lwps are stopped on
2739bbf21555SRichard Loweevents of interest, they are set running as though
2740bbf21555SRichard Lowe.Sy PCRUN
2741bbf21555SRichard Lowehad been applied to them.
2742bbf21555SRichard LoweWhen unset, the process's tracing flags and watched areas are retained and
2743bbf21555SRichard Lowelwps are not set running on last close.
2744bbf21555SRichard Lowe.It Sy PR_KLC
2745bbf21555SRichard Lowe(kill-on-last-close): When set and the last writable
2746bbf21555SRichard Lowe.Pa /proc
2747bbf21555SRichard Lowefile descriptor referring to the traced process or any of its lwps is closed,
2748bbf21555SRichard Lowethe process is terminated with
2749bbf21555SRichard Lowe.Sy SIGKILL .
2750bbf21555SRichard Lowe.It Sy PR_ASYNC
2751bbf21555SRichard Lowe(asynchronous-stop): When set, a stop on an event of interest by one lwp does
2752bbf21555SRichard Lowenot directly affect any other lwp in the process.
2753bbf21555SRichard LoweWhen unset and an lwp stops on an event of interest other than
2754bbf21555SRichard Lowe.Sy PR_REQUESTED ,
2755bbf21555SRichard Loweall other lwps in the process are directed to stop.
2756bbf21555SRichard Lowe.It Sy PR_MSACCT
2757bbf21555SRichard Lowe(microstate accounting): Microstate accounting is now continuously enabled.
2758bbf21555SRichard LoweThis flag is deprecated and no longer has any effect upon microstate
2759bbf21555SRichard Loweaccounting.
2760bbf21555SRichard LoweApplications may toggle this flag; however, microstate accounting
2761bbf21555SRichard Lowewill remain enabled regardless.
2762bbf21555SRichard Lowe.It Sy PR_MSFORK
2763bbf21555SRichard Lowe(inherit microstate accounting): All processes now inherit microstate
2764bbf21555SRichard Loweaccounting, as it is continuously enabled.
2765bbf21555SRichard LoweThis flag has been deprecated and its use no longer has any effect upon the
2766bbf21555SRichard Lowebehavior of microstate accounting.
2767bbf21555SRichard Lowe.It Sy PR_BPTADJ
2768bbf21555SRichard Lowe(breakpoint trap pc adjustment): On x86-based machines, a breakpoint trap
2769bbf21555SRichard Loweleaves the program counter (the
2770bbf21555SRichard Lowe.Sy EIP )
2771bbf21555SRichard Lowereferring to the breakpointed instruction plus one byte.
2772bbf21555SRichard LoweWhen
2773bbf21555SRichard Lowe.Sy PR_BPTADJ
2774bbf21555SRichard Loweis set, the system will adjust the program counter back to the location of the
2775bbf21555SRichard Lowebreakpointed instruction when the lwp stops on a breakpoint.
2776bbf21555SRichard LoweThis flag has no effect on SPARC based machines, where breakpoint traps leave
2777bbf21555SRichard Lowethe program counter referring to the breakpointed instruction.
2778bbf21555SRichard Lowe.It Sy PR_PTRACE
2779bbf21555SRichard Lowe(ptrace-compatibility): When set, a stop on an event of interest by the traced
2780bbf21555SRichard Loweprocess is reported to the parent of the traced process by
2781bbf21555SRichard Lowe.Xr wait 3C ,
2782bbf21555SRichard Lowe.Sy SIGTRAP
2783bbf21555SRichard Loweis sent to the traced process when it executes a successful
2784bbf21555SRichard Lowe.Xr exec 2 ,
2785bbf21555SRichard Lowesetuid/setgid flags are not honored for execs performed by the
2786bbf21555SRichard Lowetraced process, any exec of an object file that the traced process cannot read
2787bbf21555SRichard Lowefails, and the process dies when its parent dies.
2788bbf21555SRichard LoweThis mode is deprecated; it is provided only to allow
2789bbf21555SRichard Lowe.Xr ptrace 3C
2790bbf21555SRichard Loweto be implemented as a library function using
2791bbf21555SRichard Lowe.Pa /proc .
2792bbf21555SRichard Lowe.El
2793bbf21555SRichard Lowe.Pp
2794bbf21555SRichard LoweIt is an error
2795bbf21555SRichard Lowe.Pq Er EINVAL
2796bbf21555SRichard Loweto specify flags other than those described above
2797bbf21555SRichard Loweor to apply these operations to a system process.
2798bbf21555SRichard LoweThe current modes are reported in the
2799bbf21555SRichard Lowe.Sy pr_flags
2800bbf21555SRichard Lowefield of
2801bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /status
2802bbf21555SRichard Loweand
2803bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwp Ns Pa /lwpstatus .
2804bbf21555SRichard Lowe.Ss PCSREG
2805bbf21555SRichard LoweSet the general registers for the specific or representative lwp according to
2806bbf21555SRichard Lowethe operand
2807bbf21555SRichard Lowe.Vt prgregset_t
2808bbf21555SRichard Lowestructure.
2809bbf21555SRichard Lowe.Pp
2810bbf21555SRichard LoweOn SPARC based systems, only the condition-code bits of the processor-status
2811bbf21555SRichard Loweregister (R_PSR) of SPARC V8 (32-bit) processes can be modified by
2812bbf21555SRichard Lowe.Sy PCSREG .
2813bbf21555SRichard LoweOther privileged registers cannot be modified at all.
2814bbf21555SRichard Lowe.Pp
2815bbf21555SRichard LoweOn x86-based systems, only certain bits of the flags register (EFL) can be
2816bbf21555SRichard Lowemodified by
2817bbf21555SRichard Lowe.Sy PCSREG :
2818bbf21555SRichard Lowethese include the condition codes, direction-bit, and overflow-bit.
2819bbf21555SRichard Lowe.Pp
2820bbf21555SRichard Lowe.Sy PCSREG
2821bbf21555SRichard Lowefails with
2822bbf21555SRichard Lowe.Er EBUSY
2823bbf21555SRichard Loweif the lwp is not stopped on an event of interest.
2824bbf21555SRichard Lowe.Ss PCSVADDR
2825bbf21555SRichard LoweSet the address at which execution will resume for the specific or
2826bbf21555SRichard Lowerepresentative lwp from the operand
2827bbf21555SRichard Lowe.Vt long .
2828bbf21555SRichard LoweOn SPARC based systems, both %pc and %npc are set, with %npc set to the
2829bbf21555SRichard Loweinstruction following the virtual address.
2830bbf21555SRichard LoweOn x86-based systems, only %eip is set.
2831bbf21555SRichard Lowe.Sy PCSVADDR
2832bbf21555SRichard Lowefails with
2833bbf21555SRichard Lowe.Er EBUSY
2834bbf21555SRichard Loweif the lwp is not stopped on an event of interest.
2835bbf21555SRichard Lowe.Ss PCSFPREG
2836bbf21555SRichard LoweSet the floating-point registers for the specific or representative lwp
2837bbf21555SRichard Loweaccording to the operand
2838bbf21555SRichard Lowe.Vt prfpregset_t
2839bbf21555SRichard Lowestructure.
2840bbf21555SRichard LoweAn error
2841bbf21555SRichard Lowe.Pq Er EINVAL
2842bbf21555SRichard Loweis returned if the system does not support floating-point operations (no
2843bbf21555SRichard Lowefloating-point hardware and the system does not emulate floating-point machine
2844bbf21555SRichard Loweinstructions).
2845bbf21555SRichard Lowe.Sy PCSFPREG
2846bbf21555SRichard Lowefails with
2847bbf21555SRichard Lowe.Er EBUSY
2848bbf21555SRichard Loweif the lwp is not stopped on an event of interest.
2849bbf21555SRichard Lowe.Ss PCSXREG
2850bbf21555SRichard LoweSet the extra state registers for the specific or representative lwp according
2851bbf21555SRichard Loweto the architecture-dependent operand
2852bbf21555SRichard Lowe.Vt prxregset_t
2853bbf21555SRichard Lowestructure.
2854bbf21555SRichard LoweAn error
2855bbf21555SRichard Lowe.Pq Er EINVAL
2856ed093b41SRobert Mustacchiis returned if the system does not support extra state registers or the register
2857ed093b41SRobert Mustacchistate is invalid.
2858bbf21555SRichard Lowe.Sy PCSXREG
2859bbf21555SRichard Lowefails with
2860bbf21555SRichard Lowe.Er EBUSY
2861bbf21555SRichard Loweif the lwp is not stopped on an event of interest.
2862bbf21555SRichard Lowe.Ss PCSASRS
2863bbf21555SRichard LoweSet the ancillary state registers for the specific or representative lwp
2864bbf21555SRichard Loweaccording to the SPARC V9 platform-dependent operand
2865bbf21555SRichard Lowe.Vt asrset_t
2866bbf21555SRichard Lowestructure.
2867bbf21555SRichard LoweAn error
2868bbf21555SRichard Lowe.Pq Er EINVAL
2869bbf21555SRichard Loweis returned if either the target process or the
2870bbf21555SRichard Lowecontrolling process is not a 64-bit SPARC V9 process.
2871bbf21555SRichard LoweMost of the ancillary state registers are privileged registers that cannot be
2872bbf21555SRichard Lowemodified.
2873bbf21555SRichard LoweOnly those that can be modified are set; all others are silently ignored.
2874bbf21555SRichard Lowe.Sy PCSASRS
2875bbf21555SRichard Lowefails with
2876bbf21555SRichard Lowe.Er EBUSY
2877bbf21555SRichard Loweif the lwp is not stopped on an event of interest.
2878bbf21555SRichard Lowe.Ss PCAGENT
2879bbf21555SRichard LoweCreate an agent lwp in the controlled process with register values from the
2880bbf21555SRichard Loweoperand
2881bbf21555SRichard Lowe.Vt prgregset_t
2882bbf21555SRichard Lowestructure (see
2883bbf21555SRichard Lowe.Sy PCSREG ,
2884bbf21555SRichard Loweabove).
2885bbf21555SRichard LoweThe agent lwp is created in the stopped state showing
2886bbf21555SRichard Lowe.Sy PR_REQUESTED
2887bbf21555SRichard Loweand with its held signal set (the signal mask) having all signals except
2888bbf21555SRichard Lowe.Sy SIGKILL
2889bbf21555SRichard Loweand
2890bbf21555SRichard Lowe.Sy SIGSTOP
2891bbf21555SRichard Loweblocked.
2892bbf21555SRichard Lowe.Pp
2893bbf21555SRichard LoweThe
2894bbf21555SRichard Lowe.Sy PCAGENT
2895bbf21555SRichard Loweoperation fails with
2896bbf21555SRichard Lowe.Er EBUSY
2897bbf21555SRichard Loweunless the process is fully stopped via
2898bbf21555SRichard Lowe.Pa /proc ,
2899bbf21555SRichard Lowethat is, unless all of the lwps in the process are
2900bbf21555SRichard Lowestopped either on events of interest or on
2901bbf21555SRichard Lowe.Sy PR_SUSPENDED ,
2902bbf21555SRichard Loweor are stopped on
2903bbf21555SRichard Lowe.Sy PR_JOBCONTROL
2904bbf21555SRichard Loweand have been directed to stop via
2905bbf21555SRichard Lowe.Sy PCDSTOP .
2906bbf21555SRichard LoweIt fails with
2907bbf21555SRichard Lowe.Er EBUSY
2908bbf21555SRichard Loweif an agent lwp already exists.
2909bbf21555SRichard LoweIt fails with
2910bbf21555SRichard Lowe.Er ENOMEM
2911bbf21555SRichard Loweif system resources for creating new lwps have been exhausted.
2912bbf21555SRichard Lowe.Pp
2913bbf21555SRichard LoweAny
2914bbf21555SRichard Lowe.Sy PCRUN
2915bbf21555SRichard Loweoperation applied to the process control file or to the control
2916bbf21555SRichard Lowefile of an lwp other than the agent lwp fails with
2917bbf21555SRichard Lowe.Er EBUSY
2918bbf21555SRichard Loweas long as the agent lwp exists.
2919bbf21555SRichard LoweThe agent lwp must be caused to terminate by executing the
2920bbf21555SRichard Lowe.Sy SYS_lwp_exit
2921bbf21555SRichard Lowesystem call trap before the process can be restarted.
2922bbf21555SRichard Lowe.Pp
2923bbf21555SRichard LoweOnce the agent lwp is created, its lwp-ID can be found by reading the process
2924bbf21555SRichard Lowestatus file.
2925bbf21555SRichard LoweTo facilitate opening the agent lwp's control and status files,
2926bbf21555SRichard Lowethe directory name
2927bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /lwp/agent
2928bbf21555SRichard Loweis accepted for lookup operations as an invisible alias for
2929bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid ,
2930bbf21555SRichard Lowe.Em lwpid
2931bbf21555SRichard Lowebeing the lwp-ID of the agent lwp (invisible in the sense that the name
2932bbf21555SRichard Lowe.Dq agent
2933bbf21555SRichard Lowedoes not appear in a directory listing of
2934bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /lwp
2935bbf21555SRichard Loweobtained from
2936bbf21555SRichard Lowe.Xr ls 1 ,
2937bbf21555SRichard Lowe.Xr getdents 2 ,
2938bbf21555SRichard Loweor
2939bbf21555SRichard Lowe.Xr readdir 3C .
2940bbf21555SRichard Lowe.Pp
2941bbf21555SRichard LoweThe purpose of the agent lwp is to perform operations in the controlled process
2942bbf21555SRichard Loweon behalf of the controlling process: to gather information not directly
2943bbf21555SRichard Loweavailable via
2944bbf21555SRichard Lowe.Pa /proc
2945bbf21555SRichard Lowefiles, or in general to make the process change state
2946bbf21555SRichard Lowein ways not directly available via
2947bbf21555SRichard Lowe.Pa /proc
2948bbf21555SRichard Lowecontrol operations.
2949bbf21555SRichard LoweTo make use of an agent lwp, the controlling process must be capable of making
2950bbf21555SRichard Loweit execute system calls (specifically, the
2951bbf21555SRichard Lowe.Sy SYS_lwp_exit
2952bbf21555SRichard Lowesystem call trap).
2953bbf21555SRichard LoweThe register values given to the agent lwp on creation are typically the
2954bbf21555SRichard Loweregisters of the representative lwp, so that the agent lwp can use its stack.
2955bbf21555SRichard Lowe.Pp
2956bbf21555SRichard LoweIf the controlling process neglects to force the agent lwp to execute the
2957bbf21555SRichard Lowe.Sy SYS_lwp_exit
2958bbf21555SRichard Lowesystem call (due to either logic error or fatal failure on
2959bbf21555SRichard Lowethe part of the controlling process), the agent lwp will remain in the target
2960bbf21555SRichard Loweprocess.
2961bbf21555SRichard LoweFor purposes of being able to debug these otherwise rogue agents,
2962bbf21555SRichard Loweinformation as to the creator of the agent lwp is reflected in that lwp's
2963bbf21555SRichard Lowe.Pa spymaster
2964bbf21555SRichard Lowefile in
2965bbf21555SRichard Lowe.Pa /proc .
2966bbf21555SRichard LoweShould the target process generate a core
2967bbf21555SRichard Lowedump with the agent lwp in place, this information will be available via the
2968bbf21555SRichard Lowe.Sy NT_SPYMASTER
2969bbf21555SRichard Lowenote in the core file (see
2970bbf21555SRichard Lowe.Xr core 5 ) .
2971bbf21555SRichard Lowe.Pp
2972bbf21555SRichard LoweThe agent lwp is not allowed to execute any variation of the
2973bbf21555SRichard Lowe.Sy SYS_fork
2974bbf21555SRichard Loweor
2975bbf21555SRichard Lowe.Sy SYS_exec
2976bbf21555SRichard Lowesystem call traps.
2977bbf21555SRichard LoweAttempts to do so yield
2978bbf21555SRichard Lowe.Er ENOTSUP
2979bbf21555SRichard Loweto the agent lwp.
2980bbf21555SRichard Lowe.Pp
2981bbf21555SRichard LoweSymbolic constants for system call trap numbers like
2982bbf21555SRichard Lowe.Sy SYS_lwp_exit
2983bbf21555SRichard Loweand
2984bbf21555SRichard Lowe.Sy SYS_lwp_create
2985bbf21555SRichard Lowecan be found in the header file
2986bbf21555SRichard Lowe.In sys/syscall.h .
2987bbf21555SRichard Lowe.Ss PCREAD PCWRITE
2988bbf21555SRichard LoweRead or write the target process's address space via a
2989bbf21555SRichard Lowe.Vt priovec
2990bbf21555SRichard Lowestructure operand:
2991bbf21555SRichard Lowe.Bd -literal -offset 2
2992bbf21555SRichard Lowetypedef struct priovec {
2993bbf21555SRichard Lowe    void *pio_base;      /* buffer in controlling process */
2994bbf21555SRichard Lowe    size_t pio_len;      /* size of read/write request in bytes */
2995bbf21555SRichard Lowe    off_t pio_offset;    /* virtual address in target process */
2996bbf21555SRichard Lowe} priovec_t;
2997bbf21555SRichard Lowe.Ed
2998bbf21555SRichard Lowe.Pp
2999bbf21555SRichard LoweThese operations have the same effect as
3000bbf21555SRichard Lowe.Xr pread 2
3001bbf21555SRichard Loweand
3002bbf21555SRichard Lowe.Xr pwrite 2 ,
3003bbf21555SRichard Lowerespectively, of the target process's address space file.
3004bbf21555SRichard LoweThe difference is that more than one
3005bbf21555SRichard Lowe.Sy PCREAD
3006bbf21555SRichard Loweor
3007bbf21555SRichard Lowe.Sy PCWRITE
3008bbf21555SRichard Lowecontrol operation can be
3009bbf21555SRichard Lowewritten to the control file at once, and they can be interspersed with other
3010bbf21555SRichard Lowecontrol operations in a single write to the control file.
3011bbf21555SRichard LoweThis is useful, for example, when planting many breakpoint instructions in
3012bbf21555SRichard Lowethe process's address space, or when stepping over a breakpointed instruction.
3013bbf21555SRichard LoweUnlike
3014bbf21555SRichard Lowe.Xr pread 2
3015bbf21555SRichard Loweand
3016bbf21555SRichard Lowe.Xr pwrite 2 ,
3017bbf21555SRichard Loweno provision is made for partial reads or writes; if the
3018bbf21555SRichard Loweoperation cannot be performed completely, it fails with
3019bbf21555SRichard Lowe.Er EIO .
3020bbf21555SRichard Lowe.Ss PCNICE
3021bbf21555SRichard LoweThe traced process's
3022bbf21555SRichard Lowe.Xr nice 2
3023bbf21555SRichard Lowevalue is incremented by the amount in the
3024bbf21555SRichard Loweoperand
3025bbf21555SRichard Lowe.Vt long .
3026bbf21555SRichard LoweOnly a process with the
3027bbf21555SRichard Lowe.Brq Sy PRIV_PROC_PRIOCNTL
3028bbf21555SRichard Loweprivilege asserted in its effective set can better a process's priority in this
3029bbf21555SRichard Loweway, but any user may lower the priority.
3030bbf21555SRichard LoweThis operation is not meaningful for all scheduling classes.
3031bbf21555SRichard Lowe.Ss PCSCRED
3032bbf21555SRichard LoweSet the target process credentials to the values contained in the
3033bbf21555SRichard Lowe.Vt prcred_t
3034bbf21555SRichard Lowestructure operand (see
3035bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /cred ) .
3036bbf21555SRichard LoweThe
3037bbf21555SRichard Loweeffective, real, and saved user-IDs and group-IDs of the target process are
3038bbf21555SRichard Loweset.
3039bbf21555SRichard LoweThe target process's supplementary groups are not changed; the
3040bbf21555SRichard Lowe.Sy pr_ngroups
3041bbf21555SRichard Loweand
3042bbf21555SRichard Lowe.Sy pr_groups
3043bbf21555SRichard Lowemembers of the structure operand are ignored.
3044bbf21555SRichard LoweOnly the privileged processes can perform this operation; for all
3045bbf21555SRichard Loweothers it fails with
3046bbf21555SRichard Lowe.Er EPERM .
3047bbf21555SRichard Lowe.Ss PCSCREDX
3048bbf21555SRichard LoweOperates like
3049bbf21555SRichard Lowe.Sy PCSCRED
3050bbf21555SRichard Lowebut also sets the supplementary groups; the length
3051bbf21555SRichard Loweof the data written with this control operation should be "sizeof
3052bbf21555SRichard Lowe.Pq Vt prcred_t
3053bbf21555SRichard Lowe+ sizeof
3054bbf21555SRichard Lowe.Pq Vt gid_t
3055bbf21555SRichard Lowe* (#groups - 1)".
3056bbf21555SRichard Lowe.Ss PCSPRIV
3057bbf21555SRichard LoweSet the target process privilege to the values contained in the
3058bbf21555SRichard Lowe.Vt prpriv_t
3059bbf21555SRichard Loweoperand (see
3060bbf21555SRichard Lowe.Pa /proc/pid/priv ) .
3061bbf21555SRichard LoweThe effective, permitted, inheritable, and
3062bbf21555SRichard Lowelimit sets are all changed.
3063bbf21555SRichard LowePrivilege flags can also be set.
3064bbf21555SRichard LoweThe process is made privilege aware unless it can relinquish privilege awareness.
3065bbf21555SRichard LoweSee
3066bbf21555SRichard Lowe.Xr privileges 7 .
3067bbf21555SRichard Lowe.Pp
3068bbf21555SRichard LoweThe limit set of the target process cannot be grown.
3069bbf21555SRichard LoweThe other privilege sets must be subsets of the intersection of the effective set
3070bbf21555SRichard Loweof the calling process with the new limit set of the target process or subsets of
3071bbf21555SRichard Lowethe original values of the sets in the target process.
3072bbf21555SRichard Lowe.Pp
3073bbf21555SRichard LoweIf any of the above restrictions are not met,
3074bbf21555SRichard Lowe.Er EPERM
3075bbf21555SRichard Loweis returned.
3076bbf21555SRichard LoweIf the structure written is improperly formatted,
3077bbf21555SRichard Lowe.Er EINVAL
3078bbf21555SRichard Loweis returned.
3079bbf21555SRichard Lowe.Sh PROGRAMMING NOTES
3080bbf21555SRichard LoweFor security reasons, except for the
3081bbf21555SRichard Lowe.Sy psinfo ,
3082bbf21555SRichard Lowe.Sy usage ,
3083bbf21555SRichard Lowe.Sy lpsinfo ,
3084bbf21555SRichard Lowe.Sy lusage ,
3085bbf21555SRichard Lowe.Sy lwpsinfo ,
3086bbf21555SRichard Loweand
3087bbf21555SRichard Lowe.Sy lwpusage
3088bbf21555SRichard Lowefiles, which are world-readable, and except for privileged processes, an open
3089bbf21555SRichard Loweof a
3090bbf21555SRichard Lowe.Pa /proc
3091bbf21555SRichard Lowefile fails unless both the user-ID and group-ID of the caller match those of
3092bbf21555SRichard Lowethe traced process and the process's object file is readable by the caller.
3093bbf21555SRichard LoweThe effective set of the caller is a superset of both the inheritable and the
3094bbf21555SRichard Lowepermitted set of the target process.
3095bbf21555SRichard LoweThe limit set of the caller is a superset of the limit set of the target
3096bbf21555SRichard Loweprocess.
3097bbf21555SRichard LoweExcept for the world-readable files just mentioned, files corresponding to
3098bbf21555SRichard Lowesetuid and setgid processes can be opened only by the appropriately privileged
3099bbf21555SRichard Loweprocess.
3100bbf21555SRichard Lowe.Pp
3101bbf21555SRichard LoweA process that is missing the basic privilege
3102bbf21555SRichard Lowe.Brq Sy PRIV_PROC_INFO
3103bbf21555SRichard Lowecannot see any processes under
3104bbf21555SRichard Lowe.Pa /proc
3105bbf21555SRichard Lowethat it cannot send a signal to.
3106bbf21555SRichard Lowe.Pp
3107bbf21555SRichard LoweA process that has
3108bbf21555SRichard Lowe.Brq Sy PRIV_PROC_OWNER
3109bbf21555SRichard Loweasserted in its effective set can open any file for reading.
3110bbf21555SRichard LoweTo manipulate or control a process, the controlling process must have at least
3111bbf21555SRichard Loweas many privileges in its effective set as the target process has in its
3112bbf21555SRichard Loweeffective, inheritable, and permitted sets.
3113bbf21555SRichard LoweThe limit set of the controlling process must be a superset of the limit set
3114bbf21555SRichard Loweof the target process.
3115bbf21555SRichard LoweAdditional restrictions apply if any of the uids of the target process are 0.
3116bbf21555SRichard LoweSee
3117bbf21555SRichard Lowe.Xr privileges 7 .
3118bbf21555SRichard Lowe.Pp
3119bbf21555SRichard LoweEven if held by a privileged process, an open process or lwp file descriptor
3120bbf21555SRichard Lowe(other than file descriptors for the world-readable files) becomes invalid if
3121bbf21555SRichard Lowethe traced process performs an
3122bbf21555SRichard Lowe.Xr exec 2
3123bbf21555SRichard Loweof a setuid/setgid object file or
3124bbf21555SRichard Lowean object file that the traced process cannot read.
3125bbf21555SRichard LoweAny operation performed on an invalid file descriptor, except
3126bbf21555SRichard Lowe.Xr close 2 ,
3127bbf21555SRichard Lowefails with
3128bbf21555SRichard Lowe.Er EAGAIN .
3129bbf21555SRichard LoweIn this situation, if any tracing flags are set and the process or any lwp
3130bbf21555SRichard Lowefile descriptor is open for writing, the process will have been directed to
3131bbf21555SRichard Lowestop and its run-on-last-close flag will have been set (see
3132bbf21555SRichard Lowe.Sx PCSET ) .
3133bbf21555SRichard LoweThis enables a controlling process (if it has permission) to reopen the
3134bbf21555SRichard Lowe.Pa /proc
3135bbf21555SRichard Lowefiles to get new valid file descriptors, close the invalid file descriptors,
3136bbf21555SRichard Loweunset the run-on-last-close flag (if desired), and proceed.
3137bbf21555SRichard LoweJust closing the invalid file descriptors causes the traced process to resume
3138bbf21555SRichard Loweexecution with all tracing flags cleared.
3139bbf21555SRichard LoweAny process not currently open for writing via
3140bbf21555SRichard Lowe.Pa /proc ,
3141bbf21555SRichard Lowebut that has left-over tracing flags from a previous open, and that executes
3142bbf21555SRichard Lowea setuid/setgid or unreadable object file, will not be stopped but will have
3143bbf21555SRichard Loweall its tracing flags cleared.
3144bbf21555SRichard Lowe.Pp
3145bbf21555SRichard LoweTo wait for one or more of a set of processes or lwps to stop or terminate,
3146bbf21555SRichard Lowe.Pa /proc
3147bbf21555SRichard Lowefile descriptors (other than those obtained by opening the
3148bbf21555SRichard Lowe.Pa cwd
3149bbf21555SRichard Loweor
3150bbf21555SRichard Lowe.Pa root
3151bbf21555SRichard Lowedirectories or by opening files in the
3152bbf21555SRichard Lowe.Pa fd
3153bbf21555SRichard Loweor
3154bbf21555SRichard Lowe.Pa object
3155bbf21555SRichard Lowedirectories) can be used in a
3156bbf21555SRichard Lowe.Xr poll 2
3157bbf21555SRichard Lowesystem call.
3158bbf21555SRichard LoweWhen requested and returned, either of the polling events
3159bbf21555SRichard Lowe.Sy POLLPRI
3160bbf21555SRichard Loweor
3161bbf21555SRichard Lowe.Sy POLLWRNORM
3162bbf21555SRichard Loweindicates that the process or lwp stopped on an event of
3163bbf21555SRichard Loweinterest.
3164bbf21555SRichard LoweAlthough they cannot be requested, the polling events
3165bbf21555SRichard Lowe.Sy POLLHUP ,
3166bbf21555SRichard Lowe.Sy POLLERR ,
3167bbf21555SRichard Loweand
3168bbf21555SRichard Lowe.Sy POLLNVAL
3169bbf21555SRichard Lowemay be returned.
3170bbf21555SRichard Lowe.Sy POLLHUP
3171bbf21555SRichard Loweindicates that the process or lwp has terminated.
3172bbf21555SRichard Lowe.Sy POLLERR
3173bbf21555SRichard Loweindicates that the file descriptor has become invalid.
3174bbf21555SRichard Lowe.Sy POLLNVAL
3175bbf21555SRichard Loweis returned immediately if
3176bbf21555SRichard Lowe.Sy POLLPRI
3177bbf21555SRichard Loweor
3178bbf21555SRichard Lowe.Sy POLLWRNORM
3179bbf21555SRichard Loweis requested on a file descriptor referring to a system process (see
3180bbf21555SRichard Lowe.Sx  PCSTOP ) .
3181bbf21555SRichard LoweThe requested events may be empty to wait simply for termination.
3182bbf21555SRichard Lowe.Sh FILES
3183bbf21555SRichard Lowe.Bl -tag -compact -width Ds
3184bbf21555SRichard Lowe.It Pa /proc
3185bbf21555SRichard Lowedirectory (list of processes)
3186bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid
3187bbf21555SRichard Lowespecific process directory
3188bbf21555SRichard Lowe.It Pa /proc/self
3189bbf21555SRichard Lowealias for a process's own directory
3190bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /as
3191bbf21555SRichard Loweaddress space file
3192bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /ctl
3193bbf21555SRichard Loweprocess control file
3194bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /status
3195bbf21555SRichard Loweprocess status
3196bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lstatus
3197bbf21555SRichard Lowearray of lwp status structs
3198bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /psinfo
3199bbf21555SRichard Loweprocess
3200bbf21555SRichard Lowe.Xr ps 1
3201bbf21555SRichard Loweinfo
3202bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lpsinfo
3203bbf21555SRichard Lowearray of lwp
3204bbf21555SRichard Lowe.Xr ps 1
3205bbf21555SRichard Loweinfo structs
3206bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /map
3207bbf21555SRichard Loweaddress space map
3208bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /xmap
3209bbf21555SRichard Loweextended address space map
3210bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /rmap
3211bbf21555SRichard Lowereserved address map
3212bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /cred
3213bbf21555SRichard Loweprocess credentials
3214bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /priv
3215bbf21555SRichard Loweprocess privileges
3216bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /sigact
3217bbf21555SRichard Loweprocess signal actions
3218bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /auxv
3219bbf21555SRichard Loweprocess aux vector
3220bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /ldt
3221bbf21555SRichard Loweprocess
3222bbf21555SRichard Lowe.Sy LDT
3223bbf21555SRichard Lowe(x86 only)
3224bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /usage
3225bbf21555SRichard Loweprocess usage
3226bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lusage
3227bbf21555SRichard Lowearray of lwp usage structs
3228bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /path
3229bbf21555SRichard Lowesymbolic links to process open files
3230bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /pagedata
3231bbf21555SRichard Loweprocess page data
3232bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /watch
3233bbf21555SRichard Loweactive watchpoints
3234bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /cwd
3235bbf21555SRichard Lowealias for the current working directory
3236bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /root
3237bbf21555SRichard Lowealias for the root directory
3238bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /fd
3239bbf21555SRichard Lowedirectory (list of open files)
3240bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /fd/*
3241bbf21555SRichard Lowealiases for process's open files
3242bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /object
3243bbf21555SRichard Lowedirectory (list of mapped files)
3244bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /object/a.out
3245bbf21555SRichard Lowealias for process's executable file
3246bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /object/*
3247bbf21555SRichard Lowealiases for other mapped files
3248bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lwp
3249bbf21555SRichard Lowedirectory (list of lwps)
3250bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid
3251bbf21555SRichard Lowespecific lwp directory
3252bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lwp/agent
3253bbf21555SRichard Lowealias for the agent lwp directory
3254bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid Ns Pa /lwpctl
3255bbf21555SRichard Lowelwp control file
3256bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid Ns Pa /lwpstatus
3257bbf21555SRichard Lowelwp status
3258bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid Ns Pa /lwpsinfo
3259bbf21555SRichard Lowelwp
3260bbf21555SRichard Lowe.Xr ps 1
3261bbf21555SRichard Loweinfo
3262bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid Ns Pa /lwpusage
3263bbf21555SRichard Lowelwp usage
3264bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid Ns Pa /gwindows
3265bbf21555SRichard Loweregister windows (SPARC only)
3266bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid Ns Pa /xregs
3267bbf21555SRichard Loweextra state registers
3268bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid Ns Pa /asrs
3269bbf21555SRichard Loweancillary state registers (SPARC V9 only)
3270bbf21555SRichard Lowe.It Pa /proc/ Ns Em pid Ns Pa /lwp/ Ns Em lwpid Ns Pa /spymaster
3271bbf21555SRichard LoweFor an agent LWP, the controlling process
3272bbf21555SRichard Lowe.El
3273bbf21555SRichard Lowe.Sh DIAGNOSTICS
3274bbf21555SRichard LoweErrors that can occur in addition to the errors normally associated with file
3275bbf21555SRichard Lowesystem access:
3276bbf21555SRichard Lowe.Bl -tag -width "EOVERFLOW" -offset left
3277bbf21555SRichard Lowe.It Er E2BIG
3278bbf21555SRichard LoweData to be returned in a
3279bbf21555SRichard Lowe.Xr read 2
3280bbf21555SRichard Loweof the page data file exceeds the size of the read buffer provided by the
3281bbf21555SRichard Lowecaller.
3282bbf21555SRichard Lowe.It Er EACCES
3283bbf21555SRichard LoweAn attempt was made to examine a process that ran under a different uid than
3284bbf21555SRichard Lowethe controlling process and
3285bbf21555SRichard Lowe.Brq Sy PRIV_PROC_OWNER
3286bbf21555SRichard Lowewas not asserted in the effective set.
3287bbf21555SRichard Lowe.It Er EAGAIN
3288bbf21555SRichard LoweThe traced process has performed an
3289bbf21555SRichard Lowe.Xr exec 2
3290bbf21555SRichard Loweof a setuid/setgid object
3291bbf21555SRichard Lowefile or of an object file that it cannot read; all further operations on the
3292bbf21555SRichard Loweprocess or lwp file descriptor (except
3293bbf21555SRichard Lowe.Xr close 2 )
3294bbf21555SRichard Loweelicit this error.
3295bbf21555SRichard Lowe.It Er EBUSY
3296bbf21555SRichard Lowe.Sy PCSTOP ,
3297bbf21555SRichard Lowe.Sy PCDSTOP ,
3298bbf21555SRichard Lowe.Sy PCWSTOP , or
3299bbf21555SRichard Lowe.Sy PCTWSTOP
3300bbf21555SRichard Lowewas applied to a system process; an exclusive
3301bbf21555SRichard Lowe.Xr open 2
3302bbf21555SRichard Lowewas attempted on a
3303bbf21555SRichard Lowe.Pa /proc
3304bbf21555SRichard Lowefile for a process already open for writing;
3305bbf21555SRichard Lowe.Sy PCRUN ,
3306bbf21555SRichard Lowe.Sy PCSREG ,
3307bbf21555SRichard Lowe.Sy PCSVADDR ,
3308bbf21555SRichard Lowe.Sy PCSFPREG ,
3309bbf21555SRichard Loweor
3310bbf21555SRichard Lowe.Sy PCSXREG
3311bbf21555SRichard Lowewas applied to a process or
3312bbf21555SRichard Lowelwp not stopped on an event of interest; an attempt was made to mount
3313bbf21555SRichard Lowe.Pa /proc
3314bbf21555SRichard Lowewhen it was already mounted;
3315bbf21555SRichard Lowe.Sy PCAGENT
3316bbf21555SRichard Lowewas applied to a process
3317bbf21555SRichard Lowethat was not fully stopped or that already had an agent lwp.
3318bbf21555SRichard Lowe.It Er EINVAL
3319bbf21555SRichard LoweIn general, this means that some invalid argument was supplied to a system
3320bbf21555SRichard Lowecall.
3321bbf21555SRichard LoweA non-exhaustive list of conditions eliciting this error includes: a
3322bbf21555SRichard Lowecontrol message operation code is undefined; an out-of-range signal number was
3323bbf21555SRichard Lowespecified with
3324bbf21555SRichard Lowe.Sy PCSSIG ,
3325bbf21555SRichard Lowe.Sy PCKILL ,
3326bbf21555SRichard Loweor
3327bbf21555SRichard Lowe.Sy PCUNKILL ;
3328bbf21555SRichard Lowe.Sy SIGKILL
3329bbf21555SRichard Lowewas specified with
3330bbf21555SRichard Lowe.Sy PCUNKILL ;
3331bbf21555SRichard Lowe.Sy PCSFPREG
3332bbf21555SRichard Lowewas applied on a system that does not support floating-point operations;
3333bbf21555SRichard Lowe.Sy PCSXREG
3334bbf21555SRichard Lowewas applied on a system that does not support extra state registers.
3335bbf21555SRichard Lowe.It Er EINTR
3336bbf21555SRichard LoweA signal was received by the controlling process while waiting for the traced
3337bbf21555SRichard Loweprocess or lwp to stop via
3338bbf21555SRichard Lowe.Sy PCSTOP ,
3339bbf21555SRichard Lowe.Sy PCWSTOP ,
3340bbf21555SRichard Loweor
3341bbf21555SRichard Lowe.Sy PCTWSTOP .
3342bbf21555SRichard Lowe.It Er EIO
3343bbf21555SRichard LoweA
3344bbf21555SRichard Lowe.Xr write 2
3345bbf21555SRichard Lowewas attempted at an illegal address in the traced process.
3346bbf21555SRichard Lowe.It Er ENOENT
3347bbf21555SRichard LoweThe traced process or lwp has terminated after being opened.
3348bbf21555SRichard LoweThe basic privilege
3349bbf21555SRichard Lowe.Brq Sy PRIV_PROC_INFO
3350bbf21555SRichard Loweis not asserted in the effective set of the calling process and the calling
3351bbf21555SRichard Loweprocess cannot send a signal to the target process.
3352bbf21555SRichard Lowe.It Er ENOMEM
3353bbf21555SRichard LoweThe system-imposed limit on the number of page data file descriptors was
3354bbf21555SRichard Lowereached on an open of
3355bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /pagedata ;
3356bbf21555SRichard Lowean attempt was made
3357bbf21555SRichard Lowewith
3358bbf21555SRichard Lowe.Sy PCWATCH
3359bbf21555SRichard Loweto establish more watched areas than the system can support;
3360bbf21555SRichard Lowethe
3361bbf21555SRichard Lowe.Sy PCAGENT
3362bbf21555SRichard Loweoperation was issued when the system was out of resources for
3363bbf21555SRichard Lowecreating lwps.
3364bbf21555SRichard Lowe.It Er ENOSYS
3365bbf21555SRichard LoweAn attempt was made to perform an unsupported operation (such as
3366bbf21555SRichard Lowe.Xr creat 2 ,
3367bbf21555SRichard Lowe.Xr link 2 ,
3368bbf21555SRichard Loweor
3369bbf21555SRichard Lowe.Xr unlink 2 )
3370bbf21555SRichard Loweon an entry in
3371bbf21555SRichard Lowe.Pa /proc .
3372bbf21555SRichard Lowe.It Er EOVERFLOW
3373bbf21555SRichard LoweA 32-bit controlling process attempted to read or write the
3374bbf21555SRichard Lowe.Pa as
3375bbf21555SRichard Lowefile or attempted to read the
3376bbf21555SRichard Lowe.Pa map ,
3377bbf21555SRichard Lowe.Pa rmap ,
3378bbf21555SRichard Loweor
3379bbf21555SRichard Lowe.Pa pagedata
3380bbf21555SRichard Lowefile of a 64-bit target process.
3381bbf21555SRichard LoweA 32-bit controlling process attempted to apply one of the
3382bbf21555SRichard Lowecontrol operations
3383bbf21555SRichard Lowe.Sy PCSREG ,
3384bbf21555SRichard Lowe.Sy PCSXREG ,
3385bbf21555SRichard Lowe.Sy PCSVADDR ,
3386bbf21555SRichard Lowe.Sy PCWATCH ,
3387bbf21555SRichard Lowe.Sy PCAGENT ,
3388bbf21555SRichard Lowe.Sy PCREAD ,
3389bbf21555SRichard Lowe.Sy PCWRITE
3390bbf21555SRichard Loweto a 64-bit target process.
3391bbf21555SRichard Lowe.It Er EPERM
3392bbf21555SRichard LoweThe process that issued the
3393bbf21555SRichard Lowe.Sy PCSCRED
3394bbf21555SRichard Loweor
3395bbf21555SRichard Lowe.Sy PCSCREDX
3396bbf21555SRichard Loweoperation did not have the
3397bbf21555SRichard Lowe.Brq Sy PRIV_PROC_SETID
3398bbf21555SRichard Loweprivilege asserted in its effective set, or
3399bbf21555SRichard Lowethe process that issued the
3400bbf21555SRichard Lowe.Sy PCNICE
3401bbf21555SRichard Loweoperation did not have the
3402bbf21555SRichard Lowe.Brq Sy PRIV_PROC_PRIOCNTL
3403bbf21555SRichard Lowein its effective set.
3404bbf21555SRichard Lowe.Pp
3405bbf21555SRichard LoweAn attempt was made to control a process of which the E, P, and I privilege
3406bbf21555SRichard Lowesets were not a subset of the effective set of the controlling process or the
3407bbf21555SRichard Lowelimit set of the controlling process is not a superset of limit set of the
3408bbf21555SRichard Lowecontrolled process.
3409bbf21555SRichard Lowe.Pp
3410bbf21555SRichard LoweAny of the uids of the target process are
3411bbf21555SRichard Lowe.Sy 0
3412bbf21555SRichard Loweor an attempt was made to change any of the uids to
3413bbf21555SRichard Lowe.Sy 0
3414bbf21555SRichard Loweusing
3415bbf21555SRichard Lowe.Sy PCSCRED
3416bbf21555SRichard Loweand the security policy imposed additional restrictions.
3417bbf21555SRichard LoweSee
3418bbf21555SRichard Lowe.Xr privileges 7 .
3419bbf21555SRichard Lowe.El
3420bbf21555SRichard Lowe.Sh SEE ALSO
3421bbf21555SRichard Lowe.Xr ls 1 ,
3422bbf21555SRichard Lowe.Xr ps 1 ,
3423bbf21555SRichard Lowe.Xr alarm 2 ,
3424bbf21555SRichard Lowe.Xr brk 2 ,
3425bbf21555SRichard Lowe.Xr chdir 2 ,
3426bbf21555SRichard Lowe.Xr chroot 2 ,
3427bbf21555SRichard Lowe.Xr close 2 ,
3428bbf21555SRichard Lowe.Xr creat 2 ,
3429bbf21555SRichard Lowe.Xr dup 2 ,
3430bbf21555SRichard Lowe.Xr exec 2 ,
3431bbf21555SRichard Lowe.Xr fcntl 2 ,
3432bbf21555SRichard Lowe.Xr fork 2 ,
3433bbf21555SRichard Lowe.Xr fork1 2 ,
3434bbf21555SRichard Lowe.Xr fstat 2 ,
3435bbf21555SRichard Lowe.Xr getdents 2 ,
3436bbf21555SRichard Lowe.Xr getustack 2 ,
3437bbf21555SRichard Lowe.Xr kill 2 ,
3438bbf21555SRichard Lowe.Xr lseek 2 ,
3439bbf21555SRichard Lowe.Xr mmap 2 ,
3440bbf21555SRichard Lowe.Xr nice 2 ,
3441bbf21555SRichard Lowe.Xr open 2 ,
3442bbf21555SRichard Lowe.Xr poll 2 ,
3443bbf21555SRichard Lowe.Xr pread 2 ,
3444bbf21555SRichard Lowe.Xr pwrite 2 ,
3445bbf21555SRichard Lowe.Xr read 2 ,
3446bbf21555SRichard Lowe.Xr readlink 2 ,
3447bbf21555SRichard Lowe.Xr readv 2 ,
3448bbf21555SRichard Lowe.Xr shmget 2 ,
3449bbf21555SRichard Lowe.Xr sigaction 2 ,
3450bbf21555SRichard Lowe.Xr sigaltstack 2 ,
3451bbf21555SRichard Lowe.Xr vfork 2 ,
3452bbf21555SRichard Lowe.Xr write 2 ,
3453bbf21555SRichard Lowe.Xr writev 2 ,
3454bbf21555SRichard Lowe.Xr _stack_grow 3C ,
3455bbf21555SRichard Lowe.Xr pthread_create 3C ,
3456bbf21555SRichard Lowe.Xr pthread_join 3C ,
3457bbf21555SRichard Lowe.Xr ptrace 3C ,
3458bbf21555SRichard Lowe.Xr readdir 3C ,
3459bbf21555SRichard Lowe.Xr thr_create 3C ,
3460bbf21555SRichard Lowe.Xr thr_join 3C ,
3461bbf21555SRichard Lowe.Xr wait 3C ,
3462bbf21555SRichard Lowe.Xr siginfo.h 3HEAD ,
3463bbf21555SRichard Lowe.Xr signal.h 3HEAD ,
3464bbf21555SRichard Lowe.Xr types32.h 3HEAD ,
3465bbf21555SRichard Lowe.Xr ucontext.h 3HEAD ,
3466bbf21555SRichard Lowe.Xr contract 5 ,
3467bbf21555SRichard Lowe.Xr core 5 ,
3468bbf21555SRichard Lowe.Xr process 5 ,
3469bbf21555SRichard Lowe.Xr lfcompile 7 ,
3470bbf21555SRichard Lowe.Xr privileges 7 ,
3471bbf21555SRichard Lowe.Xr security-flags 7 ,
3472bbf21555SRichard Lowe.Xr chroot 8
3473bbf21555SRichard Lowe.Sh NOTES
3474bbf21555SRichard LoweDescriptions of structures in this document include only interesting structure
3475bbf21555SRichard Loweelements, not filler and padding fields, and may show elements out of order for
3476bbf21555SRichard Lowedescriptive clarity.
3477bbf21555SRichard LoweThe actual structure definitions are contained in
3478bbf21555SRichard Lowe.In procfs.h .
3479bbf21555SRichard Lowe.Sh BUGS
3480bbf21555SRichard LoweBecause the old
3481bbf21555SRichard Lowe.Xr ioctl 2 Ns -based
3482bbf21555SRichard Loweversion of
3483bbf21555SRichard Lowe.Pa /proc
3484bbf21555SRichard Loweis currently supported for binary compatibility with old applications, the
3485bbf21555SRichard Lowetop-level directory for a process,
3486bbf21555SRichard Lowe.Pa /proc/ Ns Em pid ,
3487bbf21555SRichard Loweis not world-readable, but it is world-searchable.
3488bbf21555SRichard LoweThus, anyone can open
3489bbf21555SRichard Lowe.Pa /proc/ Ns Em pid Ns Pa /psinfo
3490bbf21555SRichard Loweeven though
3491bbf21555SRichard Lowe.Xr ls 1
3492bbf21555SRichard Loweapplied to
3493bbf21555SRichard Lowe.Pa /proc/ Ns Em pid
3494bbf21555SRichard Lowewill fail for anyone but the owner or an appropriately privileged process.
3495bbf21555SRichard LoweSupport for the old
3496bbf21555SRichard Lowe.Xr ioctl 2 Ns -based
3497bbf21555SRichard Loweversion of
3498bbf21555SRichard Lowe.Pa /proc
3499bbf21555SRichard Lowewill be dropped in a future release, at which time the top-level directory for
3500bbf21555SRichard Lowea process will be made world-readable.
3501bbf21555SRichard Lowe.Pp
3502bbf21555SRichard LoweOn SPARC based machines, the types
3503bbf21555SRichard Lowe.Sy gregset_t
3504bbf21555SRichard Loweand
3505bbf21555SRichard Lowe.Sy fpregset_t
3506bbf21555SRichard Lowedefined in
3507bbf21555SRichard Lowe.In sys/regset.h
3508bbf21555SRichard Loweare similar to but not the same as the types
3509bbf21555SRichard Lowe.Sy prgregset_t
3510bbf21555SRichard Loweand
3511bbf21555SRichard Lowe.Sy prfpregset_t
3512bbf21555SRichard Lowedefined in
3513bbf21555SRichard Lowe.In procfs.h .
3514