1proc(4)                          File Formats                          proc(4)
2
3
4

NAME

6       proc - /proc, the process file system
7

DESCRIPTION

9       /proc  is  a  file  system  that  provides  access to the state of each
10       process and light-weight process (lwp) in the system. The name of  each
11       entry  in  the  /proc  directory is a decimal number corresponding to a
12       process-ID. These entries  are  themselves  subdirectories.  Access  to
13       process  state  is  provided  by additional files contained within each
14       subdirectory; the hierarchy is described more completely below. In this
15       document,  ``/proc  file''  refers  to  a non-directory file within the
16       hierarchy rooted at /proc. The owner of each /proc file  and  subdirec‐
17       tory is determined by the user-ID of the process.
18
19
20       /proc  can  be  mounted on any mount point, in addition to the standard
21       /proc mount point, and can be mounted  several  places  at  once.  Such
22       additional mounts are allowed in order to facilitate the confinement of
23       processes to subtrees of the file system via chroot(1M) and  yet  allow
24       such processes access to commands like ps(1).
25
26
27       Standard  system  calls  are  used  to  access  /proc  files:  open(2),
28       close(2),  read(2),  and  write(2)  (including   readv(2),   writev(2),
29       pread(2),  and  pwrite(2)).  Most  files describe process state and can
30       only be opened for reading.  ctl  and  lwpctl  (control)  files  permit
31       manipulation  of  process  state and can only be opened for writing. as
32       (address space) files contain the image of the running process and  can
33       be  opened  for  both  reading  and writing. An open for writing allows
34       process control; a read-only open allows inspection but not control. In
35       this  document,  we refer to the process as open for reading or writing
36       if any of its associated /proc files is open for reading or writing.
37
38
39       In general, more than one process can open the same /proc file  at  the
40       same  time.  Exclusive  open is an advisory mechanism provided to allow
41       controlling processes to avoid collisions with each  other.  A  process
42       can obtain exclusive control of a target process, with respect to other
43       cooperating processes, if it successfully opens any /proc file  in  the
44       target  process for writing (the as or ctl files, or the lwpctl file of
45       any lwp) while specifying O_EXCL in the open(2). Such an open will fail
46       if  the  target process is already open for writing (that is, if an as,
47       ctl, or lwpctl file is already open for writing). There can be any num‐
48       ber of concurrent read-only opens; O_EXCL is ignored on opens for read‐
49       ing. It is recommended that the first open for writing by a controlling
50       process  use  the  O_EXCL  flag; multiple controlling processes usually
51       result in chaos.
52
53
54       If a process opens one of its own /proc files  for  writing,  the  open
55       succeeds  regardless  of  O_EXCL  and  regardless of whether some other
56       process has the process open for writing. Self-opens do not count  when
57       another process attempts an exclusive open. (A process cannot exclude a
58       debugger by opening itself for writing and the application of a  debug‐
59       ger  cannot  prevent a process from opening itself.) All self-opens for
60       writing are forced to be close-on-exec (see the  F_SETFD  operation  of
61       fcntl(2)).
62
63
64       Data  may  be transferred from or to any locations in the address space
65       of the traced process by applying lseek(2) to position the as  file  at
66       the  virtual address of interest followed by read(2) or write(2) (or by
67       using pread(2) or pwrite(2) for the combined operation).  The  address-
68       map files /proc/pid/map and /proc/pid/xmap can be read to determine the
69       accessible areas (mappings) of the address  space.  I/O  transfers  may
70       span  contiguous  mappings.  An  I/O request extending into an unmapped
71       area is truncated at the boundary. A  write  request  beginning  at  an
72       unmapped virtual address fails with EIO; a read request beginning at an
73       unmapped virtual address returns zero (an end-of-file indication).
74
75
76       Information and control  operations  are  provided  through  additional
77       files.  <procfs.h>  contains definitions of data structures and message
78       formats used with these files. Some of these  definitions  involve  the
79       use  of  sets  of flags. The set types sigset_t, fltset_t, and sysset_t
80       correspond, respectively, to signal, fault, and  system  call  enumera‐
81       tions  defined  in  <sys/signal.h>, <sys/fault.h>, and <sys/syscall.h>.
82       Each set type is large enough to hold flags for  its  own  enumeration.
83       Although  they are of different sizes, they have a common structure and
84       can be manipulated by these macros:
85
86         prfillset(&set);             /* turn on all flags in set */
87         premptyset(&set);            /* turn off all flags in set */
88         praddset(&set, flag);        /* turn on the specified flag */
89         prdelset(&set, flag);        /* turn off the specified flag */
90         r = prismember(&set, flag);  /* != 0 iff flag is turned on */
91
92
93
94       One of prfillset() or premptyset()  must  be  used  to  initialize  set
95       before  it is used in any other operation. flag must be a member of the
96       enumeration corresponding to set.
97
98
99       Every process contains at least one light-weight process, or lwp.  Each
100       lwp  represents  a flow of execution that is independently scheduled by
101       the operating system. All lwps in a process share its address space  as
102       well  as many other attributes. Through the use of lwpctl and ctl files
103       as described below, it is possible  to  affect  individual  lwps  in  a
104       process or to affect all of them at once, depending on the operation.
105
106
107       When  the process has more than one lwp, a representative lwp is chosen
108       by the system for certain process status files and control  operations.
109       The  representative  lwp  is a stopped lwp only if all of the process's
110       lwps are stopped; is stopped on an event of interest only if all of the
111       lwps are so stopped (excluding PR_SUSPENDED lwps); is in a PR_REQUESTED
112       stop only if there are no other events of interest  to  be  found;  or,
113       failing  everything  else, is in a PR_SUSPENDED stop (implying that the
114       process is deadlocked). See the description of the status file for def‐
115       initions  of  stopped  states. See the PCSTOP control operation for the
116       definition of ``event of interest''.
117
118
119       The representative lwp remains fixed (it will be chosen  again  on  the
120       next  operation)  as  long  as all of the lwps are stopped on events of
121       interest or are in a PR_SUSPENDED stop and the PCRUN control  operation
122       is not applied to any of them.
123
124
125       When applied to the process control file, every /proc control operation
126       that must act on an lwp uses the same algorithm to choose which lwp  to
127       act  upon. Together with synchronous stopping (see PCSET), this enables
128       a debugger to control a multiple-lwp process using  only  the  process-
129       level status and control files if it so chooses. More fine-grained con‐
130       trol can be achieved using the lwp-specific files.
131
132
133       The system supports two process data  models,  the  traditional  32-bit
134       data  model in which ints, longs and pointers are all 32 bits wide (the
135       ILP32 data model), and on some platforms the 64-bit data model in which
136       longs  and  pointers, but not ints, are 64 bits in width (the LP64 data
137       model). In the LP64 data model some system data types, notably  size_t,
138       off_t, time_t and dev_t, grow from 32 bits to 64 bits as well.
139
140
141       The  /proc  interfaces  described here are available to both 32-bit and
142       64-bit controlling processes. However, many operations attempted  by  a
143       32-bit  controlling  process  on a 64-bit target process will fail with
144       EOVERFLOW because the address space range of a  32-bit  process  cannot
145       encompass  a  64-bit  process or because the data in some 64-bit system
146       data type cannot be compressed to fit  into  the  corresponding  32-bit
147       type  without loss of information. Operations that fail in this circum‐
148       stance include reading and  writing  the  address  space,  reading  the
149       address-map files, and setting the target process's registers. There is
150       no restriction on operations applied by a 64-bit process  to  either  a
151       32-bit or a 64-bit target processes.
152
153
154       The  format of the contents of any /proc file depends on the data model
155       of the observer (the controlling process), not on the data model of the
156       target process. A 64-bit debugger does not have to translate the infor‐
157       mation it reads from a /proc file for a 32-bit process from 32-bit for‐
158       mat  to  64-bit format. However, it usually has to be aware of the data
159       model of the target process. The pr_dmodel field of  the  status  files
160       indicates the target process's data model.
161
162
163       To help deal with system data structures that are read from 32-bit pro‐
164       cesses, a 64-bit controlling program can be compiled with  the  C  pre‐
165       processor  symbol  _SYSCALL32  defined  before  system header files are
166       included. This makes explicit 32-bit fixed-width data structures  (like
167       cstruct stat32) visible to the 64-bit program. See types32.h(3HEAD).
168

DIRECTORY STRUCTURE

170       At  the  top  level, the directory /proc contains entries each of which
171       names an existing process in the system. These entries  are  themselves
172       directories.  Except  where  otherwise noted, the files described below
173       can be opened for reading only. In addition, if  a  process  becomes  a
174       zombie  (one  that  has exited but whose parent has not yet performed a
175       wait(3C) upon it), most of its associated /proc  files  disappear  from
176       the  hierarchy;  subsequent  attempts to open them, or to read or write
177       files opened before the process exited, will elicit the error ENOENT.
178
179
180       Although process state and consequently the contents of /proc files can
181       change  from  instant  to  instant, a single read(2) of a /proc file is
182       guaranteed to return a sane representation of state; that is, the  read
183       will  be atomic with respect to the state of the process. No such guar‐
184       antee applies to successive reads applied to a /proc file for a running
185       process.  In  addition,  atomicity is not guaranteed for I/O applied to
186       the as (address-space) file for a running  process  or  for  a  process
187       whose address space contains memory shared by another running process.
188
189
190       A number of structure definitions are used to describe the files. These
191       structures may grow by the addition of elements at the  end  in  future
192       releases of the system and it is not legitimate for a program to assume
193       that they will not.
194

STRUCTURE OF /proc/pid

196       A given directory /proc/pid contains the following entries.  A  process
197       can  use the invisible alias /proc/self if it wishes to open one of its
198       own /proc files (invisible in the sense that the name ``self'' does not
199       appear  in  a  directory  listing  of  /proc  obtained from ls(1), get‐
200       dents(2), or readdir(3C)).
201
202   contracts
203       A directory containing references to the contracts held by the process.
204       Each  entry is a symlink to the contract's directory under /system/con‐
205       tract. See contract(4).
206
207   as
208       Contains the address-space image of the process; it can be  opened  for
209       both  reading and writing. lseek(2) is used to position the file at the
210       virtual address of interest and then the address space can be  examined
211       or  changed  through  read(2)  or  write(2)  (or  by  using pread(2) or
212       pwrite(2) for the combined operation).
213
214   ctl
215       A write-only file to which structured messages  are  written  directing
216       the  system to change some aspect of the process's state or control its
217       behavior in some way. The seek offset is not relevant when  writing  to
218       this file. Individual lwps also have associated lwpctl files in the lwp
219       subdirectories.  A  control  message  may  be  written  either  to  the
220       process's ctl file or to a specific lwpctl file with operation-specific
221       effects. The effect of a control message is  immediately  reflected  in
222       the  state of the process visible through appropriate status and infor‐
223       mation files. The types of control messages  are  described  in  detail
224       later. See CONTROL MESSAGES.
225
226   status
227       Contains  state  information  about  the process and the representative
228       lwp. The file contains a pstatus structure which contains  an  embedded
229       lwpstatus structure for the representative lwp, as follows:
230
231         typedef struct pstatus {
232              int pr_flags;            /* flags (see below) */
233              int pr_nlwp;             /* number of active lwps in the process */
234              int pr_nzomb;            /* number of zombie lwps in the process */
235              pid_tpr_pid;             /* process id */
236              pid_tpr_ppid;            /* parent process id */
237              pid_tpr_pgid;            /* process group id */
238              pid_tpr_sid;             /* session id */
239              id_t pr_aslwpid;         /* obsolete */
240              id_t pr_agentid;         /* lwp-id of the agent lwp, if any */
241              sigset_t pr_sigpend;     /* set of process pending signals */
242              uintptr_t pr_brkbase;    /* virtual address of the process heap */
243              size_t pr_brksize;       /* size of the process heap, in bytes */
244              uintptr_t pr_stkbase;    /* virtual address of the process stack */
245              size_tpr_stksize;        /* size of the process stack, in bytes */
246              timestruc_t pr_utime;    /* process user cpu time */
247              timestruc_t pr_stime;    /* process system cpu time */
248              timestruc_t pr_cutime;   /* sum of children's user times */
249              timestruc_t pr_cstime;   /* sum of children's system times */
250              sigset_t pr_sigtrace;    /* set of traced signals */
251              fltset_t pr_flttrace;    /* set of traced faults */
252              sysset_t pr_sysentry;    /* set of system calls traced on entry */
253              sysset_t pr_sysexit;     /* set of system calls traced on exit */
254              char pr_dmodel;          /* data model of the process */
255              taskid_t pr_taskid;      /* task id */
256              projid_t pr_projid;      /* project id */
257              zoneid_t pr_zoneid;      /* zone id */
258              lwpstatus_t pr_lwp;      /* status of the representative lwp */
259         } pstatus_t;
260
261
262
263       pr_flags  is a bit-mask holding the following process flags. For conve‐
264       nience, it also contains the lwp  flags  for  the  representative  lwp,
265       described later.
266
267       PR_ISSYS     process is a system process (see PCSTOP).
268
269
270       PR_VFORKP    process is the parent of a vforked child (see PCWATCH).
271
272
273       PR_FORK      process has its inherit-on-fork mode set (see PCSET).
274
275
276       PR_RLC       process has its run-on-last-close mode set (see PCSET).
277
278
279       PR_KLC       process has its kill-on-last-close mode set (see PCSET).
280
281
282       PR_ASYNC     process has its asynchronous-stop mode set (see PCSET).
283
284
285       PR_MSACCT    Set   by   default  in  all  processes  to  indicate  that
286                    microstate accounting is enabled. However, this  flag  has
287                    been  deprecated  and no longer has any effect. Microstate
288                    accounting may not be disabled; however, it is still  pos‐
289                    sible to toggle the flag.
290
291
292       PR_MSFORK    Set   by   default  in  all  processes  to  indicate  that
293                    microstate accounting will be enabled for  processes  that
294                    this  parent  forks().  However, this flag has been depre‐
295                    cated and no longer has any effect. It is possible to tog‐
296                    gle  this  flag;  however,  it  is not possible to disable
297                    microstate accounting.
298
299
300       PR_BPTADJ    process  has  its  breakpoint  adjustment  mode  set  (see
301                    PCSET).
302
303
304       PR_PTRACE    process has its ptrace-compatibility mode set (see PCSET).
305
306
307
308       pr_nlwp  is the total number of active lwps in the process. pr_nzomb is
309       the total number of zombie lwps in the process. A zombie lwp is a  non-
310       detached  lwp  that  has  terminated  but  has  not  been  reaped  with
311       thr_join(3C) or pthread_join(3C).
312
313
314       pr_pid, pr_ppid, pr_pgid, and pr_sid are, respectively, the process ID,
315       the ID of the process's parent, the process's process group ID, and the
316       process's session ID.
317
318
319       pr_aslwpid is obsolete and is always zero.
320
321
322       pr_agentid is the lwp-ID for the /proc agent lwp (see the PCAGENT  con‐
323       trol operation). It is zero if there is no agent lwp in the process.
324
325
326       pr_sigpend identifies asynchronous signals pending for the process.
327
328
329       pr_brkbase is the virtual address of the process heap and pr_brksize is
330       its size in bytes. The address formed by the sum of these values is the
331       process  break  (see  brk(2)).  pr_stkbase  and pr_stksize are, respec‐
332       tively, the virtual address of the process stack and its size in bytes.
333       (Each  lwp  runs on a separate stack; the distinguishing characteristic
334       of the process stack is that the operating system  will  grow  it  when
335       necessary.)
336
337
338       pr_utime,  pr_stime,  pr_cutime,  and  pr_cstime are, respectively, the
339       user CPU and system CPU time consumed by the process, and  the  cumula‐
340       tive  user  CPU and system CPU time consumed by the process's children,
341       in seconds and nanoseconds.
342
343
344       pr_sigtrace and pr_flttrace contain, respectively, the set  of  signals
345       and  the set of hardware faults that are being traced (see PCSTRACE and
346       PCSFAULT).
347
348
349       pr_sysentry and pr_sysexit contain, respectively, the  sets  of  system
350       calls being traced on entry and exit (see PCSENTRY and PCSEXIT).
351
352
353       pr_dmodel indicates the data model of the process. Possible values are:
354
355       PR_MODEL_ILP32     process data model is ILP32.
356
357
358       PR_MODEL_LP64      process data model is LP64.
359
360
361       PR_MODEL_NATIVE    process data model is native.
362
363
364
365       The  pr_taskid,  pr_projid,  and pr_zoneid fields contain respectively,
366       the numeric IDs of the task, project, and zone in which the process was
367       running.
368
369
370       The constant PR_MODEL_NATIVE reflects the data model of the controlling
371       process, that is, its value is PR_MODEL_ILP32 or PR_MODEL_LP64  accord‐
372       ing  to  whether  the controlling process has been compiled as a 32-bit
373       program or a 64-bit program, respectively.
374
375
376       pr_lwp contains the status information for the representative lwp:
377
378         typedef struct lwpstatus {
379           int pr_flags;              /* flags (see below) */
380           id_t pr_lwpid;             /* specific lwp identifier */
381           short pr_why;              /* reason for lwp stop, if stopped */
382           short pr_what;             /* more detailed reason */
383           short pr_cursig;           /* current signal, if any */
384           siginfo_t pr_info;         /* info associated with signal or fault */
385           sigset_t pr_lwppend;       /* set of signals pending to the lwp */
386           sigset_t pr_lwphold;       /* set of signals blocked by the lwp */
387           struct sigaction pr_action;/* signal action for current signal */
388           stack_t pr_altstack;       /* alternate signal stack info */
389           uintptr_t pr_oldcontext;   /* address of previous ucontext */
390           short pr_syscall;          /* system call number (if in syscall) */
391           short pr_nsysarg;          /* number of arguments to this syscall */
392           int pr_errno;              /* errno for failed syscall */
393           long pr_sysarg[PRSYSARGS]; /* arguments to this syscall */
394           long pr_rval1;             /* primary syscall return value */
395           long pr_rval2;             /* second syscall return value, if any */
396           char pr_clname[PRCLSZ];    /* scheduling class name */
397           timestruc_t pr_tstamp;     /* real-time time stamp of stop */
398           timestruc_t pr_utime;      /* lwp user cpu time */
399           timestruc_t pr_stime;      /* lwp system cpu time */
400           uintptr_t pr_ustack;       /* stack boundary data (stack_t) address */
401           ulong_t pr_instr;          /* current instruction */
402           prgregset_t pr_reg;        /* general registers */
403           prfpregset_t pr_fpreg;     /* floating-point registers */
404         } lwpstatus_t;
405
406
407
408       pr_flags is a bit-mask holding the  following  lwp  flags.  For  conve‐
409       nience, it also contains the process flags, described previously.
410
411       PR_STOPPED    The lwp is stopped.
412
413
414       PR_ISTOP      The lwp is stopped on an event of interest (see PCSTOP).
415
416
417       PR_DSTOP      The lwp has a stop directive in effect (see PCSTOP).
418
419
420       PR_STEP       The  lwp  has  a  single-step  directive  in  effect (see
421                     PCRUN).
422
423
424       PR_ASLEEP     The lwp is in an  interruptible  sleep  within  a  system
425                     call.
426
427
428       PR_PCINVAL    The lwp's current instruction (pr_instr) is undefined.
429
430
431       PR_DETACH     This  is  a  detached  lwp  (see  pthread_create(3C)  and
432                     pthread_join(3C)).
433
434
435       PR_DAEMON     This is a daemon lwp (see pthread_create(3C)).
436
437
438       PR_ASLWP      This flag is obsolete and is never set.
439
440
441       PR_AGENT      This is the /proc agent lwp for the process.
442
443
444
445       pr_lwpid names the specific lwp.
446
447
448       pr_why and pr_what together describe, for a stopped lwp, the reason for
449       the stop. Possible values of pr_why and the associated pr_what are:
450
451       PR_REQUESTED     indicates that the stop occurred in response to a stop
452                        directive, normally  because  PCSTOP  was  applied  or
453                        because  another  lwp  stopped on an event of interest
454                        and the asynchronous-stop flag (see PCSET) was not set
455                        for the process. pr_what is unused in this case.
456
457
458       PR_SIGNALLED     indicates  that the lwp stopped on receipt of a signal
459                        (see PCSTRACE); pr_what holds the signal  number  that
460                        caused  the  stop  (for  a newly-stopped lwp, the same
461                        value is in pr_cursig).
462
463
464       PR_FAULTED       indicates that the lwp stopped on incurring a hardware
465                        fault  (see  PCSFAULT); pr_what holds the fault number
466                        that caused the stop.
467
468
469       PR_SYSENTRY      indicate a stop on entry to or exit from a system call
470       PR_SYSEXIT       (see  PCSENTRY  and PCSEXIT); pr_what holds the system
471                        call number.
472
473
474       PR_JOBCONTROL    indicates that the lwp  stopped  due  to  the  default
475                        action  of  a  job  control  stop  signal  (see sigac‐
476                        tion(2)); pr_what holds the stopping signal number.
477
478
479       PR_SUSPENDED     indicates that the lwp stopped due  to  internal  syn‐
480                        chronization  of  lwps  within the process. pr_what is
481                        unused in this case.
482
483
484
485       pr_cursig names the current signal, that is,  the  next  signal  to  be
486       delivered  to  the  lwp,  if any. pr_info, when the lwp is in a PR_SIG‐
487       NALLED or PR_FAULTED stop, contains additional information pertinent to
488       the particular signal or fault (see <sys/siginfo.h>).
489
490
491       pr_lwppend  identifies  any synchronous or directed signals pending for
492       the lwp. pr_lwphold identifies those signals whose  delivery  is  being
493       blocked by the lwp (the signal mask).
494
495
496       pr_action contains the signal action information pertaining to the cur‐
497       rent signal (see sigaction(2)); it is undefined if pr_cursig  is  zero.
498       pr_altstack contains the alternate signal stack information for the lwp
499       (see sigaltstack(2)).
500
501
502       pr_oldcontext, if not zero, contains the address on the lwp stack of  a
503       ucontext  structure  describing  the  previous  user-level context (see
504       ucontext.h(3HEAD)). It is non-zero only if the lwp is executing in  the
505       context of a signal handler.
506
507
508       pr_syscall  is the number of the system call, if any, being executed by
509       the lwp; it is non-zero if and only if the lwp is stopped on  PR_SYSEN‐
510       TRY  or  PR_SYSEXIT,  or  is asleep within a system call ( PR_ASLEEP is
511       set). If pr_syscall is non-zero, pr_nsysarg is the number of  arguments
512       to the system call and pr_sysarg contains the actual arguments.
513
514
515       pr_rval1, pr_rval2, and pr_errno are defined only if the lwp is stopped
516       on PR_SYSEXIT or if the PR_VFORKP flag is set.  If  pr_errno  is  zero,
517       pr_rval1  and  pr_rval2 contain the return values from the system call.
518       Otherwise, pr_errno contains the error number for  the  failing  system
519       call (see <sys/errno.h>).
520
521
522       pr_clname contains the name of the lwp's scheduling class.
523
524
525       pr_tstamp,  if  the  lwp is stopped, contains a time stamp marking when
526       the lwp stopped, in real time seconds and nanoseconds  since  an  arbi‐
527       trary time in the past.
528
529
530       pr_utime is the amount of user level CPU time used by this LWP.
531
532
533       pr_stime is the amount of system level CPU time used by this LWP.
534
535
536       pr_ustack is the virtual address of the stack_t that contains the stack
537       boundaries for this LWP. See getustack(2) and _stack_grow(3C).
538
539
540       pr_instr contains the machine instruction to which  the  lwp's  program
541       counter  refers.  The  amount  of  data  retrieved  from the process is
542       machine-dependent. On SPARC based machines, it is  a  32-bit  word.  On
543       x86-based  machines,  it is a single byte. In general, the size is that
544       of the machine's smallest instruction. If PR_PCINVAL is  set,  pr_instr
545       is  undefined;  this occurs whenever the lwp is not stopped or when the
546       program counter refers to an invalid virtual address.
547
548
549       pr_reg is an array holding the contents of a stopped lwp's general reg‐
550       isters.
551
552       SPARC                On  SPARC-based machines, the predefined constants
553                            R_G0 ... R_G7, R_O0 ... R_O7, R_L0 ... R_L7,  R_I0
554                            ...  R_I7,  R_PC,  R_nPC,  and  R_Y can be used as
555                            indices to refer to the  corresponding  registers;
556                            previous  register  windows can be read from their
557                            overflow locations on the stack (however, see  the
558                            gwindows file in the /proc/pid/lwp/lwpid subdirec‐
559                            tory).
560
561
562       SPARC V8 (32-bit)    For SPARC V8 (32-bit) controlling  processes,  the
563                            predefined  constants  R_PSR, R_WIM, and R_TBR can
564                            be used as indices to refer to  the  corresponding
565                            special  registers. For SPARC V9 (64-bit) control‐
566                            ling processes, the  predefined  constants  R_CCR,
567                            R_ASI,  and R_FPRS can be used as indices to refer
568                            to the corresponding special registers.
569
570
571       x86 (32-bit)         For 32-bit x86 processes, the predefined constants
572                            listed belowcan be used as indices to refer to the
573                            corresponding registers.
574
575                              SS
576                              UESP
577                              EFL
578                              CS
579                              EIP
580                              ERR
581                              TRAPNO
582                              EAX
583                              ECX
584                              EDX
585                              EBX
586                              ESP
587                              EBP
588                              ESI
589                              EDI
590                              DS
591                              ES
592                              GS
593
594                            The   preceding   constants    are    listed    in
595                            <sys/regset.h>.
596
597                            Note  that  a  32-bit  process  can  run on an x86
598                            64-bit system, using the constants listed above.
599
600
601       x86 (64-bit)         To read  the  registers  of  a  32-  or  a  64-bit
602                            process,  a 64-bit x86 process should use the pre‐
603                            defined constants listed below.
604
605                              REG_GSBASE
606                              REG_FSBASE
607                              REG_DS
608                              REG_ES
609                              REG_GS
610                              REG_FS
611                              REG_SS
612                              REG_RSP
613                              REG_RFL
614                              REG_CS
615                              REG_RIP
616                              REG_ERR
617                              REG_TRAPNO
618                              REG_RAX
619                              REG_RCX
620                              REG_RDX
621                              REG_RBX
622                              REG_RBP
623                              REG_RSI
624                              REG_RDI
625                              REG_R8
626                              REG_R9
627                              REG_R10
628                              REG_R11
629                              REG_R12
630                              REG_R13
631                              REG_R14
632                              REG_R15
633
634                            The   preceding   constants    are    listed    in
635                            <sys/regset.h>.
636
637
638
639       pr_fpreg is a structure holding the contents of the floating-point reg‐
640       isters.
641
642
643       SPARC registers, both general and floating-point, as seen by  a  64-bit
644       controlling  process  are the V9 versions of the registers, even if the
645       target process is a 32-bit (V8) process. V8 registers are a  subset  of
646       the V9 registers.
647
648
649       If the lwp is not stopped, all register values are undefined.
650
651   psinfo
652       Contains  miscellaneous information about the process and the represen‐
653       tative lwp needed by the ps(1) command. psinfo remains accessible after
654       a  process becomes a zombie. The file contains a psinfo structure which
655       contains an embedded lwpsinfo structure for the representative lwp,  as
656       follows:
657
658         typedef struct psinfo {
659             int pr_flag;             /* process flags (DEPRECATED: see below) */
660             int pr_nlwp;             /* number of active lwps in the process */
661             int pr_nzomb;            /* number of zombie lwps in the process */
662             pid_t pr_pid;            /* process id */
663             pid_t pr_ppid;           /* process id of parent */
664             pid_t pr_pgid;           /* process id of process group leader */
665             pid_t pr_sid;            /* session id */
666             uid_t pr_uid;            /* real user id */
667             uid_t pr_euid;           /* effective user id */
668             gid_t pr_gid;            /* real group id */
669             gid_t pr_egid;           /* effective group id */
670             uintptr_t pr_addr;       /* address of process */
671             size_t pr_size;          /* size of process image in Kbytes */
672             size_t pr_rssize;        /* resident set size in Kbytes */
673             dev_t pr_ttydev;         /* controlling tty device (or PRNODEV) */
674             ushort_t pr_pctcpu;      /* % of recent cpu time used by all lwps */
675             ushort_t pr_pctmem;      /* % of system memory used by process */
676             timestruc_t pr_start;    /* process start time, from the epoch */
677             timestruc_t pr_time;     /* cpu time for this process */
678             timestruc_t pr_ctime;    /* cpu time for reaped children */
679             char pr_fname[PRFNSZ];   /* name of exec'ed file */
680             char pr_psargs[PRARGSZ]; /* initial characters of arg list */
681             int pr_wstat;            /* if zombie, the wait() status */
682             int pr_argc;             /* initial argument count */
683             uintptr_t pr_argv;       /* address of initial argument vector */
684             uintptr_t pr_envp;       /* address of initial environment vector */
685             char pr_dmodel;          /* data model of the process */
686             lwpsinfo_t pr_lwp;       /* information for representative lwp */
687             taskid_t pr_taskid;      /* task id */
688             projid_t pr_projid;      /* project id */
689             poolid_t pr_poolid;      /* pool id */
690             zoneid_t pr_zoneid;      /* zone id */
691             ctid_t pr_contract;      /* process contract id */
692         } psinfo_t;
693
694
695
696       Some  of the entries in psinfo, such as pr_addr, refer to internal ker‐
697       nel data structures and should not be expected to retain their meanings
698       across different versions of the operating system.
699
700
701       psinfo_t.pr_flag  is  a  deprecated  interface that should no longer be
702       used. Applications currently relying on the SSYS bit in pr_flag  should
703       migrate to checking PR_ISSYS in the pstatus structure's pr_flags field.
704
705
706       pr_pctcpu and pr_pctmem are 16-bit binary fractions in the range 0.0 to
707       1.0 with the binary point to the right of the high-order  bit  (1.0  ==
708       0x8000). pr_pctcpu is the summation over all lwps in the process.
709
710
711       pr_lwp  contains  the  ps(1) information for the representative lwp. If
712       the process is a zombie, pr_nlwp,  pr_nzomb,  and  pr_lwp.pr_lwpid  are
713       zero and the other fields of pr_lwp are undefined:
714
715         typedef struct lwpsinfo {
716             int pr_flag;             /* lwp flags (DEPRECATED: see below) */
717             id_t pr_lwpid;           /* lwp id */
718             uintptr_t pr_addr;       /* internal address of lwp */
719             uintptr_t pr_wchan;      /* wait addr for sleeping lwp */
720             char pr_stype;           /* synchronization event type */
721             char pr_state;           /* numeric lwp state */
722             char pr_sname;           /* printable character for pr_state */
723             char pr_nice;            /* nice for cpu usage */
724             short pr_syscall;        /* system call number (if in syscall) */
725             char pr_oldpri;          /* pre-SVR4, low value is high priority */
726             char pr_cpu;             /* pre-SVR4, cpu usage for scheduling */
727             int pr_pri;              /* priority, high value = high priority */
728             ushort_t pr_pctcpu;      /* % of recent cpu time used by this lwp */
729             timestruc_t pr_start;    /* lwp start time, from the epoch */
730             timestruc_t pr_time;     /* cpu time for this lwp */
731             char pr_clname[PRCLSZ];  /* scheduling class name */
732             char pr_name[PRFNSZ];    /* name of system lwp */
733             processorid_t pr_onpro;  /* processor which last ran this lwp */
734             processorid_t pr_bindpro;/* processor to which lwp is bound */
735             psetid_t pr_bindpset;    /* processor set to which lwp is bound */
736             lgrp_id_t pr_lgrp          /* home lgroup */
737         } lwpsinfo_t;
738
739
740
741       Some  of  the entries in lwpsinfo, such as pr_addr, pr_wchan, pr_stype,
742       pr_state, and pr_name, refer to internal  kernel  data  structures  and
743       should  not  be expected to retain their meanings across different ver‐
744       sions of the operating system.
745
746
747       lwpsinfo_t.pr_flag is a deprecated interface that should no  longer  be
748       used.
749
750
751       pr_pctcpu  is  a  16-bit binary fraction, as described above. It repre‐
752       sents the CPU time used by  the  specific  lwp.  On  a  multi-processor
753       machine, the maximum value is 1/N, where N is the number of CPUs.
754
755
756       pr_contract is the id of the process contract of which the process is a
757       member. See contract(4) and process(4).
758
759   cred
760       Contains a description of the credentials associated with the process:
761
762         typedef struct prcred {
763              uid_t pr_euid;      /* effective user id */
764              uid_t pr_ruid;      /* real user id */
765              uid_t pr_suid;      /* saved user id (from exec) */
766              gid_t pr_egid;      /* effective group id */
767              gid_t pr_rgid;      /* real group id */
768              gid_t pr_sgid;      /* saved group id (from exec) */
769              int pr_ngroups;     /* number of supplementary groups */
770              gid_t pr_groups[1]; /* array of supplementary groups */
771         } prcred_t;
772
773
774
775
776       The array of associated supplementary groups in pr_groups is  of  vari‐
777       able  length;  the  cred file contains all of the supplementary groups.
778       pr_ngroups indicates the number of supplementary groups. (See also  the
779       PCSCRED and PCSCREDX control operations.)
780
781   priv
782       Contains a description of the privileges associated with the process:
783
784         typedef struct prpriv {
785              uint32_t        pr_nsets;      /* number of privilege set */
786              uint32_t        pr_setsize;    /* size of privilege set */
787              uint32_t        pr_infosize;   /* size of supplementary data */
788              priv_chunk_t    pr_sets[1];    /* array of sets */
789         } prpriv_t;
790
791
792
793       The actual dimension of the pr_sets[] field is
794
795         pr_sets[pr_nsets][pr_setsize]
796
797
798
799       which  is  followed  by  additional information about the process state
800       pr_infosize bytes in size.
801
802
803       The   full   size   of   the   structure   can   be   computed    using
804       PRIV_PRPRIV_SIZE(prpriv_t *).
805
806   sigact
807       Contains an array of sigaction structures describing the current dispo‐
808       sitions of all signals associated with the traced process  (see  sigac‐
809       tion(2)). Signal numbers are displaced by 1 from array indices, so that
810       the action for signal number n appears in position n-1 of the array.
811
812   auxv
813       Contains the initial values of the process's aux vector in an array  of
814       auxv_t  structures  (see  <sys/auxv.h>). The values are those that were
815       passed by the operating system as startup information  to  the  dynamic
816       linker.
817
818   ldt
819       This  file  exists  only on x86-based machines. It is non-empty only if
820       the process has established a local descriptor  table  (LDT).  If  non-
821       empty,  the  file contains the array of currently active LDT entries in
822       an array of elements of type struct ssd, defined in <sys/sysi86.h>, one
823       element for each active LDT entry.
824
825   map, xmap
826       Contain  information  about the virtual address map of the process. The
827       map file contains an array of prmap structures while the xmap file con‐
828       tains  an  array  of prxmap structures. Each structure describes a con‐
829       tiguous virtual address region in  the  address  space  of  the  traced
830       process:
831
832         typedef struct prmap {
833              uintptr_tpr_vaddr;         /* virtual address of mapping */
834              size_t pr_size;            /* size of mapping in bytes */
835              char pr_mapname[PRMAPSZ];  /* name in /proc/pid/object */
836              offset_t pr_offset;        /* offset into mapped object, if any */
837              int pr_mflags;             /* protection and attribute flags */
838              int pr_pagesize;           /* pagesize for this mapping in bytes */
839              int pr_shmid;              /* SysV shared memory identifier */
840         } prmap_t;
841
842
843
844         typedef struct prxmap {
845              uintptr_t pr_vaddr;        /* virtual address of mapping */
846              size_t pr_size;            /* size of mapping in bytes */
847              char pr_mapname[PRMAPSZ];  /* name in /proc/pid/object */
848              offset_t pr_offset;        /* offset into mapped object, if any */
849              int pr_mflags;             /* protection and attribute flags */
850              int pr_pagesize;           /* pagesize for this mapping in bytes */
851              int pr_shmid;              /* SysV shared memory identifier */
852              dev_t pr_dev;              /* device of mapped object, if any */
853              uint64_t pr_ino;           /* inode of mapped object, if any */
854              size_t pr_rss;             /* pages of resident memory */
855              size_t pr_anon;            /* pages of resident anonymous memory */
856              size_t pr_locked;          /* pages of locked memory */
857              uint64_t pr_hatpagesize;   /* pagesize of mapping */
858         } prxmap_t;
859
860
861
862
863       pr_vaddr  is  the  virtual  address  of  the  mapping within the traced
864       process and pr_size is its size in bytes. pr_mapname, if  it  does  not
865       contain a null string, contains the name of a file in the object direc‐
866       tory (see below) that can be opened read-only to obtain a file descrip‐
867       tor  for  the  mapped  file associated with the mapping. This enables a
868       debugger to find object file symbol tables without having to  know  the
869       real  path  names  of  the  executable file and shared libraries of the
870       process. pr_offset is the 64-bit offset within the mapped file (if any)
871       to which the virtual address is mapped.
872
873
874       pr_mflags is a bit-mask of protection and attribute flags:
875
876       MA_READ          mapping is readable by the traced process.
877
878
879       MA_WRITE         mapping is writable by the traced process.
880
881
882       MA_EXEC          mapping is executable by the traced process.
883
884
885       MA_SHARED        mapping changes are shared by the mapped object.
886
887
888       MA_ISM           mapping   is   intimate   shared  memory  (shared  MMU
889                        resources)
890
891
892       MAP_NORESERVE    mapping does not have swap space reserved (mapped with
893                        MAP_NORESERVE)
894
895
896       MA_SHM           mapping System V shared memory
897
898
899
900       A  contiguous  area  of  the  address  space having the same underlying
901       mapped object may appear as multiple  mappings  due  to  varying  read,
902       write,  and  execute  attributes. The underlying mapped object does not
903       change over the range of a single mapping. An I/O operation to  a  map‐
904       ping  marked MA_SHARED fails if applied at a virtual address not corre‐
905       sponding to a valid page in the underlying mapped object. A write to  a
906       MA_SHARED  mapping  that is not marked MA_WRITE fails. Reads and writes
907       to private mappings  always  succeed.  Reads  and  writes  to  unmapped
908       addresses fail.
909
910
911       pr_pagesize is the page size for the mapping, currently always the sys‐
912       tem pagesize.
913
914
915       pr_shmid is the shared memory identifier, if any, for the mapping.  Its
916       value  is  −1  if  the  mapping  is  not  System  V  shared memory. See
917       shmget(2).
918
919
920       pr_dev is the device of the mapped object, if any, for the mapping. Its
921       value is PRNODEV (-1) if the mapping does not have a device.
922
923
924       pr_ino  is the inode of the mapped object, if any, for the mapping. Its
925       contents are only valid if pr_dev is not PRNODEV.
926
927
928       pr_rss is the number of resident pages of memory for the  mapping.  The
929       number of resident bytes for the mapping may be determined by multiply‐
930       ing pr_rss by the page size given by pr_pagesize.
931
932
933       pr_anon is the number of resident anonymous memory pages  (pages  which
934       are private to this process) for the mapping.
935
936
937       pr_locked  is  the  number of locked pages for the mapping. Pages which
938       are locked are always resident in memory.
939
940
941       pr_hatpagesize is the size, in bytes, of the HAT (MMU) translation  for
942       the mapping. pr_hatpagesize may be different than pr_pagesize. The pos‐
943       sible values are hardware architecture specific, and may change over  a
944       mapping's lifetime.
945
946   rmap
947       Contains  information about the reserved address ranges of the process.
948       The file contains an array of prmap structures, as  defined  above  for
949       the  map  file.  Each  structure describes a contiguous virtual address
950       region in the address space of the traced process that is  reserved  by
951       the system in the sense that an mmap(2) system call that does not spec‐
952       ify MAP_FIXED will not use any part of it for the new mapping. Examples
953       of  such  reservations  include  the  address  ranges  reserved for the
954       process stack and the individual  thread  stacks  of  a  multi-threaded
955       process.
956
957   cwd
958       A  symbolic  link  to  the  process's  current  working  directory. See
959       chdir(2). A readlink(2) of /proc/pid/cwd yields a null string. However,
960       it  can  be opened, listed, and searched as a directory, and can be the
961       target of chdir(2).
962
963   root
964       A symbolic link to the process's  root  directory.  /proc/pid/root  can
965       differ  from  the  system  root  directory if the process or one of its
966       ancestors executed chroot(2) as super user. It has the  same  semantics
967       as /proc/pid/cwd.
968
969   fd
970       A  directory  containing  references  to the open files of the process.
971       Each entry is a decimal number corresponding to an open file descriptor
972       in the process.
973
974
975       If an entry refers to a regular file, it can be opened with normal file
976       system semantics but, to ensure that  the  controlling  process  cannot
977       gain  greater  access  than the controlled process, with no file access
978       modes other than its read/write open modes in the  controlled  process.
979       If  an  entry  refers  to a directory, it can be accessed with the same
980       semantics as /proc/pid/cwd. An attempt to open any other type of  entry
981       fails with EACCES.
982
983   object
984       A  directory containing read-only files with names corresponding to the
985       pr_mapname entries in the map and pagedata files. Opening such  a  file
986       yields a file descriptor for the underlying mapped file associated with
987       an address-space mapping in the process. The file name a.out appears in
988       the directory as an alias for the process's executable file.
989
990
991       The  object  directory  makes  it possible for a controlling process to
992       gain access to the object file and any  shared  libraries  (and  conse‐
993       quently the symbol tables) without having to know the actual path names
994       of the executable files.
995
996   path
997       A directory containing symbolic links to files opened by  the  process.
998       The  directory  includes one entry for cwd and root. The directory also
999       contains a numerical entry for each file descriptor in  the  fd  direc‐
1000       tory,  and  entries  matching  those  in  the object directory. If this
1001       information is not available, any attempt to read the contents  of  the
1002       symbolic  link  will  fail.  This  is most common for files that do not
1003       exist in the filesystem namespace (such as FIFOs and sockets), but  can
1004       also  happen  for  regular  files. For the file descriptor entries, the
1005       path may be different from the one used by  the  process  to  open  the
1006       file.
1007
1008   pagedata
1009       Opening the page data file enables tracking of address space references
1010       and modifications on a per-page basis.
1011
1012
1013       A read(2) of the page data file descriptor returns structured page data
1014       and atomically clears the page data maintained for the file by the sys‐
1015       tem. That is to say, each read returns data collected  since  the  last
1016       read;  the first read returns data collected since the file was opened.
1017       When the call completes, the read buffer contains the following  struc‐
1018       ture  as  its header and thereafter contains a number of section header
1019       structures and associated byte arrays that must be accessed by  walking
1020       linearly through the buffer.
1021
1022         typedef struct prpageheader {
1023             timestruc_t pr_tstamp; /* real time stamp, time of read() */
1024             ulong_t pr_nmap;       /* number of address space mappings */
1025             ulong_t pr_npage;      /* total number of pages */
1026         } prpageheader_t;
1027
1028
1029
1030       The  header  is  followed  by pr_nmap prasmap structures and associated
1031       data arrays. The prasmap structure contains the following elements:
1032
1033         typedef struct prasmap {
1034             uintptr_t pr_vaddr;        /* virtual address of mapping */
1035             ulong_t pr_npage;          /* number of pages in mapping */
1036             char pr_mapname[PRMAPSZ];  /* name in /proc/pid/object */
1037             offset_t pr_offset;        /* offset into mapped object, if any */
1038             int pr_mflags;             /* protection and attribute flags */
1039             int pr_pagesize;           /* pagesize for this mapping in bytes */
1040             int pr_shmid;              /* SysV shared memory identifier */
1041         } prasmap_t;
1042
1043
1044
1045       Each section header is followed by pr_npage bytes, one  byte  for  each
1046       page  in  the  mapping, plus 0-7 null bytes at the end so that the next
1047       prasmap structure begins on an eight-byte aligned boundary.  Each  data
1048       byte may contain these flags:
1049
1050       PG_REFERENCED    page has been referenced.
1051
1052
1053       PG_MODIFIED      page has been modified.
1054
1055
1056
1057       If the read buffer is not large enough to contain all of the page data,
1058       the read fails with E2BIG  and  the  page  data  is  not  cleared.  The
1059       required  size  of  the read buffer can be determined through fstat(2).
1060       Application of lseek(2) to the page data file  descriptor  is  ineffec‐
1061       tive;  every  read  starts  from the beginning of the file. Closing the
1062       page data file descriptor terminates  the  system  overhead  associated
1063       with collecting the data.
1064
1065
1066       More  than  one  page  data file descriptor for the same process can be
1067       opened, up to a system-imposed limit per traced process. A read of  one
1068       does  not affect the data being collected by the system for the others.
1069       An open of the page data file will fail  with  ENOMEM  if  the  system-
1070       imposed limit would be exceeded.
1071
1072   watch
1073       Contains  an  array  of  prwatch  structures, one for each watched area
1074       established by the PCWATCH control operation. See PCWATCH for details.
1075
1076   usage
1077       Contains process usage information described  by  a  prusage  structure
1078       which contains at least the following fields:
1079
1080         typedef struct prusage {
1081             id_t pr_lwpid;           /* lwp id.  0: process or defunct */
1082             int pr_count;            /* number of contributing lwps */
1083             timestruc_t pr_tstamp;   /* real time stamp, time of read() */
1084             timestruc_t pr_create;   /* process/lwp creation time stamp */
1085             timestruc_t pr_term;     /* process/lwp termination time stamp */
1086             timestruc_t pr_rtime;    /* total lwp real (elapsed) time */
1087             timestruc_t pr_utime;    /* user level CPU time */
1088             timestruc_t pr_stime;    /* system call CPU time */
1089             timestruc_t pr_ttime;    /* other system trap CPU time */
1090             timestruc_t pr_tftime;   /* text page fault sleep time */
1091             timestruc_t pr_dftime;   /* data page fault sleep time */
1092             timestruc_t pr_kftime;   /* kernel page fault sleep time */
1093             timestruc_t pr_ltime;    /* user lock wait sleep time */
1094             timestruc_t pr_slptime;  /* all other sleep time */
1095             timestruc_t pr_wtime;    /* wait-cpu (latency) time */
1096             timestruc_t pr_stoptime; /* stopped time */
1097             ulong_t pr_minf;         /* minor page faults */
1098             ulong_t pr_majf;         /* major page faults */
1099             ulong_t pr_nswap;        /* swaps */
1100             ulong_t pr_inblk;        /* input blocks */
1101             ulong_t pr_oublk;        /* output blocks */
1102             ulong_t pr_msnd;         /* messages sent */
1103             ulong_t pr_mrcv;         /* messages received */
1104             ulong_t pr_sigs;         /* signals received */
1105             ulong_t pr_vctx;         /* voluntary context switches */
1106             ulong_t pr_ictx;         /* involuntary context switches */
1107             ulong_t pr_sysc;         /* system calls */
1108             ulong_t pr_ioch;         /* chars read and written */
1109         } prusage_t;
1110
1111
1112
1113       Microstate  accounting is now continuously enabled. While this informa‐
1114       tion was previously an estimate,  if  microstate  accounting  were  not
1115       enabled,  the  current  information is now never an estimate represents
1116       time the process has spent in various states.
1117
1118   lstatus
1119       Contains a prheader structure followed by an array of lwpstatus  struc‐
1120       tures,   one   for   each   active   lwp   in  the  process  (see  also
1121       /proc/pid/lwp/lwpid/lwpstatus, below). The prheader structure describes
1122       the number and size of the array entries that follow.
1123
1124         typedef struct prheader {
1125             long pr_nent;        /* number of entries */
1126             size_t pr_entsize;   /* size of each entry, in bytes */
1127         } prheader_t;
1128
1129
1130
1131       The lwpstatus structure may grow by the addition of elements at the end
1132       in future releases of the system. Programs must use pr_entsize  in  the
1133       file  header  to  index  through the array. These comments apply to all
1134       /proc files that include a  prheader  structure  (lpsinfo  and  lusage,
1135       below).
1136
1137   lpsinfo
1138       Contains  a  prheader structure followed by an array of lwpsinfo struc‐
1139       tures, one for eachactive and zombie  lwp  in  the  process.  See  also
1140       /proc/pid/lwp/lwpid/lwpsinfo, below.
1141
1142   lusage
1143       Contains  a  prheader  structure followed by an array of prusage struc‐
1144       tures, one for each active lwp in the process, plus an additional  ele‐
1145       ment at the beginning that contains the summation over all defunct lwps
1146       (lwps that once existed but no longer exist in the process).  Excluding
1147       the  pr_lwpid, pr_tstamp, pr_create, and pr_term entries, the entry-by-
1148       entry summation over all these structures  is  the  definition  of  the
1149       process  usage  information  obtained  from  the  usage file. (See also
1150       /proc/pid/lwp/lwpid/lwpusage, below.)
1151
1152   lwp
1153       A directory containing entries each of which names an active or  zombie
1154       lwp  within  the process. These entries are themselves directories con‐
1155       taining additional files as described below.  Only  the  lwpsinfo  file
1156       exists in the directory of a zombie lwp.
1157

STRUCTURE OF /proc/pid/lwp/ lwpid

1159       A given directory /proc/pid/lwp/lwpid contains the following entries:
1160
1161   lwpctl
1162       Write-only  control  file. The messages written to this file affect the
1163       specific lwp rather than the representative lwp, as is the case for the
1164       process's ctl file.
1165
1166   lwpstatus
1167       lwp-specific state information. This file contains the lwpstatus struc‐
1168       ture for the specific lwp as described above for the representative lwp
1169       in the process's status file.
1170
1171   lwpsinfo
1172       lwp-specific  ps(1) information. This file contains the lwpsinfo struc‐
1173       ture for the specific lwp as described above for the representative lwp
1174       in  the  process's  psinfo  file.  The lwpsinfo file remains accessible
1175       after an lwp becomes a zombie.
1176
1177   lwpusage
1178       This file contains the  prusage  structure  for  the  specific  lwp  as
1179       described above for the process's usage file.
1180
1181   gwindows
1182       This  file  exists only on SPARC based machines. If it is non-empty, it
1183       contains a gwindows_t structure, defined in  <sys/regset.h>,  with  the
1184       values  of those SPARC register windows that could not be stored on the
1185       stack when the lwp stopped. Conditions under which register windows are
1186       not  stored  on  the stack are: the stack pointer refers to nonexistent
1187       process memory or the stack pointer is improperly aligned. If  the  lwp
1188       is  not  stopped  or if there are no register windows that could not be
1189       stored on the stack, the file is empty (the usual case).
1190
1191   xregs
1192       Extra state registers. The extra state  register  set  is  architecture
1193       dependent;  this  file  is  empty  if the system does not support extra
1194       state registers. If the file is non-empty, it contains an  architecture
1195       dependent  structure  of  type prxregset_t, defined in <procfs.h>, with
1196       the values of the lwp's extra  state  registers.  If  the  lwp  is  not
1197       stopped,  all  register values are undefined. See also the PCSXREG con‐
1198       trol operation, below.
1199
1200   asrs
1201       This file exists only for 64-bit SPARC V9  processes.  It  contains  an
1202       asrset_t structure, defined in <sys/regset.h>, containing the values of
1203       the lwp's platform-dependent ancillary state registers. If the  lwp  is
1204       not  stopped,  all  register values are undefined. See also the PCSASRS
1205       control operation, below.
1206
1207   templates
1208       A directory which contains references to the active templates  for  the
1209       lwp,  named  by  the  contract type. Changes made to an active template
1210       descriptor do not affect the original  template  which  was  activated,
1211       though  they do affect the active template. It is not possible to acti‐
1212       vate an active template descriptor. See contract(4).
1213

CONTROL MESSAGES

1215       Process state changes  are  effected  through  messages  written  to  a
1216       process's  ctl  file or to an individual lwp's lwpctl file. All control
1217       messages consist of a long that names the specific  operation  followed
1218       by additional data containing the operand, if any.
1219
1220
1221       Multiple  control  messages  may  be  combined in a single write(2) (or
1222       writev(2)) to a control file, but no partial writes are permitted. That
1223       is,  each control message, operation code plus operand, if any, must be
1224       presented in its entirety to the write(2) and not in pieces  over  sev‐
1225       eral  system  calls. If a control operation fails, no subsequent opera‐
1226       tions contained in the same write(2) are attempted.
1227
1228
1229       Descriptions of the allowable control messages follow.  In  all  cases,
1230       writing  a message to a control file for a process or lwp that has ter‐
1231       minated elicits the error ENOENT.
1232
1233   PCSTOP PCDSTOP PCWSTOP PCTWSTOP
1234       When applied to the process control file, PCSTOP directs  all  lwps  to
1235       stop and waits for them to stop, PCDSTOP directs all lwps to stop with‐
1236       out waiting for them to stop, and PCWSTOP simply waits for all lwps  to
1237       stop.  When applied to an lwp control file, PCSTOP directs the specific
1238       lwp to stop and waits until it has stopped, PCDSTOP  directs  the  spe‐
1239       cific  lwp  to  stop without waiting for it to stop, and PCWSTOP simply
1240       waits for the specific lwp to stop. When  applied  to  an  lwp  control
1241       file,  PCSTOP  and  PCWSTOP  complete when the lwp stops on an event of
1242       interest, immediately if  already  so  stopped;  when  applied  to  the
1243       process  control  file, they complete when every lwp has stopped either
1244       on an event of interest or on a PR_SUSPENDED stop.
1245
1246
1247       PCTWSTOP is identical to PCWSTOP except that it enables  the  operation
1248       to  time  out,  to  avoid waiting forever for a process or lwp that may
1249       never stop on an event of interest. PCTWSTOP takes a long operand spec‐
1250       ifying  a  number of milliseconds; the wait will terminate successfully
1251       after the specified number of milliseconds even if the process  or  lwp
1252       has  not stopped; a timeout value of zero makes the operation identical
1253       to PCWSTOP.
1254
1255
1256       An ``event of interest'' is either a PR_REQUESTED stop or a  stop  that
1257       has  been  specified  in  the process's tracing flags (set by PCSTRACE,
1258       PCSFAULT, PCSENTRY, and PCSEXIT). PR_JOBCONTROL and PR_SUSPENDED  stops
1259       are  specifically not events of interest. (An lwp may stop twice due to
1260       a stop signal, first showing PR_SIGNALLED if the signal is  traced  and
1261       again  showing PR_JOBCONTROL if the lwp is set running without clearing
1262       the signal.) If PCSTOP or PCDSTOP is applied to an lwp that is stopped,
1263       but  not  on an event of interest, the stop directive takes effect when
1264       the lwp is restarted by the competing mechanism. At that time, the  lwp
1265       enters a PR_REQUESTED stop before executing any user-level code.
1266
1267
1268       A  write  of a control message that blocks is interruptible by a signal
1269       so that, for example, an alarm(2) can be set to avoid  waiting  forever
1270       for  a  process  or lwp that may never stop on an event of interest. If
1271       PCSTOP is interrupted, the lwp stop directives remain  in  effect  even
1272       though  the write(2) returns an error. (Use of PCTWSTOP with a non-zero
1273       timeout is recommended over PCWSTOP with an alarm(2).)
1274
1275
1276       A system process (indicated by the PR_ISSYS  flag)  never  executes  at
1277       user  level, has no user-level address space visible through /proc, and
1278       cannot be stopped. Applying one of these operations to a system process
1279       or any of its lwps elicits the error EBUSY.
1280
1281   PCRUN
1282       Make  an  lwp  runnable again after a stop. This operation takes a long
1283       operand containing zero or more of the following flags:
1284
1285       PRCSIG      clears the current signal, if any (see PCCSIG).
1286
1287
1288       PRCFAULT    clears the current fault, if any (see PCCFAULT).
1289
1290
1291       PRSTEP      directs the lwp to execute a single machine instruction. On
1292                   completion of the instruction, a trace trap occurs. If FLT‐
1293                   TRACE is being traced, the lwp stops; otherwise, it is sent
1294                   SIGTRAP. If SIGTRAP is being traced and is not blocked, the
1295                   lwp stops. When the lwp stops on an event of interest,  the
1296                   single-step directive is cancelled, even if the stop occurs
1297                   before the instruction is executed. This operation requires
1298                   hardware and operating system support and may not be imple‐
1299                   mented on all processors. It is implemented  on  SPARC  and
1300                   x86-based machines.
1301
1302
1303       PRSABORT    is  meaningful  only if the lwp is in a PR_SYSENTRY stop or
1304                   is marked PR_ASLEEP; it instructs the lwp to  abort  execu‐
1305                   tion of the system call (see PCSENTRY and PCSEXIT).
1306
1307
1308       PRSTOP      directs  the  lwp  to  stop again as soon as possible after
1309                   resuming execution (see PCDSTOP). In particular, if the lwp
1310                   is  stopped  on  PR_SIGNALLED  or PR_FAULTED, the next stop
1311                   will show PR_REQUESTED, no other stop will have intervened,
1312                   and the lwp will not have executed any user-level code.
1313
1314
1315
1316       When  applied  to  an  lwp  control  file, PCRUN clears any outstanding
1317       directed-stop request and makes the specific lwp runnable.  The  opera‐
1318       tion fails with EBUSY if the specific lwp is not stopped on an event of
1319       interest or has not been directed to stop or if the  agent  lwp  exists
1320       and this is not the agent lwp (see PCAGENT).
1321
1322
1323       When  applied to the process control file, a representative lwp is cho‐
1324       sen for the operation as described for /proc/pid/status. The  operation
1325       fails  with  EBUSY if the representative lwp is not stopped on an event
1326       of interest or has not been directed  to  stop  or  if  the  agent  lwp
1327       exists.  If  PRSTEP  or PRSTOP was requested, the representative lwp is
1328       made runnable and its outstanding  directed-stop  request  is  cleared;
1329       otherwise all outstanding directed-stop requests are cleared and, if it
1330       was stopped on an event of interest, the representative lwp  is  marked
1331       PR_REQUESTED. If, as a consequence, all lwps are in the PR_REQUESTED or
1332       PR_SUSPENDED  stop  state,  all  lwps  showing  PR_REQUESTED  are  made
1333       runnable.
1334
1335   PCSTRACE
1336       Define a set of signals to be traced in the process. The receipt of one
1337       of these signals by an lwp causes the lwp to stop. The set  of  signals
1338       is  defined using an operand sigset_t contained in the control message.
1339       Receipt of SIGKILL cannot be  traced;  if  specified,  it  is  silently
1340       ignored.
1341
1342
1343       If  a  signal  that is included in an lwp's held signal set (the signal
1344       mask) is sent to the lwp, the signal is not received and does not cause
1345       a  stop until it is removed from the held signal set, either by the lwp
1346       itself or by setting the held signal set with PCSHOLD.
1347
1348   PCCSIG
1349       The current signal, if any, is cleared from the specific or representa‐
1350       tive lwp.
1351
1352   PCSSIG
1353       The  current  signal and its associated signal information for the spe‐
1354       cific or representative lwp are set according to the  contents  of  the
1355       operand  siginfo structure (see <sys/siginfo.h>). If the specified sig‐
1356       nal number is zero, the current signal is  cleared.  The  semantics  of
1357       this  operation  are different from those of kill(2) in that the signal
1358       is delivered to the lwp immediately after execution is resumed (even if
1359       it  is  being  blocked)  and  an  additional PR_SIGNALLED stop does not
1360       intervene even if the signal is traced. Setting the current  signal  to
1361       SIGKILL terminates the process immediately.
1362
1363   PCKILL
1364       If applied to the process control file, a signal is sent to the process
1365       with semantics identical to those of kill(2). If applied to an lwp con‐
1366       trol file, a directed signal is sent to the specific lwp. The signal is
1367       named in a long operand contained in the message. Sending SIGKILL  ter‐
1368       minates the process immediately.
1369
1370   PCUNKILL
1371       A  signal  is  deleted,  that is, it is removed from the set of pending
1372       signals. If applied to the process control file, the signal is  deleted
1373       from  the process's pending signals. If applied to an lwp control file,
1374       the signal is deleted from the lwp's pending signals. The current  sig‐
1375       nal  (if  any)  is unaffected. The signal is named in a long operand in
1376       the control message. It is an  error  (EINVAL)  to  attempt  to  delete
1377       SIGKILL.
1378
1379   PCSHOLD
1380       Set  the  set  of  held  signals for the specific or representative lwp
1381       (signals whose delivery will be blocked if sent to the lwp). The set of
1382       signals  is specified with a sigset_t operand. SIGKILL and SIGSTOP can‐
1383       not be held; if specified, they are silently ignored.
1384
1385   PCSFAULT
1386       Define a set of hardware faults to be traced in the process. On  incur‐
1387       ring  one of these faults, an lwp stops. The set is defined via the op‐
1388       erand fltset_t structure. Fault names are defined in <sys/fault.h>  and
1389       include  the  following. Some of these may not occur on all processors;
1390       there may be processor-specific faults in addition to these.
1391
1392       FLTILL       illegal instruction
1393
1394
1395       FLTPRIV      privileged instruction
1396
1397
1398       FLTBPT       breakpoint trap
1399
1400
1401       FLTTRACE     trace trap (single-step)
1402
1403
1404       FLTWATCH     watchpoint trap
1405
1406
1407       FLTACCESS    memory access fault (bus error)
1408
1409
1410       FLTBOUNDS    memory bounds violation
1411
1412
1413       FLTIOVF      integer overflow
1414
1415
1416       FLTIZDIV     integer zero divide
1417
1418
1419       FLTFPE       floating-point exception
1420
1421
1422       FLTSTACK     unrecoverable stack fault
1423
1424
1425       FLTPAGE      recoverable page fault
1426
1427
1428
1429       When not traced, a fault normally results in the posting of a signal to
1430       the lwp that incurred the fault. If an lwp stops on a fault, the signal
1431       is posted to the lwp when execution is  resumed  unless  the  fault  is
1432       cleared  by  PCCFAULT or by the PRCFAULT option of PCRUN. FLTPAGE is an
1433       exception; no signal is posted. The  pr_info  field  in  the  lwpstatus
1434       structure  identifies  the  signal to be sent and contains machine-spe‐
1435       cific information about the fault.
1436
1437   PCCFAULT
1438       The current fault, if any, is cleared; the associated signal  will  not
1439       be sent to the specific or representative lwp.
1440
1441   PCSENTRY PCSEXIT
1442       These  control  operations instruct the process's lwps to stop on entry
1443       to or exit from specified system calls. The set of system calls  to  be
1444       traced is defined via an operand sysset_t structure.
1445
1446
1447       When  entry to a system call is being traced, an lwp stops after having
1448       begun the call to the system but before the system call arguments  have
1449       been  fetched  from  the  lwp.  When  exit  from a system call is being
1450       traced, an lwp stops on completion of the system  call  just  prior  to
1451       checking  for  signals  and returning to user level. At this point, all
1452       return values have been stored into the lwp's registers.
1453
1454
1455       If an lwp is stopped on entry to a system call  (PR_SYSENTRY)  or  when
1456       sleeping  in an interruptible system call (PR_ASLEEP is set), it may be
1457       instructed to go  directly  to  system  call  exit  by  specifying  the
1458       PRSABORT  flag  in a PCRUN control message. Unless exit from the system
1459       call is being traced, the lwp returns to user level showing EINTR.
1460
1461   PCWATCH
1462       Set or clear a watched area in the controlled process  from  a  prwatch
1463       structure operand:
1464
1465         typedef struct prwatch {
1466             uintptr_t pr_vaddr;  /* virtual address of watched area */
1467             size_t pr_size;      /* size of watched area in bytes */
1468             int pr_wflags;       /* watch type flags */
1469         } prwatch_t;
1470
1471
1472
1473       pr_vaddr  specifies  the  virtual  address  of  an area of memory to be
1474       watched in the controlled process. pr_size specifies the  size  of  the
1475       area,  in  bytes.  pr_wflags  specifies the type of memory access to be
1476       monitored as a bit-mask of the following flags:
1477
1478       WA_READ         read access
1479
1480
1481       WA_WRITE        write access
1482
1483
1484       WA_EXEC         execution access
1485
1486
1487       WA_TRAPAFTER    trap after the instruction completes
1488
1489
1490
1491       If pr_wflags is non-empty, a watched area is established for  the  vir‐
1492       tual  address  range specified by pr_vaddr and pr_size. If pr_wflags is
1493       empty, any previously-established watched area starting at  the  speci‐
1494       fied virtual address is cleared; pr_size is ignored.
1495
1496
1497       A  watchpoint  is  triggered  when an lwp in the traced process makes a
1498       memory reference that covers at least one byte of a  watched  area  and
1499       the memory reference is as specified in pr_wflags. When an lwp triggers
1500       a watchpoint, it incurs a watchpoint trap. If FLTWATCH is being traced,
1501       the  lwp  stops;  otherwise, it is sent a SIGTRAP signal; if SIGTRAP is
1502       being traced and is not blocked, the lwp stops.
1503
1504
1505       The watchpoint trap occurs  before  the  instruction  completes  unless
1506       WA_TRAPAFTER  was specified, in which case it occurs after the instruc‐
1507       tion completes. If it occurs before completion, the memory is not modi‐
1508       fied.  If  it  occurs  after completion, the memory is modified (if the
1509       access is a write access).
1510
1511
1512       Physical i/o is an exception for watchpoint traps.  In  this  instance,
1513       there  is  no guarantee that memory before the watched area has already
1514       been modified (or in the case of WA_TRAPAFTER, that the memory  follow‐
1515       ing  the  watched  area has not been modified) when the watchpoint trap
1516       occurs and the lwp stops.
1517
1518
1519       pr_info in the lwpstatus structure contains  information  pertinent  to
1520       the watchpoint trap. In particular, the si_addr field contains the vir‐
1521       tual address of the memory reference that triggered the watchpoint, and
1522       the   si_code  field  contains  one  of  TRAP_RWATCH,  TRAP_WWATCH,  or
1523       TRAP_XWATCH, indicating read, write, or execute  access,  respectively.
1524       The  si_trapafter  field  is  zero unless WA_TRAPAFTER is in effect for
1525       this watched area; non-zero indicates that the current  instruction  is
1526       not  the instruction that incurred the watchpoint trap. The si_pc field
1527       contains the virtual address of the instruction that incurred the trap.
1528
1529
1530       A watchpoint trap may be triggered while executing a system  call  that
1531       makes reference to the traced process's memory. The lwp that is execut‐
1532       ing the system call incurs the watchpoint trap while still in the  sys‐
1533       tem call. If it stops as a result, the lwpstatus structure contains the
1534       system call number and its arguments. If the lwp does not stop,  or  if
1535       it  is set running again without clearing the signal or fault, the sys‐
1536       tem call fails with EFAULT. If WA_TRAPAFTER was specified,  the  memory
1537       reference  will  have  completed and the memory will have been modified
1538       (if the access was a write access) when the watchpoint trap occurs.
1539
1540
1541       If more than one of WA_READ, WA_WRITE, and WA_EXEC is specified  for  a
1542       watched  area,  and  a  single  instruction incurs more than one of the
1543       specified types, only one is reported when the watchpoint trap  occurs.
1544       The  precedence is WA_EXEC, WA_READ, WA_WRITE (WA_EXEC and WA_READ take
1545       precedence over WA_WRITE), unless WA_TRAPAFTER was specified, in  which
1546       case it is WA_WRITE, WA_READ, WA_EXEC (WA_WRITE takes precedence).
1547
1548
1549       PCWATCH  fails with EINVAL if an attempt is made to specify overlapping
1550       watched areas or if pr_wflags contains flags other than those specified
1551       above.  It  fails  with  ENOMEM if an attempt is made to establish more
1552       watched areas than the system can support (the system can support thou‐
1553       sands).
1554
1555
1556       The  child  of  a  vfork(2)  borrows the parent's address space. When a
1557       vfork(2) is executed by a traced process, all watched areas established
1558       for  the parent are suspended until the child terminates or performs an
1559       exec(2). Any watched areas established independently in the  child  are
1560       cancelled  when  the  parent  resumes  after the child's termination or
1561       exec(2). PCWATCH fails with  EBUSY  if  applied  to  the  parent  of  a
1562       vfork(2)  before  the child has terminated or performed an exec(2). The
1563       PR_VFORKP flag is set in  the  pstatus  structure  for  such  a  parent
1564       process.
1565
1566
1567       Certain accesses of the traced process's address space by the operating
1568       system are immune to watchpoints. The initial construction of a  signal
1569       stack  frame  when  a  signal is delivered to an lwp will not trigger a
1570       watchpoint trap even if the new  frame  covers  watched  areas  of  the
1571       stack.  Once the signal handler is entered, watchpoint traps occur nor‐
1572       mally. On SPARC based machines, register window overflow and  underflow
1573       will  not  trigger  watchpoint  traps, even if the register window save
1574       areas cover watched areas of the stack.
1575
1576
1577       Watched areas are not inherited by child processes, even if the  traced
1578       process's inherit-on-fork mode, PR_FORK, is set (see PCSET, below). All
1579       watched areas are cancelled when the traced process performs a success‐
1580       ful exec(2).
1581
1582   PCSET PCUNSET
1583       PCSET sets one or more modes of operation for the traced process. PCUN‐
1584       SET unsets these modes. The modes to be set or unset are  specified  by
1585       flags in an operand long in the control message:
1586
1587       PR_FORK      (inherit-on-fork):  When  set, the process's tracing flags
1588                    and its inherit-on-fork mode are inherited by the child of
1589                    a  fork(2),  fork1(2), or vfork(2). When unset, child pro‐
1590                    cesses start with all tracing flags cleared.
1591
1592
1593       PR_RLC       (run-on-last-close): When set and the last writable  /proc
1594                    file  descriptor referring to the traced process or any of
1595                    its lwps is closed, all of the process's tracing flags and
1596                    watched areas are cleared, any outstanding stop directives
1597                    are canceled, and if any lwps are  stopped  on  events  of
1598                    interest,  they  are  set running as though PCRUN had been
1599                    applied to them. When unset, the process's  tracing  flags
1600                    and  watched  areas are retained and lwps are not set run‐
1601                    ning on last close.
1602
1603
1604       PR_KLC       (kill-on-last-close): When set and the last writable /proc
1605                    file  descriptor referring to the traced process or any of
1606                    its  lwps  is  closed,  the  process  is  terminated  with
1607                    SIGKILL.
1608
1609
1610       PR_ASYNC     (asynchronous-stop):  When  set,  a  stop  on  an event of
1611                    interest by one lwp does not directly affect any other lwp
1612                    in the process. When unset and an lwp stops on an event of
1613                    interest other than PR_REQUESTED, all other  lwps  in  the
1614                    process are directed to stop.
1615
1616
1617       PR_MSACCT    (microstate accounting): Microstate accounting is now con‐
1618                    tinuously enabled. This flag is deprecated and  no  longer
1619                    has  any  effect  upon microstate accounting. Applications
1620                    may toggle this flag; however, microstate accounting  will
1621                    remain enabled regardless.
1622
1623
1624       PR_MSFORK    (inherit microstate accounting): All processes now inherit
1625                    microstate accounting, as it is continuously enabled. This
1626                    flag  has  been  deprecated  and its use no longer has any
1627                    effect upon the behavior of microstate accounting.
1628
1629
1630       PR_BPTADJ    (breakpoint trap pc adjustment): On x86-based machines,  a
1631                    breakpoint  trap  leaves  the  program  counter  (the EIP)
1632                    referring to the breakpointed instruction plus  one  byte.
1633                    When  PR_BPTADJ is set, the system will adjust the program
1634                    counter back to the location of the breakpointed  instruc‐
1635                    tion  when the lwp stops on a breakpoint. This flag has no
1636                    effect on SPARC based  machines,  where  breakpoint  traps
1637                    leave  the  program  counter referring to the breakpointed
1638                    instruction.
1639
1640
1641       PR_PTRACE    (ptrace-compatibility): When set, a stop on  an  event  of
1642                    interest  by  the traced process is reported to the parent
1643                    of the traced process by wait(3C), SIGTRAP is sent to  the
1644                    traced  process  when  it  executes  a successful exec(2),
1645                    setuid/setgid flags are not honored for execs performed by
1646                    the  traced  process,  any exec of an object file that the
1647                    traced process cannot read fails,  and  the  process  dies
1648                    when  its parent dies. This mode is deprecated; it is pro‐
1649                    vided only to allow ptrace(3C)  to  be  implemented  as  a
1650                    library function using /proc.
1651
1652
1653
1654       It  is  an  error  (EINVAL) to specify flags other than those described
1655       above or to apply these operations to a  system  process.  The  current
1656       modes  are  reported  in  the  pr_flags  field  of /proc/pid/status and
1657       /proc/pid/lwp/lwp/lwpstatus.
1658
1659   PCSREG
1660       Set the general  registers  for  the  specific  or  representative  lwp
1661       according to the operand prgregset_t structure.
1662
1663
1664       On  SPARC based systems, only the condition-code bits of the processor-
1665       status register (R_PSR) of SPARC V8 (32-bit) processes can be  modified
1666       by PCSREG. Other privileged registers cannot be modified at all.
1667
1668
1669       On x86-based systems, only certain bits of the flags register (EFL) can
1670       be modified by PCSREG: these include the  condition  codes,  direction-
1671       bit, and overflow-bit.
1672
1673
1674       PCSREG fails with EBUSY if the lwp is not stopped on an event of inter‐
1675       est.
1676
1677   PCSVADDR
1678       Set the address at which execution will resume for the specific or rep‐
1679       resentative lwp from the operand long. On SPARC based systems, both %pc
1680       and %npc are set, with %npc set to the instruction following  the  vir‐
1681       tual  address.  On  x86-based systems, only %eip is set. PCSVADDR fails
1682       with EBUSY if the lwp is not stopped on an event of interest.
1683
1684   PCSFPREG
1685       Set the floating-point registers for the specific or representative lwp
1686       according  to  the operand prfpregset_t structure. An error (EINVAL) is
1687       returned if the system does not support floating-point  operations  (no
1688       floating-point  hardware and the system does not emulate floating-point
1689       machine instructions). PCSFPREG fails with EBUSY  if  the  lwp  is  not
1690       stopped on an event of interest.
1691
1692   PCSXREG
1693       Set  the  extra  state registers for the specific or representative lwp
1694       according to the architecture-dependent operand prxregset_t  structure.
1695       An  error  (EINVAL)  is  returned  if the system does not support extra
1696       state registers. PCSXREG fails with EBUSY if the lwp is not stopped  on
1697       an event of interest.
1698
1699   PCSASRS
1700       Set  the  ancillary  state registers for the specific or representative
1701       lwp according to  the  SPARC  V9  platform-dependent  operand  asrset_t
1702       structure.  An  error (EINVAL) is returned if either the target process
1703       or the controlling process is not a 64-bit SPARC V9  process.  Most  of
1704       the  ancillary  state registers are privileged registers that cannot be
1705       modified. Only those that can be  modified  are  set;  all  others  are
1706       silently ignored. PCSASRS fails with EBUSY if the lwp is not stopped on
1707       an event of interest.
1708
1709   PCAGENT
1710       Create an agent lwp in the controlled process with register values from
1711       the operand prgregset_t structure (see PCSREG, above). The agent lwp is
1712       created in the stopped state showing PR_REQUESTED  and  with  its  held
1713       signal  set  (the  signal  mask)  having all signals except SIGKILL and
1714       SIGSTOP blocked.
1715
1716
1717       The PCAGENT operation fails with EBUSY  unless  the  process  is  fully
1718       stopped  via  /proc, that is, unless all of the lwps in the process are
1719       stopped either on events of interest or on PR_SUSPENDED, or are stopped
1720       on  PR_JOBCONTROL and have been directed to stop via PCDSTOP.  It fails
1721       with EBUSY if an agent lwp already exists. It fails with ENOMEM if sys‐
1722       tem resources for creating new lwps have been exhausted.
1723
1724
1725       Any  PCRUN operation applied to the process control file or to the con‐
1726       trol file of an lwp other than the agent lwp fails with EBUSY  as  long
1727       as  the  agent lwp exists. The agent lwp must be caused to terminate by
1728       executing the SYS_lwp_exit system call trap before the process  can  be
1729       restarted.
1730
1731
1732       Once  the  agent lwp is created, its lwp-ID can be found by reading the
1733       process status file. To facilitate opening the agent lwp's control  and
1734       status  files,  the directory name /propc/pid/lwp/agent is accepted for
1735       lookup operations as an invisible alias for /proc/pid/lwp/lwpid,  lwpid
1736       being the lwp-ID of the agent lwp (invisible in the sense that the name
1737       ``agent'' does not appear  in  a  directory  listing  of  /proc/pid/lwp
1738       obtained from ls(1), getdents(2), or readdir(3C)).
1739
1740
1741       The purpose of the agent lwp is to perform operations in the controlled
1742       process on behalf of the controlling process: to gather information not
1743       directly  available  via /proc files, or in general to make the process
1744       change state in ways not directly available via  /proc  control  opera‐
1745       tions.  To  make  use  of an agent lwp, the controlling process must be
1746       capable  of  making  it  execute  system   calls   (specifically,   the
1747       SYS_lwp_exit  system call trap). The register values given to the agent
1748       lwp on creation are typically the registers of the representative  lwp,
1749       so that the agent lwp can use its stack.
1750
1751
1752       The  agent  lwp is not allowed to execute any variation of the SYS_fork
1753       or SYS_exec system call traps. Attempts to do so yield ENOTSUP  to  the
1754       agent lwp.
1755
1756
1757       Symbolic  constants  for system call trap numbers like SYS_lwp_exit and
1758       SYS_lwp_create can be found in the header file <sys/syscall.h>.
1759
1760   PCREAD PCWRITE
1761       Read or write the target process's address space via a  priovec  struc‐
1762       ture operand:
1763
1764         typedef struct priovec {
1765             void *pio_base;      /* buffer in controlling process */
1766             size_t pio_len;      /* size of read/write request in bytes */
1767             off_t pio_offset;    /* virtual address in target process */
1768         } priovec_t;
1769
1770
1771
1772       These  operations  have  the  same  effect  as  pread(2) and pwrite(2),
1773       respectively, of the target process's address space file.  The  differ‐
1774       ence  is  that more than one PCREAD or PCWRITE control operation can be
1775       written to the control file at once, and they can be interspersed  with
1776       other control operations in a single write to the control file. This is
1777       useful, for example, when planting many breakpoint instructions in  the
1778       process's  address space, or when stepping over a breakpointed instruc‐
1779       tion. Unlike pread(2) and pwrite(2), no provision is made  for  partial
1780       reads  or  writes;  if the operation cannot be performed completely, it
1781       fails with EIO.
1782
1783   PCNICE
1784       The traced process's nice(2) value is incremented by the amount in  the
1785       operand  long.  Only  a process with the {PRIV_PROC_PRIOCNTL} privilege
1786       asserted in its effective set can better a process's priority  in  this
1787       way,  but  any user may lower the priority. This operation is not mean‐
1788       ingful for all scheduling classes.
1789
1790   PCSCRED
1791       Set the target process credentials  to  the  values  contained  in  the
1792       prcred_t  structure  operand (see /proc/pid/cred). The effective, real,
1793       and saved user-IDs and group-IDs of the target  process  are  set.  The
1794       target  process's  supplementary groups are not changed; the pr_ngroups
1795       and pr_groups members of the structure operand are  ignored.  Only  the
1796       privileged  processes  can  perform  this  operation; for all others it
1797       fails with EPERM.
1798
1799   PCSCREDX
1800       Operates like PCSCRED but  also  sets  the  supplementary  groups;  the
1801       length  of  the  data  written  with  this  control operation should be
1802       "sizeof (prcred_t) + sizeof (gid_t) * (#groups - 1)".
1803
1804   PCSPRIV
1805       Set the target  process  privilege  to  the  values  contained  in  the
1806       prpriv_t operand (see /proc/pid/priv). The effective, permitted, inher‐
1807       itable, and limit sets are all changed. Privilege  flags  can  also  be
1808       set. The process is made privilege aware unless it can relinquish priv‐
1809       ilege awareness. See privileges(5).
1810
1811
1812       The limit set of the target process cannot be grown. The  other  privi‐
1813       lege  sets  must be subsets of the intersection of the effective set of
1814       the calling process with the new limit set of  the  target  process  or
1815       subsets of the original values of the sets in the target process.
1816
1817
1818       If any of the above restrictions are not met, EPERM is returned. If the
1819       structure written is improperly formatted, EINVAL is returned.
1820

PROGRAMMING NOTES

1822       For security reasons, except for the psinfo,  usage,  lpsinfo,  lusage,
1823       lwpsinfo,  and lwpusage files, which are world-readable, and except for
1824       privileged processes, an open of a /proc file  fails  unless  both  the
1825       user-ID  and  group-ID  of the caller match those of the traced process
1826       and the process's object file is readable by the caller. The  effective
1827       set of the caller is a superset of both the inheritable and the permit‐
1828       ted set of the target process. The limit set of the caller is a  super‐
1829       set  of the limit set of the target process. Except for the world-read‐
1830       able files just mentioned, files corresponding  to  setuid  and  setgid
1831       processes can be opened only by the appropriately privileged process.
1832
1833
1834       A  process  that is missing the basic privilege {PRIV_PROC_INFO} cannot
1835       see any processes under /proc that it cannot send a signal to.
1836
1837
1838       A process that has {PRIV_PROC_OWNER} asserted in its effective set  can
1839       open any file for reading. To manipulate or control a process, the con‐
1840       trolling process must have at least as many privileges in its effective
1841       set  as  the target process has in its effective, inheritable, and per‐
1842       mitted sets. The limit set of the controlling process must be a  super‐
1843       set  of  the  limit  set of the target process. Additional restrictions
1844       apply if any of the uids of  the  target  process  are  0.  See  privi‐
1845       leges(5).
1846
1847
1848       Even  if  held  by  a  privileged  process, an open process or lwp file
1849       descriptor (other than file descriptors for the  world-readable  files)
1850       becomes  invalid  if  the  traced  process  performs  an  exec(2)  of a
1851       setuid/setgid object file or an object file  that  the  traced  process
1852       cannot  read.  Any  operation  performed on an invalid file descriptor,
1853       except close(2), fails with EAGAIN. In this situation, if  any  tracing
1854       flags  are  set  and the process or any lwp file descriptor is open for
1855       writing, the process will have been directed to stop  and  its  run-on-
1856       last-close flag will have been set (see PCSET). This enables a control‐
1857       ling process (if it has permission) to reopen the /proc  files  to  get
1858       new  valid  file descriptors, close the invalid file descriptors, unset
1859       the run-on-last-close flag (if desired), and proceed. Just closing  the
1860       invalid  file descriptors causes the traced process to resume execution
1861       with all tracing flags cleared. Any  process  not  currently  open  for
1862       writing via /proc, but that has left-over tracing flags from a previous
1863       open, and that executes a setuid/setgid or unreadable object file, will
1864       not be stopped but will have all its tracing flags cleared.
1865
1866
1867       To wait for one or more of a set of processes or lwps to stop or termi‐
1868       nate, /proc file descriptors (other than those obtained by opening  the
1869       cwd  or root directories or by opening files in the fd or object direc‐
1870       tories) can be used in  a  poll(2)  system  call.  When  requested  and
1871       returned,  either of the polling events POLLPRI or POLLWRNORM indicates
1872       that the process or lwp stopped on an event of interest. Although  they
1873       cannot  be requested, the polling events POLLHUP, POLLERR, and POLLNVAL
1874       may be returned. POLLHUP indicates that the process or lwp  has  termi‐
1875       nated.  POLLERR  indicates that the file descriptor has become invalid.
1876       POLLNVAL is returned immediately if POLLPRI or POLLWRNORM is  requested
1877       on  a  file  descriptor referring to a system process (see PCSTOP). The
1878       requested events may be empty to wait simply for termination.
1879

FILES

1881       /proc
1882
1883           directory (list of processes)
1884
1885
1886       /proc/pid
1887
1888           specific process directory
1889
1890
1891       /proc/self
1892
1893           alias for a process's own directory
1894
1895
1896       /proc/pid/as
1897
1898           address space file
1899
1900
1901       /proc/pid/ctl
1902
1903           process control file
1904
1905
1906       /proc/pid/status
1907
1908           process status
1909
1910
1911       /proc/pid/lstatus
1912
1913           array of lwp status structs
1914
1915
1916       /proc/pid/psinfo
1917
1918           process ps(1) info
1919
1920
1921       /proc/pid/lpsinfo
1922
1923           array of lwp ps(1) info structs
1924
1925
1926       /proc/pid/map
1927
1928           address space map
1929
1930
1931       /proc/pid/xmap
1932
1933           extended address space map
1934
1935
1936       /proc/pid/rmap
1937
1938           reserved address map
1939
1940
1941       /proc/pid/cred
1942
1943           process credentials
1944
1945
1946       /proc/pid/priv
1947
1948           process privileges
1949
1950
1951       /proc/pid/sigact
1952
1953           process signal actions
1954
1955
1956       /proc/pid/auxv
1957
1958           process aux vector
1959
1960
1961       /proc/pid/ldt
1962
1963           process LDT (x86 only)
1964
1965
1966       /proc/pid/usage
1967
1968           process usage
1969
1970
1971       /proc/pid/lusage
1972
1973           array of lwp usage structs
1974
1975
1976       /proc/pid/path
1977
1978           symbolic links to process open files
1979
1980
1981       /proc/pid/pagedata
1982
1983           process page data
1984
1985
1986       /proc/pid/watch
1987
1988           active watchpoints
1989
1990
1991       /proc/pid/cwd
1992
1993           alias for the current working directory
1994
1995
1996       /proc/pid/root
1997
1998           alias for the root directory
1999
2000
2001       /proc/pid/fd
2002
2003           directory (list of open files)
2004
2005
2006       /proc/pid/fd/*
2007
2008           aliases for process's open files
2009
2010
2011       /proc/pid/object
2012
2013           directory (list of mapped files)
2014
2015
2016       /proc/pid/object/a.out
2017
2018           alias for process's executable file
2019
2020
2021       /proc/pid/object/*
2022
2023           aliases for other mapped files
2024
2025
2026       /proc/pid/lwp
2027
2028           directory (list of lwps)
2029
2030
2031       /proc/pid/lwp/lwpid
2032
2033           specific lwp directory
2034
2035
2036       /proc/pid/lwp/agent
2037
2038           alias for the agent lwp directory
2039
2040
2041       /proc/pid/lwp/lwpid/lwpctl
2042
2043           lwp control file
2044
2045
2046       /proc/pid/lwp/lwpid/lwpstatus
2047
2048           lwp status
2049
2050
2051       /proc/pid/lwp/lwpid/lwpsinfo
2052
2053           lwp ps(1) info
2054
2055
2056       /proc/pid/lwp/lwpid/lwpusage
2057
2058           lwp usage
2059
2060
2061       /proc/pid/lwp/lwpid/gwindows
2062
2063           register windows (SPARC only)
2064
2065
2066       /proc/pid/lwp/lwpid/xregs
2067
2068           extra state registers
2069
2070
2071       /proc/pid/lwp/lwpid/asrs
2072
2073           ancillary state registers (SPARC V9 only)
2074
2075

SEE ALSO

2077       ls(1),  ps(1),  chroot(1M),  alarm(2),  brk(2),  chdir(2),   chroot(2),
2078       close(2),  creat(2),  dup(2),  exec(2),  fcntl(2),  fork(2),  fork1(2),
2079       fstat(2),  getdents(2),  getustack(2),  kill(2),   lseek(2),   mmap(2),
2080       nice(2),  open(2),  poll(2),  pread(2), ptrace(3C), pwrite(2), read(2),
2081       readlink(2),   readv(2),   shmget(2),   sigaction(2),   sigaltstack(2),
2082       vfork(2),    write(2),    writev(2),    _stack_grow(3C),   readdir(3C),
2083       pthread_create(3C),    pthread_join(3C),     siginfo.h(3HEAD),     sig‐
2084       nal.h(3HEAD),  thr_create(3C),  thr_join(3C),  types32.h(3HEAD),  ucon‐
2085       text.h(3HEAD), wait(3C), contract(4), process(4), lfcompile(5),  privi‐
2086       leges(5)
2087

DIAGNOSTICS

2089       Errors  that  can  occur  in addition to the errors normally associated
2090       with file system access:
2091
2092       E2BIG        Data to be returned in a read(2) of  the  page  data  file
2093                    exceeds  the size of the read buffer provided by the call‐
2094                    er.
2095
2096
2097       EACCES       An attempt was made to examine a process that ran under  a
2098                    different   uid   than   the   controlling   process   and
2099                    {PRIV_PROC_OWNER} was not asserted in the effective set.
2100
2101
2102       EAGAIN       The  traced  process  has  performed  an  exec(2)   of   a
2103                    setuid/setgid  object  file  or  of an object file that it
2104                    cannot read; all further operations on the process or  lwp
2105                    file descriptor (except close(2)) elicit this error.
2106
2107
2108       EBUSY        PCSTOP,  PCDSTOP,  PCWSTOP,  or  PCTWSTOP was applied to a
2109                    system process; an exclusive open(2) was  attempted  on  a
2110                    /proc  file for a process already open for writing; PCRUN,
2111                    PCSREG, PCSVADDR, PCSFPREG, or PCSXREG was  applied  to  a
2112                    process  or  lwp  not  stopped on an event of interest; an
2113                    attempt was made  to  mount  /proc  when  it  was  already
2114                    mounted;  PCAGENT  was  applied  to a process that was not
2115                    fully stopped or that already had an agent lwp.
2116
2117
2118       EINVAL       In general, this means that some invalid argument was sup‐
2119                    plied  to  a  system call. A non-exhaustive list of condi‐
2120                    tions eliciting this error  includes:  a  control  message
2121                    operation code is undefined; an out-of-range signal number
2122                    was specified with PCSSIG, PCKILL,  or  PCUNKILL;  SIGKILL
2123                    was  specified  with  PCUNKILL;  PCSFPREG was applied on a
2124                    system that does not  support  floating-point  operations;
2125                    PCSXREG  was  applied  on  a  system that does not support
2126                    extra state registers.
2127
2128
2129       EINTR        A signal was received by  the  controlling  process  while
2130                    waiting  for the traced process or lwp to stop via PCSTOP,
2131                    PCWSTOP, or PCTWSTOP.
2132
2133
2134       EIO          A write(2) was attempted at  an  illegal  address  in  the
2135                    traced process.
2136
2137
2138       ENOENT       The  traced  process  or  lwp  has  terminated after being
2139                    opened.  The  basic  privilege  {PRIV_PROC_INFO}  is   not
2140                    asserted  in  the effective set of the calling process and
2141                    the calling process cannot send a  signal  to  the  target
2142                    process.
2143
2144
2145       ENOMEM       The  system-imposed  limit on the number of page data file
2146                    descriptors was reached on an open of  /proc/pid/pagedata;
2147                    an attempt was made with PCWATCH to establish more watched
2148                    areas than the system can support; the  PCAGENT  operation
2149                    was issued when the system was out of resources for creat‐
2150                    ing lwps.
2151
2152
2153       ENOSYS       An attempt was made to perform  an  unsupported  operation
2154                    (such  as  creat(2), link(2), or unlink(2)) on an entry in
2155                    /proc.
2156
2157
2158       EOVERFLOW    A 32-bit controlling process attempted to  read  or  write
2159                    the  as  file or attempted to read the map, rmap, or page‐
2160                    data file of a 64-bit target process. A 32-bit controlling
2161                    process  attempted  to apply one of the control operations
2162                    PCSREG,  PCSXREG,  PCSVADDR,  PCWATCH,  PCAGENT,   PCREAD,
2163                    PCWRITE to a 64-bit target process.
2164
2165
2166       EPERM        The  process that issued the PCSCRED or PCSCREDX operation
2167                    did not have the {PRIV_PROC_SETID} privilege  asserted  in
2168                    its  effective  set, or the process that issued the PCNICE
2169                    operation did not have  the  {PRIV_PROC_PRIOCNTL}  in  its
2170                    effective set.
2171
2172                    An  attempt  was made to control a process of which the E,
2173                    P, and I privilege sets were not a subset of the effective
2174                    set  of  the  controlling  process or the limit set of the
2175                    controlling process is not a superset of limit set of  the
2176                    controlled process.
2177
2178                    Any  of the uids of the target process are 0 or an attempt
2179                    was made to change any of the uids to 0 using PCSCRED  and
2180                    the  security  policy imposed additional restrictions. See
2181                    privileges(5).
2182
2183

NOTES

2185       Descriptions of structures in this document  include  only  interesting
2186       structure  elements,  not  filler and padding fields, and may show ele‐
2187       ments out of order for descriptive clarity. The actual structure  defi‐
2188       nitions are contained in <procfs.h>.
2189

BUGS

2191       Because  the old ioctl(2)-based version of /proc is currently supported
2192       for binary compatibility with old applications, the top-level directory
2193       for  a  process,  /proc/pid,  is  not  world-readable, but it is world-
2194       searchable. Thus, anyone can open /proc/pid/psinfo  even  though  ls(1)
2195       applied to /proc/pid will fail for anyone but the owner or an appropri‐
2196       ately privileged process. Support for the old ioctl(2)-based version of
2197       /proc  will be dropped in a future release, at which time the top-level
2198       directory for a process will be made world-readable.
2199
2200
2201       On SPARC based machines, the types gregset_t and fpregset_t defined  in
2202       <sys/regset.h> are similar to but not the same as the types prgregset_t
2203       and prfpregset_t defined in <procfs.h>.
2204
2205
2206
2207SunOS 5.11                        29 Nov 2006                          proc(4)
Impressum