Print this page
    
OS-3820 lxbrand ptrace(2): the next generation
OS-3685 lxbrand PTRACE_O_TRACEFORK race condition
OS-3834 lxbrand 64-bit strace(1) reports 64-bit process as using x32 ABI
OS-3794 lxbrand panic on init signal death
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Bryan Cantrill <bryan@joyent.com>
OS-3463 expose process argv through procfs
OS-3207 in lx zone, 'ps auxww' does not show full cmdline for processes
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
OS-3383 lx brand: node.js test test-setproctitle.js fails
OS-15 add procfs equivalent to prctl(PR_SET_NAME)
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/man/man4/proc.4.man.txt
          +++ new/usr/src/man/man4/proc.4.man.txt
   1    1  PROC(4)                 File Formats and Configurations                PROC(4)
   2    2  
   3    3  
   4    4  
   5    5  NAME
   6    6         proc - /proc, the process file system
   7    7  
   8    8  DESCRIPTION
   9    9         /proc is a file system that provides access to the state of each
  10   10         process and light-weight process (lwp) in the system. The name of each
  11   11         entry in the /proc directory is a decimal number corresponding to a
  12   12         process-ID. These entries are themselves subdirectories. Access to
  13   13         process state is provided by additional files contained within each
  14   14         subdirectory; the hierarchy is described more completely below. In this
  15   15         document, ``/proc file'' refers to a non-directory file within the
  16   16         hierarchy rooted at /proc. The owner of each /proc file and
  17   17         subdirectory is determined by the user-ID of the process.
  18   18  
  19   19  
  20   20         /proc can be mounted on any mount point, in addition to the standard
  21   21         /proc mount point, and can be mounted several places at once. Such
  22   22         additional mounts are allowed in order to facilitate the confinement of
  23   23         processes to subtrees of the file system via chroot(1M) and yet allow
  24   24         such processes access to commands like ps(1).
  25   25  
  26   26  
  27   27         Standard system calls are used to access /proc files: open(2),
  28   28         close(2), read(2), and write(2) (including readv(2), writev(2),
  29   29         pread(2), and pwrite(2)). Most files describe process state and can
  30   30         only be opened for reading. ctl and lwpctl (control) files permit
  31   31         manipulation of process state and can only be opened for writing. as
  32   32         (address space) files contain the image of the running process and can
  33   33         be opened for both reading and writing. An open for writing allows
  34   34         process control; a read-only open allows inspection but not control. In
  35   35         this document, we refer to the process as open for reading or writing
  36   36         if any of its associated /proc files is open for reading or writing.
  37   37  
  38   38  
  39   39         In general, more than one process can open the same /proc file at the
  40   40         same time. Exclusive open is an advisory mechanism provided to allow
  41   41         controlling processes to avoid collisions with each other. A process
  42   42         can obtain exclusive control of a target process, with respect to other
  43   43         cooperating processes, if it successfully opens any /proc file in the
  44   44         target process for writing (the as or ctl files, or the lwpctl file of
  45   45         any lwp) while specifying O_EXCL in the open(2). Such an open will fail
  46   46         if the target process is already open for writing (that is, if an as,
  47   47         ctl, or lwpctl file is already open for writing). There can be any
  48   48         number of concurrent read-only opens; O_EXCL is ignored on opens for
  49   49         reading. It is recommended that the first open for writing by a
  50   50         controlling process use the O_EXCL flag; multiple controlling processes
  51   51         usually result in chaos.
  52   52  
  53   53  
  54   54         If a process opens one of its own /proc files for writing, the open
  55   55         succeeds regardless of O_EXCL and regardless of whether some other
  56   56         process has the process open for writing. Self-opens do not count when
  57   57         another process attempts an exclusive open. (A process cannot exclude a
  58   58         debugger by opening itself for writing and the application of a
  59   59         debugger cannot prevent a process from opening itself.) All self-opens
  60   60         for writing are forced to be close-on-exec (see the F_SETFD operation
  61   61         of fcntl(2)).
  62   62  
  63   63  
  64   64         Data may be transferred from or to any locations in the address space
  65   65         of the traced process by applying lseek(2) to position the as file at
  66   66         the virtual address of interest followed by read(2) or write(2) (or by
  67   67         using pread(2) or pwrite(2) for the combined operation). The address-
  68   68         map files /proc/pid/map and /proc/pid/xmap can be read to determine the
  69   69         accessible areas (mappings) of the address space. I/O transfers may
  70   70         span contiguous mappings. An I/O request extending into an unmapped
  71   71         area is truncated at the boundary. A write request beginning at an
  72   72         unmapped virtual address fails with EIO; a read request beginning at an
  73   73         unmapped virtual address returns zero (an end-of-file indication).
  74   74  
  75   75  
  76   76         Information and control operations are provided through additional
  77   77         files.  <procfs.h> contains definitions of data structures and message
  78   78         formats used with these files. Some of these definitions involve the
  79   79         use of sets of flags. The set types sigset_t, fltset_t, and sysset_t
  80   80         correspond, respectively, to signal, fault, and system call
  81   81         enumerations defined in <sys/signal.h>, <sys/fault.h>, and
  82   82         <sys/syscall.h>. Each set type is large enough to hold flags for its
  83   83         own enumeration. Although they are of different sizes, they have a
  84   84         common structure and can be manipulated by these macros:
  85   85  
  86   86           prfillset(&set);             /* turn on all flags in set */
  87   87           premptyset(&set);            /* turn off all flags in set */
  88   88           praddset(&set, flag);        /* turn on the specified flag */
  89   89           prdelset(&set, flag);        /* turn off the specified flag */
  90   90           r = prismember(&set, flag);  /* != 0 iff flag is turned on */
  91   91  
  92   92  
  93   93  
  94   94         One of prfillset() or premptyset() must be used to initialize set
  95   95         before it is used in any other operation. flag must be a member of the
  96   96         enumeration corresponding to set.
  97   97  
  98   98  
  99   99         Every process contains at least one light-weight process, or lwp.  Each
 100  100         lwp represents a flow of execution that is independently scheduled by
 101  101         the operating system. All lwps in a process share its address space as
 102  102         well as many other attributes. Through the use of lwpctl and ctl files
 103  103         as described below, it is possible to affect individual lwps in a
 104  104         process or to affect all of them at once, depending on the operation.
 105  105  
 106  106  
 107  107         When the process has more than one lwp, a representative lwp is chosen
 108  108         by the system for certain process status files and control operations.
 109  109         The representative lwp is a stopped lwp only if all of the process's
 110  110         lwps are stopped; is stopped on an event of interest only if all of the
 111  111         lwps are so stopped (excluding PR_SUSPENDED lwps); is in a PR_REQUESTED
 112  112         stop only if there are no other events of interest to be found; or,
 113  113         failing everything else, is in a PR_SUSPENDED stop (implying that the
 114  114         process is deadlocked). See the description of the status file for
 115  115         definitions of stopped states. See the PCSTOP control operation for the
 116  116         definition of ``event of interest''.
 117  117  
 118  118  
 119  119         The representative lwp remains fixed (it will be chosen again on the
 120  120         next operation) as long as all of the lwps are stopped on events of
 121  121         interest or are in a PR_SUSPENDED stop and the PCRUN control operation
 122  122         is not applied to any of them.
 123  123  
 124  124  
 125  125         When applied to the process control file, every /proc control operation
 126  126         that must act on an lwp uses the same algorithm to choose which lwp to
 127  127         act upon. Together with synchronous stopping (see PCSET), this enables
 128  128         a debugger to control a multiple-lwp process using only the process-
 129  129         level status and control files if it so chooses. More fine-grained
 130  130         control can be achieved using the lwp-specific files.
 131  131  
 132  132  
 133  133         The system supports two process data models, the traditional 32-bit
 134  134         data model in which ints, longs and pointers are all 32 bits wide (the
 135  135         ILP32 data model), and on some platforms the 64-bit data model in which
 136  136         longs and pointers, but not ints, are 64 bits in width (the LP64 data
 137  137         model). In the LP64 data model some system data types, notably size_t,
 138  138         off_t, time_t and dev_t, grow from 32 bits to 64 bits as well.
 139  139  
 140  140  
 141  141         The /proc interfaces described here are available to both 32-bit and
 142  142         64-bit controlling processes. However, many operations attempted by a
 143  143         32-bit controlling process on a 64-bit target process will fail with
 144  144         EOVERFLOW because the address space range of a 32-bit process cannot
 145  145         encompass a 64-bit process or because the data in some 64-bit system
 146  146         data type cannot be compressed to fit into the corresponding 32-bit
 147  147         type without loss of information. Operations that fail in this
 148  148         circumstance include reading and writing the address space, reading the
 149  149         address-map files, and setting the target process's registers. There is
 150  150         no restriction on operations applied by a 64-bit process to either a
 151  151         32-bit or a 64-bit target processes.
 152  152  
 153  153  
 154  154         The format of the contents of any /proc file depends on the data model
 155  155         of the observer (the controlling process), not on the data model of the
 156  156         target process. A 64-bit debugger does not have to translate the
 157  157         information it reads from a /proc file for a 32-bit process from 32-bit
 158  158         format to 64-bit format. However, it usually has to be aware of the
 159  159         data model of the target process. The pr_dmodel field of the status
 160  160         files indicates the target process's data model.
 161  161  
 162  162  
 163  163         To help deal with system data structures that are read from 32-bit
 164  164         processes, a 64-bit controlling program can be compiled with the C
 165  165         preprocessor symbol _SYSCALL32 defined before system header files are
 166  166         included. This makes explicit 32-bit fixed-width data structures (like
 167  167         cstruct stat32) visible to the 64-bit program. See types32.h(3HEAD).
 168  168  
 169  169  DIRECTORY STRUCTURE
 170  170         At the top level, the directory /proc contains entries each of which
 171  171         names an existing process in the system. These entries are themselves
 172  172         directories. Except where otherwise noted, the files described below
 173  173         can be opened for reading only. In addition, if a process becomes a
 174  174         zombie (one that has exited but whose parent has not yet performed a
 175  175         wait(3C) upon it), most of its associated /proc files disappear from
 176  176         the hierarchy; subsequent attempts to open them, or to read or write
 177  177         files opened before the process exited, will elicit the error ENOENT.
 178  178  
 179  179  
 180  180         Although process state and consequently the contents of /proc files can
 181  181         change from instant to instant, a single read(2) of a /proc file is
 182  182         guaranteed to return a sane representation of state; that is, the read
 183  183         will be atomic with respect to the state of the process. No such
 184  184         guarantee applies to successive reads applied to a /proc file for a
 185  185         running process. In addition, atomicity is not guaranteed for I/O
 186  186         applied to the as (address-space) file for a running process or for a
 187  187         process whose address space contains memory shared by another running
 188  188         process.
 189  189  
 190  190  
 191  191         A number of structure definitions are used to describe the files. These
 192  192         structures may grow by the addition of elements at the end in future
 193  193         releases of the system and it is not legitimate for a program to assume
 194  194         that they will not.
 195  195  
 196  196  STRUCTURE OF /proc/pid
 197  197         A given directory /proc/pid contains the following entries. A process
 198  198         can use the invisible alias /proc/self if it wishes to open one of its
 199  199         own /proc files (invisible in the sense that the name ``self'' does not
 200  200         appear in a directory listing of /proc obtained from ls(1),
 201  201         getdents(2), or readdir(3C)).
 202  202  
 203  203     contracts
 204  204         A directory containing references to the contracts held by the process.
 205  205         Each entry is a symlink to the contract's directory under
 206  206         /system/contract.  See contract(4).
 207  207  
 208  208     as
 209  209         Contains the address-space image of the process; it can be opened for
 210  210         both reading and writing. lseek(2) is used to position the file at the
 211  211         virtual address of interest and then the address space can be examined
 212  212         or changed through read(2) or write(2) (or by using pread(2) or
 213  213         pwrite(2) for the combined operation).
 214  214  
 215  215     ctl
 216  216         A write-only file to which structured messages are written directing
 217  217         the system to change some aspect of the process's state or control its
 218  218         behavior in some way. The seek offset is not relevant when writing to
 219  219         this file. Individual lwps also have associated lwpctl files in the lwp
 220  220         subdirectories. A control message may be written either to the
 221  221         process's ctl file or to a specific lwpctl file with operation-specific
 222  222         effects. The effect of a control message is immediately reflected in
 223  223         the state of the process visible through appropriate status and
 224  224         information files. The types of control messages are described in
 225  225         detail later. See CONTROL MESSAGES.
 226  226  
 227  227     status
 228  228         Contains state information about the process and the representative
 229  229         lwp. The file contains a pstatus structure which contains an embedded
 230  230         lwpstatus structure for the representative lwp, as follows:
 231  231  
 232  232           typedef struct pstatus {
 233  233                int pr_flags;            /* flags (see below) */
 234  234                int pr_nlwp;             /* number of active lwps in the process */
 235  235                int pr_nzomb;            /* number of zombie lwps in the process */
 236  236                pid_tpr_pid;             /* process id */
 237  237                pid_tpr_ppid;            /* parent process id */
 238  238                pid_tpr_pgid;            /* process group id */
 239  239                pid_tpr_sid;             /* session id */
 240  240                id_t pr_aslwpid;         /* obsolete */
 241  241                id_t pr_agentid;         /* lwp-id of the agent lwp, if any */
 242  242                sigset_t pr_sigpend;     /* set of process pending signals */
 243  243                uintptr_t pr_brkbase;    /* virtual address of the process heap */
 244  244                size_t pr_brksize;       /* size of the process heap, in bytes */
 245  245                uintptr_t pr_stkbase;    /* virtual address of the process stack */
 246  246                size_tpr_stksize;        /* size of the process stack, in bytes */
 247  247                timestruc_t pr_utime;    /* process user cpu time */
 248  248                timestruc_t pr_stime;    /* process system cpu time */
 249  249                timestruc_t pr_cutime;   /* sum of children's user times */
 250  250                timestruc_t pr_cstime;   /* sum of children's system times */
 251  251                sigset_t pr_sigtrace;    /* set of traced signals */
 252  252                fltset_t pr_flttrace;    /* set of traced faults */
 253  253                sysset_t pr_sysentry;    /* set of system calls traced on entry */
 254  254                sysset_t pr_sysexit;     /* set of system calls traced on exit */
 255  255                char pr_dmodel;          /* data model of the process */
 256  256                taskid_t pr_taskid;      /* task id */
 257  257                projid_t pr_projid;      /* project id */
 258  258                zoneid_t pr_zoneid;      /* zone id */
 259  259                lwpstatus_t pr_lwp;      /* status of the representative lwp */
 260  260           } pstatus_t;
 261  261  
 262  262  
 263  263  
 264  264         pr_flags is a bit-mask holding the following process flags. For
 265  265         convenience, it also contains the lwp flags for the representative lwp,
 266  266         described later.
 267  267  
 268  268         PR_ISSYS
 269  269                      process is a system process (see PCSTOP).
 270  270  
 271  271  
 272  272         PR_VFORKP
 273  273                      process is the parent of a vforked child (see PCWATCH).
 274  274  
 275  275  
 276  276         PR_FORK
 277  277                      process has its inherit-on-fork mode set (see PCSET).
 278  278  
 279  279  
 280  280         PR_RLC
 281  281                      process has its run-on-last-close mode set (see PCSET).
 282  282  
 283  283  
 284  284         PR_KLC
 285  285                      process has its kill-on-last-close mode set (see PCSET).
 286  286  
 287  287  
 288  288         PR_ASYNC
 289  289                      process has its asynchronous-stop mode set (see PCSET).
 290  290  
 291  291  
 292  292         PR_MSACCT
 293  293                      Set by default in all processes to indicate that
 294  294                      microstate accounting is enabled. However, this flag has
 295  295                      been deprecated and no longer has any effect.  Microstate
 296  296                      accounting may not be disabled; however, it is still
 297  297                      possible to toggle the flag.
 298  298  
 299  299  
 300  300         PR_MSFORK
 301  301                      Set by default in all processes to indicate that
 302  302                      microstate accounting will be enabled for processes that
 303  303                      this parent forks(). However, this flag has been
 304  304                      deprecated and no longer has any effect. It is possible to
 305  305                      toggle this flag; however, it is not possible to disable
 306  306                      microstate accounting.
 307  307  
 308  308  
 309  309         PR_BPTADJ
 310  310                      process has its breakpoint adjustment mode set (see
 311  311                      PCSET).
 312  312  
 313  313  
 314  314         PR_PTRACE
 315  315                      process has its ptrace-compatibility mode set (see PCSET).
 316  316  
 317  317  
 318  318  
 319  319         pr_nlwp is the total number of active lwps in the process. pr_nzomb is
 320  320         the total number of zombie lwps in the process. A zombie lwp is a non-
 321  321         detached lwp that has terminated but has not been reaped with
 322  322         thr_join(3C) or pthread_join(3C).
 323  323  
 324  324  
 325  325         pr_pid, pr_ppid, pr_pgid, and pr_sid are, respectively, the process ID,
 326  326         the ID of the process's parent, the process's process group ID, and the
 327  327         process's session ID.
 328  328  
 329  329  
 330  330         pr_aslwpid is obsolete and is always zero.
 331  331  
 332  332  
 333  333         pr_agentid is the lwp-ID for the /proc agent lwp (see the PCAGENT
 334  334         control operation). It is zero if there is no agent lwp in the process.
 335  335  
 336  336  
 337  337         pr_sigpend identifies asynchronous signals pending for the process.
 338  338  
 339  339  
 340  340         pr_brkbase is the virtual address of the process heap and pr_brksize is
 341  341         its size in bytes. The address formed by the sum of these values is the
 342  342         process break (see brk(2)). pr_stkbase and pr_stksize are,
 343  343         respectively, the virtual address of the process stack and its size in
 344  344         bytes. (Each lwp runs on a separate stack; the distinguishing
 345  345         characteristic of the process stack is that the operating system will
 346  346         grow it when necessary.)
 347  347  
 348  348  
 349  349         pr_utime, pr_stime, pr_cutime, and pr_cstime are, respectively, the
 350  350         user CPU and system CPU time consumed by the process, and the
 351  351         cumulative user CPU and system CPU time consumed by the process's
 352  352         children, in seconds and nanoseconds.
 353  353  
 354  354  
 355  355         pr_sigtrace and pr_flttrace contain, respectively, the set of signals
 356  356         and the set of hardware faults that are being traced (see PCSTRACE and
 357  357         PCSFAULT).
 358  358  
 359  359  
 360  360         pr_sysentry and pr_sysexit contain, respectively, the sets of system
 361  361         calls being traced on entry and exit (see PCSENTRY and PCSEXIT).
 362  362  
 363  363  
 364  364         pr_dmodel indicates the data model of the process. Possible values are:
 365  365  
 366  366         PR_MODEL_ILP32
 367  367                            process data model is ILP32.
 368  368  
 369  369  
 370  370         PR_MODEL_LP64
 371  371                            process data model is LP64.
 372  372  
 373  373  
 374  374         PR_MODEL_NATIVE
 375  375                            process data model is native.
 376  376  
 377  377  
 378  378  
 379  379         The pr_taskid, pr_projid, and pr_zoneid fields contain respectively,
 380  380         the numeric IDs of the task, project, and zone in which the process was
 381  381         running.
 382  382  
 383  383  
 384  384         The constant PR_MODEL_NATIVE reflects the data model of the controlling
 385  385         process, that is, its value is PR_MODEL_ILP32 or PR_MODEL_LP64
 386  386         according to whether the controlling process has been compiled as a
 387  387         32-bit program or a 64-bit program, respectively.
 388  388  
 389  389  
 390  390         pr_lwp contains the status information for the representative lwp:
 391  391  
 392  392           typedef struct lwpstatus {
 393  393             int pr_flags;              /* flags (see below) */
 394  394             id_t pr_lwpid;             /* specific lwp identifier */
 395  395             short pr_why;              /* reason for lwp stop, if stopped */
 396  396             short pr_what;             /* more detailed reason */
 397  397             short pr_cursig;           /* current signal, if any */
 398  398             siginfo_t pr_info;         /* info associated with signal or fault */
 399  399             sigset_t pr_lwppend;       /* set of signals pending to the lwp */
 400  400             sigset_t pr_lwphold;       /* set of signals blocked by the lwp */
 401  401             struct sigaction pr_action;/* signal action for current signal */
 402  402             stack_t pr_altstack;       /* alternate signal stack info */
 403  403             uintptr_t pr_oldcontext;   /* address of previous ucontext */
 404  404             short pr_syscall;          /* system call number (if in syscall) */
 405  405             short pr_nsysarg;          /* number of arguments to this syscall */
 406  406             int pr_errno;              /* errno for failed syscall */
 407  407             long pr_sysarg[PRSYSARGS]; /* arguments to this syscall */
 408  408             long pr_rval1;             /* primary syscall return value */
 409  409             long pr_rval2;             /* second syscall return value, if any */
 410  410             char pr_clname[PRCLSZ];    /* scheduling class name */
 411  411             timestruc_t pr_tstamp;     /* real-time time stamp of stop */
 412  412             timestruc_t pr_utime;      /* lwp user cpu time */
 413  413             timestruc_t pr_stime;      /* lwp system cpu time */
 414  414             uintptr_t pr_ustack;       /* stack boundary data (stack_t) address */
 415  415             ulong_t pr_instr;          /* current instruction */
 416  416             prgregset_t pr_reg;        /* general registers */
 417  417             prfpregset_t pr_fpreg;     /* floating-point registers */
 418  418           } lwpstatus_t;
 419  419  
 420  420  
 421  421  
 422  422         pr_flags is a bit-mask holding the following lwp flags. For
 423  423         convenience, it also contains the process flags, described previously.
 424  424  
 425  425         PR_STOPPED
 426  426                       The lwp is stopped.
 427  427  
 428  428  
 429  429         PR_ISTOP
 430  430                       The lwp is stopped on an event of interest (see PCSTOP).
 431  431  
 432  432  
 433  433         PR_DSTOP
 434  434                       The lwp has a stop directive in effect (see PCSTOP).
 435  435  
 436  436  
 437  437         PR_STEP
 438  438                       The lwp has a single-step directive in effect (see
 439  439                       PCRUN).
 440  440  
 441  441  
 442  442         PR_ASLEEP
 443  443                       The lwp is in an interruptible sleep within a system
 444  444                       call.
 445  445  
 446  446  
 447  447         PR_PCINVAL
 448  448                       The lwp's current instruction (pr_instr) is undefined.
 449  449  
 450  450  
 451  451         PR_DETACH
 452  452                       This is a detached lwp (see pthread_create(3C) and
 453  453                       pthread_join(3C)).
 454  454  
 455  455  
 456  456         PR_DAEMON
 457  457                       This is a daemon lwp (see pthread_create(3C)).
 458  458  
 459  459  
 460  460         PR_ASLWP
 461  461                       This flag is obsolete and is never set.
 462  462  
 463  463  
 464  464         PR_AGENT
 465  465                       This is the /proc agent lwp for the process.
 466  466  
 467  467  
 468  468  
 469  469         pr_lwpid names the specific lwp.
 470  470  
 471  471  
 472  472         pr_why and pr_what together describe, for a stopped lwp, the reason for
 473  473         the stop. Possible values of pr_why and the associated pr_what are:
 474  474  
 475  475         PR_REQUESTED
 476  476                          indicates that the stop occurred in response to a stop
 477  477                          directive, normally because PCSTOP was applied or
 478  478                          because another lwp stopped on an event of interest
 479  479                          and the asynchronous-stop flag (see PCSET) was not set
 480  480                          for the process. pr_what is unused in this case.
 481  481  
 482  482  
 483  483         PR_SIGNALLED
 484  484                          indicates that the lwp stopped on receipt of a signal
 485  485                          (see PCSTRACE); pr_what holds the signal number that
 486  486                          caused the stop (for a newly-stopped lwp, the same
 487  487                          value is in pr_cursig).
 488  488  
 489  489  
 490  490         PR_FAULTED
 491  491                          indicates that the lwp stopped on incurring a hardware
 492  492                          fault (see PCSFAULT); pr_what holds the fault number
 493  493                          that caused the stop.
 494  494  
 495  495  
 496  496         PR_SYSENTRY
 497  497         PR_SYSEXIT
 498  498                          indicate a stop on entry to or exit from a system call
 499  499                          (see PCSENTRY and PCSEXIT); pr_what holds the system
 500  500                          call number.
 501  501  
 502  502  
 503  503         PR_JOBCONTROL
 504  504                          indicates that the lwp stopped due to the default
 505  505                          action of a job control stop signal (see
  
    | 
      ↓ open down ↓ | 
    505 lines elided | 
    
      ↑ open up ↑ | 
  
 506  506                          sigaction(2)); pr_what holds the stopping signal
 507  507                          number.
 508  508  
 509  509  
 510  510         PR_SUSPENDED
 511  511                          indicates that the lwp stopped due to internal
 512  512                          synchronization of lwps within the process. pr_what is
 513  513                          unused in this case.
 514  514  
 515  515  
      516 +       PR_BRAND
      517 +                        indicates that the lwp stopped for a brand-specific
      518 +                        reason.  Interpretation of the value of pr_what
      519 +                        depends on which zone brand is in use.  It is not
      520 +                        generally expected that an lwp stopped in this state
      521 +                        will be restarted by native proc(4) consumers.
 516  522  
      523 +
      524 +
 517  525         pr_cursig names the current signal, that is, the next signal to be
 518  526         delivered to the lwp, if any. pr_info, when the lwp is in a
 519  527         PR_SIGNALLED or PR_FAULTED stop, contains additional information
 520  528         pertinent to the particular signal or fault (see <sys/siginfo.h>).
 521  529  
 522  530  
 523  531         pr_lwppend identifies any synchronous or directed signals pending for
 524  532         the lwp. pr_lwphold identifies those signals whose delivery is being
 525  533         blocked by the lwp (the signal mask).
 526  534  
 527  535  
 528  536         pr_action contains the signal action information pertaining to the
 529  537         current signal (see sigaction(2)); it is undefined if pr_cursig is
 530  538         zero. pr_altstack contains the alternate signal stack information for
 531  539         the lwp (see sigaltstack(2)).
 532  540  
 533  541  
 534  542         pr_oldcontext, if not zero, contains the address on the lwp stack of a
 535  543         ucontext structure describing the previous user-level context (see
 536  544         ucontext.h(3HEAD)). It is non-zero only if the lwp is executing in the
 537  545         context of a signal handler.
 538  546  
 539  547  
 540  548         pr_syscall is the number of the system call, if any, being executed by
 541  549         the lwp; it is non-zero if and only if the lwp is stopped on
 542  550         PR_SYSENTRY or PR_SYSEXIT, or is asleep within a system call (
 543  551         PR_ASLEEP is set). If pr_syscall is non-zero, pr_nsysarg is the number
 544  552         of arguments to the system call and pr_sysarg contains the actual
 545  553         arguments.
 546  554  
 547  555  
 548  556         pr_rval1, pr_rval2, and pr_errno are defined only if the lwp is stopped
 549  557         on PR_SYSEXIT or if the PR_VFORKP flag is set. If pr_errno is zero,
 550  558         pr_rval1 and pr_rval2 contain the return values from the system call.
 551  559         Otherwise, pr_errno contains the error number for the failing system
 552  560         call (see <sys/errno.h>).
 553  561  
 554  562  
 555  563         pr_clname contains the name of the lwp's scheduling class.
 556  564  
 557  565  
 558  566         pr_tstamp, if the lwp is stopped, contains a time stamp marking when
 559  567         the lwp stopped, in real time seconds and nanoseconds since an
 560  568         arbitrary time in the past.
 561  569  
 562  570  
 563  571         pr_utime is the amount of user level CPU time used by this LWP.
 564  572  
 565  573  
 566  574         pr_stime is the amount of system level CPU time used by this LWP.
 567  575  
 568  576  
 569  577         pr_ustack is the virtual address of the stack_t that contains the stack
 570  578         boundaries for this LWP. See getustack(2) and _stack_grow(3C).
 571  579  
 572  580  
 573  581         pr_instr contains the machine instruction to which the lwp's program
 574  582         counter refers. The amount of data retrieved from the process is
 575  583         machine-dependent. On SPARC based machines, it is a 32-bit word. On
 576  584         x86-based machines, it is a single byte. In general, the size is that
 577  585         of the machine's smallest instruction. If PR_PCINVAL is set, pr_instr
 578  586         is undefined; this occurs whenever the lwp is not stopped or when the
 579  587         program counter refers to an invalid virtual address.
 580  588  
 581  589  
 582  590         pr_reg is an array holding the contents of a stopped lwp's general
 583  591         registers.
 584  592  
 585  593         SPARC
 586  594                              On SPARC-based machines, the predefined constants
 587  595                              R_G0 ... R_G7, R_O0 ... R_O7, R_L0 ... R_L7, R_I0
 588  596                              ...  R_I7, R_PC, R_nPC, and R_Y can be used as
 589  597                              indices to refer to the corresponding registers;
 590  598                              previous register windows can be read from their
 591  599                              overflow locations on the stack (however, see the
 592  600                              gwindows file in the /proc/pid/lwp/lwpid
 593  601                              subdirectory).
 594  602  
 595  603  
 596  604         SPARC V8 (32-bit)
 597  605                              For SPARC V8 (32-bit) controlling processes, the
 598  606                              predefined constants R_PSR, R_WIM, and R_TBR can
 599  607                              be used as indices to refer to the corresponding
 600  608                              special registers. For SPARC V9 (64-bit)
 601  609                              controlling processes, the predefined constants
 602  610                              R_CCR, R_ASI, and R_FPRS can be used as indices to
 603  611                              refer to the corresponding special registers.
 604  612  
 605  613  
 606  614         x86 (32-bit)
 607  615                              For 32-bit x86 processes, the predefined constants
 608  616                              listed belowcan be used as indices to refer to the
 609  617                              corresponding registers.
 610  618  
 611  619                                SS
 612  620                                UESP
 613  621                                EFL
 614  622                                CS
 615  623                                EIP
 616  624                                ERR
 617  625                                TRAPNO
 618  626                                EAX
 619  627                                ECX
 620  628                                EDX
 621  629                                EBX
 622  630                                ESP
 623  631                                EBP
 624  632                                ESI
 625  633                                EDI
 626  634                                DS
 627  635                                ES
 628  636                                GS
 629  637  
 630  638                              The preceding constants are listed in
 631  639                              <sys/regset.h>.
 632  640  
 633  641                              Note that a 32-bit process can run on an x86
 634  642                              64-bit system, using the constants listed above.
 635  643  
 636  644  
 637  645         x86 (64-bit)
 638  646                              To read the registers of a 32- or a 64-bit
 639  647                              process, a 64-bit x86 process should use the
 640  648                              predefined constants listed below.
 641  649  
 642  650                                REG_GSBASE
 643  651                                REG_FSBASE
 644  652                                REG_DS
 645  653                                REG_ES
 646  654                                REG_GS
 647  655                                REG_FS
 648  656                                REG_SS
 649  657                                REG_RSP
 650  658                                REG_RFL
 651  659                                REG_CS
 652  660                                REG_RIP
 653  661                                REG_ERR
 654  662                                REG_TRAPNO
 655  663                                REG_RAX
 656  664                                REG_RCX
 657  665                                REG_RDX
 658  666                                REG_RBX
 659  667                                REG_RBP
 660  668                                REG_RSI
 661  669                                REG_RDI
 662  670                                REG_R8
 663  671                                REG_R9
 664  672                                REG_R10
 665  673                                REG_R11
 666  674                                REG_R12
 667  675                                REG_R13
 668  676                                REG_R14
 669  677                                REG_R15
 670  678  
 671  679                              The preceding constants are listed in
 672  680                              <sys/regset.h>.
 673  681  
 674  682  
 675  683  
 676  684         pr_fpreg is a structure holding the contents of the floating-point
 677  685         registers.
 678  686  
 679  687  
 680  688         SPARC registers, both general and floating-point, as seen by a 64-bit
 681  689         controlling process are the V9 versions of the registers, even if the
 682  690         target process is a 32-bit (V8) process. V8 registers are a subset of
 683  691         the V9 registers.
 684  692  
 685  693  
 686  694         If the lwp is not stopped, all register values are undefined.
 687  695  
 688  696     psinfo
 689  697         Contains miscellaneous information about the process and the
 690  698         representative lwp needed by the ps(1) command. psinfo remains
 691  699         accessible after a process becomes a zombie. The file contains a psinfo
 692  700         structure which contains an embedded lwpsinfo structure for the
 693  701         representative lwp, as follows:
 694  702  
 695  703           typedef struct psinfo {
 696  704               int pr_flag;             /* process flags (DEPRECATED: see below) */
 697  705               int pr_nlwp;             /* number of active lwps in the process */
 698  706               int pr_nzomb;            /* number of zombie lwps in the process */
 699  707               pid_t pr_pid;            /* process id */
 700  708               pid_t pr_ppid;           /* process id of parent */
 701  709               pid_t pr_pgid;           /* process id of process group leader */
 702  710               pid_t pr_sid;            /* session id */
 703  711               uid_t pr_uid;            /* real user id */
 704  712               uid_t pr_euid;           /* effective user id */
 705  713               gid_t pr_gid;            /* real group id */
 706  714               gid_t pr_egid;           /* effective group id */
 707  715               uintptr_t pr_addr;       /* address of process */
 708  716               size_t pr_size;          /* size of process image in Kbytes */
 709  717               size_t pr_rssize;        /* resident set size in Kbytes */
 710  718               dev_t pr_ttydev;         /* controlling tty device (or PRNODEV) */
 711  719               ushort_t pr_pctcpu;      /* % of recent cpu time used by all lwps */
 712  720               ushort_t pr_pctmem;      /* % of system memory used by process */
 713  721               timestruc_t pr_start;    /* process start time, from the epoch */
 714  722               timestruc_t pr_time;     /* cpu time for this process */
 715  723               timestruc_t pr_ctime;    /* cpu time for reaped children */
 716  724               char pr_fname[PRFNSZ];   /* name of exec'ed file */
 717  725               char pr_psargs[PRARGSZ]; /* initial characters of arg list */
 718  726               int pr_wstat;            /* if zombie, the wait() status */
 719  727               int pr_argc;             /* initial argument count */
 720  728               uintptr_t pr_argv;       /* address of initial argument vector */
 721  729               uintptr_t pr_envp;       /* address of initial environment vector */
 722  730               char pr_dmodel;          /* data model of the process */
 723  731               lwpsinfo_t pr_lwp;       /* information for representative lwp */
 724  732               taskid_t pr_taskid;      /* task id */
 725  733               projid_t pr_projid;      /* project id */
 726  734               poolid_t pr_poolid;      /* pool id */
 727  735               zoneid_t pr_zoneid;      /* zone id */
 728  736               ctid_t pr_contract;      /* process contract id */
 729  737           } psinfo_t;
 730  738  
 731  739  
 732  740  
 733  741         Some of the entries in psinfo, such as pr_addr, refer to internal
 734  742         kernel data structures and should not be expected to retain their
 735  743         meanings across different versions of the operating system.
 736  744  
 737  745  
  
    | 
      ↓ open down ↓ | 
    211 lines elided | 
    
      ↑ open up ↑ | 
  
 738  746         psinfo_t.pr_flag is a deprecated interface that should no longer be
 739  747         used.  Applications currently relying on the SSYS bit in pr_flag should
 740  748         migrate to checking PR_ISSYS in the pstatus structure's pr_flags field.
 741  749  
 742  750  
 743  751         pr_pctcpu and pr_pctmem are 16-bit binary fractions in the range 0.0 to
 744  752         1.0 with the binary point to the right of the high-order bit (1.0 ==
 745  753         0x8000). pr_pctcpu is the summation over all lwps in the process.
 746  754  
 747  755  
      756 +       The pr_fname and pr_psargs are writable by the owner of the process. To
      757 +       write to them, the psinfo file should be open for writing and the
      758 +       desired value for the field should be written at the file offset that
      759 +       corresponds to the member of structure.  No other entry may be written
      760 +       to; if a write is attempted to an offset that does not represent one of
      761 +       these two memers, or if the size of the write is not exactly the size
      762 +       of the member being written, no bytes will be written and zero will be
      763 +       returned.
      764 +
      765 +
 748  766         pr_lwp contains the ps(1) information for the representative lwp.  If
 749  767         the process is a zombie, pr_nlwp, pr_nzomb, and pr_lwp.pr_lwpid are
 750  768         zero and the other fields of pr_lwp are undefined:
 751  769  
 752  770           typedef struct lwpsinfo {
 753  771               int pr_flag;             /* lwp flags (DEPRECATED: see below) */
 754  772               id_t pr_lwpid;           /* lwp id */
 755  773               uintptr_t pr_addr;       /* internal address of lwp */
 756  774               uintptr_t pr_wchan;      /* wait addr for sleeping lwp */
 757  775               char pr_stype;           /* synchronization event type */
 758  776               char pr_state;           /* numeric lwp state */
 759  777               char pr_sname;           /* printable character for pr_state */
 760  778               char pr_nice;            /* nice for cpu usage */
 761  779               short pr_syscall;        /* system call number (if in syscall) */
 762  780               char pr_oldpri;          /* pre-SVR4, low value is high priority */
 763  781               char pr_cpu;             /* pre-SVR4, cpu usage for scheduling */
 764  782               int pr_pri;              /* priority, high value = high priority */
 765  783               ushort_t pr_pctcpu;      /* % of recent cpu time used by this lwp */
 766  784               timestruc_t pr_start;    /* lwp start time, from the epoch */
 767  785               timestruc_t pr_time;     /* cpu time for this lwp */
 768  786               char pr_clname[PRCLSZ];  /* scheduling class name */
 769  787               char pr_name[PRFNSZ];    /* name of system lwp */
 770  788               processorid_t pr_onpro;  /* processor which last ran this lwp */
 771  789               processorid_t pr_bindpro;/* processor to which lwp is bound */
 772  790               psetid_t pr_bindpset;    /* processor set to which lwp is bound */
 773  791               lgrp_id_t pr_lgrp          /* home lgroup */
 774  792           } lwpsinfo_t;
 775  793  
 776  794  
 777  795  
 778  796         Some of the entries in lwpsinfo, such as pr_addr, pr_wchan, pr_stype,
 779  797         pr_state, and pr_name, refer to internal kernel data structures and
 780  798         should not be expected to retain their meanings across different
 781  799         versions of the operating system.
 782  800  
 783  801  
 784  802         lwpsinfo_t.pr_flag is a deprecated interface that should no longer be
 785  803         used.
 786  804  
 787  805  
 788  806         pr_pctcpu is a 16-bit binary fraction, as described above. It
 789  807         represents the CPU time used by the specific lwp. On a multi-processor
 790  808         machine, the maximum value is 1/N, where N is the number of CPUs.
 791  809  
 792  810  
 793  811         pr_contract is the id of the process contract of which the process is a
 794  812         member. See contract(4) and process(4).
 795  813  
 796  814     cred
 797  815         Contains a description of the credentials associated with the process:
 798  816  
 799  817           typedef struct prcred {
 800  818                uid_t pr_euid;      /* effective user id */
 801  819                uid_t pr_ruid;      /* real user id */
 802  820                uid_t pr_suid;      /* saved user id (from exec) */
 803  821                gid_t pr_egid;      /* effective group id */
 804  822                gid_t pr_rgid;      /* real group id */
 805  823                gid_t pr_sgid;      /* saved group id (from exec) */
 806  824                int pr_ngroups;     /* number of supplementary groups */
 807  825                gid_t pr_groups[1]; /* array of supplementary groups */
 808  826           } prcred_t;
 809  827  
 810  828  
 811  829  
 812  830  
 813  831         The array of associated supplementary groups in pr_groups is of
 814  832         variable length; the cred file contains all of the supplementary
 815  833         groups.  pr_ngroups indicates the number of supplementary groups. (See
 816  834         also the PCSCRED and PCSCREDX control operations.)
 817  835  
 818  836     priv
 819  837         Contains a description of the privileges associated with the process:
 820  838  
 821  839           typedef struct prpriv {
 822  840                uint32_t        pr_nsets;      /* number of privilege set */
 823  841                uint32_t        pr_setsize;    /* size of privilege set */
 824  842                uint32_t        pr_infosize;   /* size of supplementary data */
 825  843                priv_chunk_t    pr_sets[1];    /* array of sets */
 826  844           } prpriv_t;
 827  845  
 828  846  
 829  847  
 830  848         The actual dimension of the pr_sets[] field is
 831  849  
 832  850           pr_sets[pr_nsets][pr_setsize]
 833  851  
 834  852  
 835  853  
 836  854         which is followed by additional information about the process state
 837  855         pr_infosize bytes in size.
 838  856  
 839  857  
 840  858         The full size of the structure can be computed using
 841  859         PRIV_PRPRIV_SIZE(prpriv_t *).
 842  860  
 843  861     sigact
 844  862         Contains an array of sigaction structures describing the current
 845  863         dispositions of all signals associated with the traced process (see
  
    | 
      ↓ open down ↓ | 
    88 lines elided | 
    
      ↑ open up ↑ | 
  
 846  864         sigaction(2)). Signal numbers are displaced by 1 from array indices, so
 847  865         that the action for signal number n appears in position n-1 of the
 848  866         array.
 849  867  
 850  868     auxv
 851  869         Contains the initial values of the process's aux vector in an array of
 852  870         auxv_t structures (see <sys/auxv.h>). The values are those that were
 853  871         passed by the operating system as startup information to the dynamic
 854  872         linker.
 855  873  
      874 +   argv
      875 +       Contains the concatenation of each of the argument strings, including
      876 +       their NUL terminators, in the argument vector (argv) for the process.
      877 +       If the process has modified either its argument vector, or the contents
      878 +       of any of the strings referenced by that vector, those changes will be
      879 +       visible here.
      880 +
 856  881     ldt
 857  882         This file exists only on x86-based machines. It is non-empty only if
 858  883         the process has established a local descriptor table (LDT). If non-
 859  884         empty, the file contains the array of currently active LDT entries in
 860  885         an array of elements of type struct ssd, defined in <sys/sysi86.h>, one
 861  886         element for each active LDT entry.
 862  887  
 863  888     map, xmap
 864  889         Contain information about the virtual address map of the process. The
 865  890         map file contains an array of prmap structures while the xmap file
 866  891         contains an array of prxmap structures. Each structure describes a
 867  892         contiguous virtual address region in the address space of the traced
 868  893         process:
 869  894  
 870  895           typedef struct prmap {
 871  896                uintptr_tpr_vaddr;         /* virtual address of mapping */
 872  897                size_t pr_size;            /* size of mapping in bytes */
 873  898                char pr_mapname[PRMAPSZ];  /* name in /proc/pid/object */
 874  899                offset_t pr_offset;        /* offset into mapped object, if any */
 875  900                int pr_mflags;             /* protection and attribute flags */
 876  901                int pr_pagesize;           /* pagesize for this mapping in bytes */
 877  902                int pr_shmid;              /* SysV shared memory identifier */
 878  903           } prmap_t;
 879  904  
 880  905  
 881  906  
 882  907           typedef struct prxmap {
 883  908                uintptr_t pr_vaddr;        /* virtual address of mapping */
 884  909                size_t pr_size;            /* size of mapping in bytes */
 885  910                char pr_mapname[PRMAPSZ];  /* name in /proc/pid/object */
 886  911                offset_t pr_offset;        /* offset into mapped object, if any */
 887  912                int pr_mflags;             /* protection and attribute flags */
 888  913                int pr_pagesize;           /* pagesize for this mapping in bytes */
 889  914                int pr_shmid;              /* SysV shared memory identifier */
 890  915                dev_t pr_dev;              /* device of mapped object, if any */
 891  916                uint64_t pr_ino;           /* inode of mapped object, if any */
 892  917                size_t pr_rss;             /* pages of resident memory */
 893  918                size_t pr_anon;            /* pages of resident anonymous memory */
 894  919                size_t pr_locked;          /* pages of locked memory */
 895  920                uint64_t pr_hatpagesize;   /* pagesize of mapping */
 896  921           } prxmap_t;
 897  922  
 898  923  
 899  924  
 900  925  
 901  926         pr_vaddr is the virtual address of the mapping within the traced
 902  927         process and pr_size is its size in bytes. pr_mapname, if it does not
 903  928         contain a null string, contains the name of a file in the object
 904  929         directory (see below) that can be opened read-only to obtain a file
 905  930         descriptor for the mapped file associated with the mapping. This
 906  931         enables a debugger to find object file symbol tables without having to
 907  932         know the real path names of the executable file and shared libraries of
 908  933         the process. pr_offset is the 64-bit offset within the mapped file (if
 909  934         any) to which the virtual address is mapped.
 910  935  
 911  936  
 912  937         pr_mflags is a bit-mask of protection and attribute flags:
 913  938  
 914  939         MA_READ
 915  940                          mapping is readable by the traced process.
 916  941  
 917  942  
 918  943         MA_WRITE
 919  944                          mapping is writable by the traced process.
 920  945  
 921  946  
 922  947         MA_EXEC
 923  948                          mapping is executable by the traced process.
 924  949  
 925  950  
 926  951         MA_SHARED
 927  952                          mapping changes are shared by the mapped object.
 928  953  
 929  954  
 930  955         MA_ISM
 931  956                          mapping is intimate shared memory (shared MMU
 932  957                          resources)
 933  958  
 934  959  
 935  960         MAP_NORESERVE
 936  961                          mapping does not have swap space reserved (mapped with
 937  962                          MAP_NORESERVE)
 938  963  
 939  964  
 940  965         MA_SHM
 941  966                          mapping System V shared memory
 942  967  
 943  968  
 944  969  
 945  970         A contiguous area of the address space having the same underlying
 946  971         mapped object may appear as multiple mappings due to varying read,
 947  972         write, and execute attributes. The underlying mapped object does not
 948  973         change over the range of a single mapping. An I/O operation to a
 949  974         mapping marked MA_SHARED fails if applied at a virtual address not
 950  975         corresponding to a valid page in the underlying mapped object. A write
 951  976         to a MA_SHARED mapping that is not marked MA_WRITE fails. Reads and
 952  977         writes to private mappings always succeed. Reads and writes to unmapped
 953  978         addresses fail.
 954  979  
 955  980  
 956  981         pr_pagesize is the page size for the mapping, currently always the
 957  982         system pagesize.
 958  983  
 959  984  
 960  985         pr_shmid is the shared memory identifier, if any, for the mapping. Its
 961  986         value is -1 if the mapping is not System V shared memory. See
 962  987         shmget(2).
 963  988  
 964  989  
 965  990         pr_dev is the device of the mapped object, if any, for the mapping. Its
 966  991         value is PRNODEV (-1) if the mapping does not have a device.
 967  992  
 968  993  
 969  994         pr_ino is the inode of the mapped object, if any, for the mapping. Its
 970  995         contents are only valid if pr_dev is not PRNODEV.
 971  996  
 972  997  
 973  998         pr_rss is the number of resident pages of memory for the mapping. The
 974  999         number of resident bytes for the mapping may be determined by
 975 1000         multiplying pr_rss by the page size given by pr_pagesize.
 976 1001  
 977 1002  
 978 1003         pr_anon is the number of resident anonymous memory pages (pages which
 979 1004         are private to this process) for the mapping.
 980 1005  
 981 1006  
 982 1007         pr_locked is the number of locked pages for the mapping. Pages which
 983 1008         are locked are always resident in memory.
 984 1009  
 985 1010  
 986 1011         pr_hatpagesize is the size, in bytes, of the HAT (MMU) translation for
 987 1012         the mapping. pr_hatpagesize may be different than pr_pagesize. The
 988 1013         possible values are hardware architecture specific, and may change over
 989 1014         a mapping's lifetime.
 990 1015  
 991 1016     rmap
 992 1017         Contains information about the reserved address ranges of the process.
 993 1018         The file contains an array of prmap structures, as defined above for
 994 1019         the map file. Each structure describes a contiguous virtual address
 995 1020         region in the address space of the traced process that is reserved by
 996 1021         the system in the sense that an mmap(2) system call that does not
 997 1022         specify MAP_FIXED will not use any part of it for the new mapping.
 998 1023         Examples of such reservations include the address ranges reserved for
 999 1024         the process stack and the individual thread stacks of a multi-threaded
1000 1025         process.
1001 1026  
1002 1027     cwd
1003 1028         A symbolic link to the process's current working directory. See
1004 1029         chdir(2).  A readlink(2) of /proc/pid/cwd yields a null string.
1005 1030         However, it can be opened, listed, and searched as a directory, and can
1006 1031         be the target of chdir(2).
1007 1032  
1008 1033     root
1009 1034         A symbolic link to the process's root directory.  /proc/pid/root can
1010 1035         differ from the system root directory if the process or one of its
1011 1036         ancestors executed chroot(2) as super user. It has the same semantics
1012 1037         as /proc/pid/cwd.
1013 1038  
1014 1039     fd
1015 1040         A directory containing references to the open files of the process.
1016 1041         Each entry is a decimal number corresponding to an open file descriptor
1017 1042         in the process.
1018 1043  
1019 1044  
1020 1045         If an entry refers to a regular file, it can be opened with normal file
1021 1046         system semantics but, to ensure that the controlling process cannot
1022 1047         gain greater access than the controlled process, with no file access
1023 1048         modes other than its read/write open modes in the controlled process.
1024 1049         If an entry refers to a directory, it can be accessed with the same
1025 1050         semantics as /proc/pid/cwd. An attempt to open any other type of entry
1026 1051         fails with EACCES.
1027 1052  
1028 1053     object
1029 1054         A directory containing read-only files with names corresponding to the
1030 1055         pr_mapname entries in the map and pagedata files. Opening such a file
1031 1056         yields a file descriptor for the underlying mapped file associated with
1032 1057         an address-space mapping in the process. The file name a.out appears in
1033 1058         the directory as an alias for the process's executable file.
1034 1059  
1035 1060  
1036 1061         The object directory makes it possible for a controlling process to
1037 1062         gain access to the object file and any shared libraries (and
1038 1063         consequently the symbol tables) without having to know the actual path
1039 1064         names of the executable files.
1040 1065  
1041 1066     path
1042 1067         A directory containing symbolic links to files opened by the process.
1043 1068         The directory includes one entry for cwd and root. The directory also
1044 1069         contains a numerical entry for each file descriptor in the fd
1045 1070         directory, and entries matching those in the object directory. If this
1046 1071         information is not available, any attempt to read the contents of the
1047 1072         symbolic link will fail. This is most common for files that do not
1048 1073         exist in the filesystem namespace (such as FIFOs and sockets), but can
1049 1074         also happen for regular files. For the file descriptor entries, the
1050 1075         path may be different from the one used by the process to open the
1051 1076         file.
1052 1077  
1053 1078     pagedata
1054 1079         Opening the page data file enables tracking of address space references
1055 1080         and modifications on a per-page basis.
1056 1081  
1057 1082  
1058 1083         A read(2) of the page data file descriptor returns structured page data
1059 1084         and atomically clears the page data maintained for the file by the
1060 1085         system. That is to say, each read returns data collected since the last
1061 1086         read; the first read returns data collected since the file was opened.
1062 1087         When the call completes, the read buffer contains the following
1063 1088         structure as its header and thereafter contains a number of section
1064 1089         header structures and associated byte arrays that must be accessed by
1065 1090         walking linearly through the buffer.
1066 1091  
1067 1092           typedef struct prpageheader {
1068 1093               timestruc_t pr_tstamp; /* real time stamp, time of read() */
1069 1094               ulong_t pr_nmap;       /* number of address space mappings */
1070 1095               ulong_t pr_npage;      /* total number of pages */
1071 1096           } prpageheader_t;
1072 1097  
1073 1098  
1074 1099  
1075 1100         The header is followed by pr_nmap prasmap structures and associated
1076 1101         data arrays. The prasmap structure contains the following elements:
1077 1102  
1078 1103           typedef struct prasmap {
1079 1104               uintptr_t pr_vaddr;        /* virtual address of mapping */
1080 1105               ulong_t pr_npage;          /* number of pages in mapping */
1081 1106               char pr_mapname[PRMAPSZ];  /* name in /proc/pid/object */
1082 1107               offset_t pr_offset;        /* offset into mapped object, if any */
1083 1108               int pr_mflags;             /* protection and attribute flags */
1084 1109               int pr_pagesize;           /* pagesize for this mapping in bytes */
1085 1110               int pr_shmid;              /* SysV shared memory identifier */
1086 1111           } prasmap_t;
1087 1112  
1088 1113  
1089 1114  
1090 1115         Each section header is followed by pr_npage bytes, one byte for each
1091 1116         page in the mapping, plus 0-7 null bytes at the end so that the next
1092 1117         prasmap structure begins on an eight-byte aligned boundary. Each data
1093 1118         byte may contain these flags:
1094 1119  
1095 1120         PG_REFERENCED
1096 1121                          page has been referenced.
1097 1122  
1098 1123  
1099 1124         PG_MODIFIED
1100 1125                          page has been modified.
1101 1126  
1102 1127  
1103 1128  
1104 1129         If the read buffer is not large enough to contain all of the page data,
1105 1130         the read fails with E2BIG and the page data is not cleared. The
1106 1131         required size of the read buffer can be determined through fstat(2).
1107 1132         Application of lseek(2) to the page data file descriptor is
1108 1133         ineffective; every read starts from the beginning of the file. Closing
1109 1134         the page data file descriptor terminates the system overhead associated
1110 1135         with collecting the data.
1111 1136  
1112 1137  
1113 1138         More than one page data file descriptor for the same process can be
1114 1139         opened, up to a system-imposed limit per traced process. A read of one
1115 1140         does not affect the data being collected by the system for the others.
1116 1141         An open of the page data file will fail with ENOMEM if the system-
1117 1142         imposed limit would be exceeded.
1118 1143  
1119 1144     watch
1120 1145         Contains an array of prwatch structures, one for each watched area
1121 1146         established by the PCWATCH control operation. See PCWATCH for details.
1122 1147  
1123 1148     usage
1124 1149         Contains process usage information described by a prusage structure
1125 1150         which contains at least the following fields:
1126 1151  
1127 1152           typedef struct prusage {
1128 1153               id_t pr_lwpid;           /* lwp id.  0: process or defunct */
1129 1154               int pr_count;            /* number of contributing lwps */
1130 1155               timestruc_t pr_tstamp;   /* real time stamp, time of read() */
1131 1156               timestruc_t pr_create;   /* process/lwp creation time stamp */
1132 1157               timestruc_t pr_term;     /* process/lwp termination time stamp */
1133 1158               timestruc_t pr_rtime;    /* total lwp real (elapsed) time */
1134 1159               timestruc_t pr_utime;    /* user level CPU time */
1135 1160               timestruc_t pr_stime;    /* system call CPU time */
1136 1161               timestruc_t pr_ttime;    /* other system trap CPU time */
1137 1162               timestruc_t pr_tftime;   /* text page fault sleep time */
1138 1163               timestruc_t pr_dftime;   /* data page fault sleep time */
1139 1164               timestruc_t pr_kftime;   /* kernel page fault sleep time */
1140 1165               timestruc_t pr_ltime;    /* user lock wait sleep time */
1141 1166               timestruc_t pr_slptime;  /* all other sleep time */
1142 1167               timestruc_t pr_wtime;    /* wait-cpu (latency) time */
1143 1168               timestruc_t pr_stoptime; /* stopped time */
1144 1169               ulong_t pr_minf;         /* minor page faults */
1145 1170               ulong_t pr_majf;         /* major page faults */
1146 1171               ulong_t pr_nswap;        /* swaps */
1147 1172               ulong_t pr_inblk;        /* input blocks */
1148 1173               ulong_t pr_oublk;        /* output blocks */
1149 1174               ulong_t pr_msnd;         /* messages sent */
1150 1175               ulong_t pr_mrcv;         /* messages received */
1151 1176               ulong_t pr_sigs;         /* signals received */
1152 1177               ulong_t pr_vctx;         /* voluntary context switches */
1153 1178               ulong_t pr_ictx;         /* involuntary context switches */
1154 1179               ulong_t pr_sysc;         /* system calls */
1155 1180               ulong_t pr_ioch;         /* chars read and written */
1156 1181           } prusage_t;
1157 1182  
1158 1183  
1159 1184  
1160 1185         Microstate accounting is now continuously enabled. While this
1161 1186         information was previously an estimate, if microstate accounting were
1162 1187         not enabled, the current information is now never an estimate
1163 1188         represents time the process has spent in various states.
1164 1189  
1165 1190     lstatus
1166 1191         Contains a prheader structure followed by an array of lwpstatus
1167 1192         structures, one for each active lwp in the process (see also
1168 1193         /proc/pid/lwp/lwpid/lwpstatus, below). The prheader structure describes
1169 1194         the number and size of the array entries that follow.
1170 1195  
1171 1196           typedef struct prheader {
1172 1197               long pr_nent;        /* number of entries */
1173 1198               size_t pr_entsize;   /* size of each entry, in bytes */
1174 1199           } prheader_t;
1175 1200  
1176 1201  
1177 1202  
1178 1203         The lwpstatus structure may grow by the addition of elements at the end
1179 1204         in future releases of the system. Programs must use pr_entsize in the
1180 1205         file header to index through the array. These comments apply to all
1181 1206         /proc files that include a prheader structure (lpsinfo and lusage,
1182 1207         below).
1183 1208  
1184 1209     lpsinfo
1185 1210         Contains a prheader structure followed by an array of lwpsinfo
1186 1211         structures, one for eachactive and zombie lwp in the process. See also
1187 1212         /proc/pid/lwp/lwpid/lwpsinfo, below.
1188 1213  
1189 1214     lusage
1190 1215         Contains a prheader structure followed by an array of prusage
1191 1216         structures, one for each active lwp in the process, plus an additional
1192 1217         element at the beginning that contains the summation over all defunct
1193 1218         lwps (lwps that once existed but no longer exist in the process).
1194 1219         Excluding the pr_lwpid, pr_tstamp, pr_create, and pr_term entries, the
1195 1220         entry-by-entry summation over all these structures is the definition of
1196 1221         the process usage information obtained from the usage file. (See also
1197 1222         /proc/pid/lwp/lwpid/lwpusage, below.)
1198 1223  
1199 1224     lwp
1200 1225         A directory containing entries each of which names an active or zombie
1201 1226         lwp within the process. These entries are themselves directories
1202 1227         containing additional files as described below. Only the lwpsinfo file
1203 1228         exists in the directory of a zombie lwp.
1204 1229  
1205 1230  STRUCTURE OF /proc/pid/lwp/lwpid
1206 1231         A given directory /proc/pid/lwp/lwpid contains the following entries:
1207 1232  
1208 1233     lwpctl
1209 1234         Write-only control file. The messages written to this file affect the
1210 1235         specific lwp rather than the representative lwp, as is the case for the
1211 1236         process's ctl file.
1212 1237  
1213 1238     lwpstatus
1214 1239         lwp-specific state information. This file contains the lwpstatus
1215 1240         structure for the specific lwp as described above for the
1216 1241         representative lwp in the process's status file.
1217 1242  
1218 1243     lwpsinfo
1219 1244         lwp-specific ps(1) information. This file contains the lwpsinfo
1220 1245         structure for the specific lwp as described above for the
1221 1246         representative lwp in the process's psinfo file. The lwpsinfo file
1222 1247         remains accessible after an lwp becomes a zombie.
1223 1248  
1224 1249     lwpusage
1225 1250         This file contains the prusage structure for the specific lwp as
1226 1251         described above for the process's usage file.
1227 1252  
1228 1253     gwindows
1229 1254         This file exists only on SPARC based machines. If it is non-empty, it
1230 1255         contains a gwindows_t structure, defined in <sys/regset.h>, with the
1231 1256         values of those SPARC register windows that could not be stored on the
1232 1257         stack when the lwp stopped. Conditions under which register windows are
1233 1258         not stored on the stack are: the stack pointer refers to nonexistent
1234 1259         process memory or the stack pointer is improperly aligned. If the lwp
1235 1260         is not stopped or if there are no register windows that could not be
1236 1261         stored on the stack, the file is empty (the usual case).
1237 1262  
1238 1263     xregs
1239 1264         Extra state registers. The extra state register set is architecture
1240 1265         dependent; this file is empty if the system does not support extra
1241 1266         state registers. If the file is non-empty, it contains an architecture
1242 1267         dependent structure of type prxregset_t, defined in <procfs.h>, with
1243 1268         the values of the lwp's extra state registers. If the lwp is not
1244 1269         stopped, all register values are undefined. See also the PCSXREG
1245 1270         control operation, below.
1246 1271  
1247 1272     asrs
1248 1273         This file exists only for 64-bit SPARC V9 processes. It contains an
1249 1274         asrset_t structure, defined in <sys/regset.h>, containing the values of
1250 1275         the lwp's platform-dependent ancillary state registers. If the lwp is
1251 1276         not stopped, all register values are undefined. See also the PCSASRS
1252 1277         control operation, below.
1253 1278  
1254 1279     spymaster
1255 1280         For an agent lwp (see PCAGENT), this file contains a psinfo_t structure
1256 1281         that corresponds to the process that created the agent lwp at the time
1257 1282         the agent was created. This structure is identical to that retrieved
1258 1283         via the psinfo file, with one modification: the pr_time field does not
1259 1284         correspond to the CPU time for the process, but rather to the creation
1260 1285         time of the agent lwp.
1261 1286  
1262 1287     templates
1263 1288         A directory which contains references to the active templates for the
1264 1289         lwp, named by the contract type. Changes made to an active template
1265 1290         descriptor do not affect the original template which was activated,
1266 1291         though they do affect the active template. It is not possible to
1267 1292         activate an active template descriptor.  See contract(4).
1268 1293  
1269 1294  CONTROL MESSAGES
1270 1295         Process state changes are effected through messages written to a
1271 1296         process's ctl file or to an individual lwp's lwpctl file. All control
1272 1297         messages consist of a long that names the specific operation followed
1273 1298         by additional data containing the operand, if any.
1274 1299  
1275 1300  
1276 1301         Multiple control messages may be combined in a single write(2) (or
1277 1302         writev(2)) to a control file, but no partial writes are permitted. That
1278 1303         is, each control message, operation code plus operand, if any, must be
1279 1304         presented in its entirety to the write(2) and not in pieces over
1280 1305         several system calls. If a control operation fails, no subsequent
1281 1306         operations contained in the same write(2) are attempted.
1282 1307  
1283 1308  
1284 1309         Descriptions of the allowable control messages follow. In all cases,
1285 1310         writing a message to a control file for a process or lwp that has
1286 1311         terminated elicits the error ENOENT.
1287 1312  
1288 1313     PCSTOP PCDSTOP PCWSTOP PCTWSTOP
1289 1314         When applied to the process control file, PCSTOP directs all lwps to
1290 1315         stop and waits for them to stop, PCDSTOP directs all lwps to stop
1291 1316         without waiting for them to stop, and PCWSTOP simply waits for all lwps
1292 1317         to stop.  When applied to an lwp control file, PCSTOP directs the
1293 1318         specific lwp to stop and waits until it has stopped, PCDSTOP directs
1294 1319         the specific lwp to stop without waiting for it to stop, and PCWSTOP
1295 1320         simply waits for the specific lwp to stop. When applied to an lwp
1296 1321         control file, PCSTOP and PCWSTOP complete when the lwp stops on an
1297 1322         event of interest, immediately if already so stopped; when applied to
1298 1323         the process control file, they complete when every lwp has stopped
1299 1324         either on an event of interest or on a PR_SUSPENDED stop.
1300 1325  
1301 1326  
1302 1327         PCTWSTOP is identical to PCWSTOP except that it enables the operation
1303 1328         to time out, to avoid waiting forever for a process or lwp that may
1304 1329         never stop on an event of interest. PCTWSTOP takes a long operand
1305 1330         specifying a number of milliseconds; the wait will terminate
1306 1331         successfully after the specified number of milliseconds even if the
1307 1332         process or lwp has not stopped; a timeout value of zero makes the
1308 1333         operation identical to PCWSTOP.
1309 1334  
1310 1335  
1311 1336         An ``event of interest'' is either a PR_REQUESTED stop or a stop that
1312 1337         has been specified in the process's tracing flags (set by PCSTRACE,
1313 1338         PCSFAULT, PCSENTRY, and PCSEXIT). PR_JOBCONTROL and PR_SUSPENDED stops
1314 1339         are specifically not events of interest. (An lwp may stop twice due to
1315 1340         a stop signal, first showing PR_SIGNALLED if the signal is traced and
1316 1341         again showing PR_JOBCONTROL if the lwp is set running without clearing
1317 1342         the signal.) If PCSTOP or PCDSTOP is applied to an lwp that is stopped,
1318 1343         but not on an event of interest, the stop directive takes effect when
1319 1344         the lwp is restarted by the competing mechanism. At that time, the lwp
1320 1345         enters a PR_REQUESTED stop before executing any user-level code.
1321 1346  
1322 1347  
1323 1348         A write of a control message that blocks is interruptible by a signal
1324 1349         so that, for example, an alarm(2) can be set to avoid waiting forever
1325 1350         for a process or lwp that may never stop on an event of interest. If
1326 1351         PCSTOP is interrupted, the lwp stop directives remain in effect even
1327 1352         though the write(2) returns an error. (Use of PCTWSTOP with a non-zero
1328 1353         timeout is recommended over PCWSTOP with an alarm(2).)
1329 1354  
1330 1355  
1331 1356         A system process (indicated by the PR_ISSYS flag) never executes at
1332 1357         user level, has no user-level address space visible through /proc, and
1333 1358         cannot be stopped. Applying one of these operations to a system process
1334 1359         or any of its lwps elicits the error EBUSY.
1335 1360  
1336 1361     PCRUN
1337 1362         Make an lwp runnable again after a stop. This operation takes a long
1338 1363         operand containing zero or more of the following flags:
1339 1364  
1340 1365         PRCSIG
1341 1366                     clears the current signal, if any (see PCCSIG).
1342 1367  
1343 1368  
1344 1369         PRCFAULT
1345 1370                     clears the current fault, if any (see PCCFAULT).
1346 1371  
1347 1372  
1348 1373         PRSTEP
1349 1374                     directs the lwp to execute a single machine instruction. On
1350 1375                     completion of the instruction, a trace trap occurs. If
1351 1376                     FLTTRACE is being traced, the lwp stops; otherwise, it is
1352 1377                     sent SIGTRAP. If SIGTRAP is being traced and is not
1353 1378                     blocked, the lwp stops. When the lwp stops on an event of
1354 1379                     interest, the single-step directive is cancelled, even if
1355 1380                     the stop occurs before the instruction is executed. This
1356 1381                     operation requires hardware and operating system support
1357 1382                     and may not be implemented on all processors. It is
1358 1383                     implemented on SPARC and x86-based machines.
1359 1384  
1360 1385  
1361 1386         PRSABORT
1362 1387                     is meaningful only if the lwp is in a PR_SYSENTRY stop or
1363 1388                     is marked PR_ASLEEP; it instructs the lwp to abort
1364 1389                     execution of the system call (see PCSENTRY and PCSEXIT).
1365 1390  
1366 1391  
1367 1392         PRSTOP
1368 1393                     directs the lwp to stop again as soon as possible after
1369 1394                     resuming execution (see PCDSTOP). In particular, if the lwp
1370 1395                     is stopped on PR_SIGNALLED or PR_FAULTED, the next stop
1371 1396                     will show PR_REQUESTED, no other stop will have intervened,
1372 1397                     and the lwp will not have executed any user-level code.
1373 1398  
1374 1399  
1375 1400  
1376 1401         When applied to an lwp control file, PCRUN clears any outstanding
1377 1402         directed-stop request and makes the specific lwp runnable. The
1378 1403         operation fails with EBUSY if the specific lwp is not stopped on an
1379 1404         event of interest or has not been directed to stop or if the agent lwp
1380 1405         exists and this is not the agent lwp (see PCAGENT).
1381 1406  
1382 1407  
1383 1408         When applied to the process control file, a representative lwp is
1384 1409         chosen for the operation as described for /proc/pid/status. The
1385 1410         operation fails with EBUSY if the representative lwp is not stopped on
1386 1411         an event of interest or has not been directed to stop or if the agent
1387 1412         lwp exists.  If PRSTEP or PRSTOP was requested, the representative lwp
1388 1413         is made runnable and its outstanding directed-stop request is cleared;
1389 1414         otherwise all outstanding directed-stop requests are cleared and, if it
1390 1415         was stopped on an event of interest, the representative lwp is marked
1391 1416         PR_REQUESTED. If, as a consequence, all lwps are in the PR_REQUESTED or
1392 1417         PR_SUSPENDED stop state, all lwps showing PR_REQUESTED are made
1393 1418         runnable.
1394 1419  
1395 1420     PCSTRACE
1396 1421         Define a set of signals to be traced in the process. The receipt of one
1397 1422         of these signals by an lwp causes the lwp to stop. The set of signals
1398 1423         is defined using an operand sigset_t contained in the control message.
1399 1424         Receipt of SIGKILL cannot be traced; if specified, it is silently
1400 1425         ignored.
1401 1426  
1402 1427  
1403 1428         If a signal that is included in an lwp's held signal set (the signal
1404 1429         mask) is sent to the lwp, the signal is not received and does not cause
1405 1430         a stop until it is removed from the held signal set, either by the lwp
1406 1431         itself or by setting the held signal set with PCSHOLD.
1407 1432  
1408 1433     PCCSIG
1409 1434         The current signal, if any, is cleared from the specific or
1410 1435         representative lwp.
1411 1436  
1412 1437     PCSSIG
1413 1438         The current signal and its associated signal information for the
1414 1439         specific or representative lwp are set according to the contents of the
1415 1440         operand siginfo structure (see <sys/siginfo.h>). If the specified
1416 1441         signal number is zero, the current signal is cleared. The semantics of
1417 1442         this operation are different from those of kill(2) in that the signal
1418 1443         is delivered to the lwp immediately after execution is resumed (even if
1419 1444         it is being blocked) and an additional PR_SIGNALLED stop does not
1420 1445         intervene even if the signal is traced. Setting the current signal to
1421 1446         SIGKILL terminates the process immediately.
1422 1447  
1423 1448     PCKILL
1424 1449         If applied to the process control file, a signal is sent to the process
1425 1450         with semantics identical to those of kill(2). If applied to an lwp
1426 1451         control file, a directed signal is sent to the specific lwp. The signal
1427 1452         is named in a long operand contained in the message. Sending SIGKILL
1428 1453         terminates the process immediately.
1429 1454  
1430 1455     PCUNKILL
1431 1456         A signal is deleted, that is, it is removed from the set of pending
1432 1457         signals. If applied to the process control file, the signal is deleted
1433 1458         from the process's pending signals. If applied to an lwp control file,
1434 1459         the signal is deleted from the lwp's pending signals. The current
1435 1460         signal (if any) is unaffected. The signal is named in a long operand in
1436 1461         the control message. It is an error (EINVAL) to attempt to delete
1437 1462         SIGKILL.
1438 1463  
1439 1464     PCSHOLD
1440 1465         Set the set of held signals for the specific or representative lwp
1441 1466         (signals whose delivery will be blocked if sent to the lwp). The set of
1442 1467         signals is specified with a sigset_t operand. SIGKILL and SIGSTOP
1443 1468         cannot be held; if specified, they are silently ignored.
1444 1469  
1445 1470     PCSFAULT
1446 1471         Define a set of hardware faults to be traced in the process. On
1447 1472         incurring one of these faults, an lwp stops. The set is defined via the
1448 1473         operand fltset_t structure. Fault names are defined in <sys/fault.h>
1449 1474         and include the following. Some of these may not occur on all
1450 1475         processors; there may be processor-specific faults in addition to
1451 1476         these.
1452 1477  
1453 1478         FLTILL
1454 1479                      illegal instruction
1455 1480  
1456 1481  
1457 1482         FLTPRIV
1458 1483                      privileged instruction
1459 1484  
1460 1485  
1461 1486         FLTBPT
1462 1487                      breakpoint trap
1463 1488  
1464 1489  
1465 1490         FLTTRACE
1466 1491                      trace trap (single-step)
1467 1492  
1468 1493  
1469 1494         FLTWATCH
1470 1495                      watchpoint trap
1471 1496  
1472 1497  
1473 1498         FLTACCESS
1474 1499                      memory access fault (bus error)
1475 1500  
1476 1501  
1477 1502         FLTBOUNDS
1478 1503                      memory bounds violation
1479 1504  
1480 1505  
1481 1506         FLTIOVF
1482 1507                      integer overflow
1483 1508  
1484 1509  
1485 1510         FLTIZDIV
1486 1511                      integer zero divide
1487 1512  
1488 1513  
1489 1514         FLTFPE
1490 1515                      floating-point exception
1491 1516  
1492 1517  
1493 1518         FLTSTACK
1494 1519                      unrecoverable stack fault
1495 1520  
1496 1521  
1497 1522         FLTPAGE
1498 1523                      recoverable page fault
1499 1524  
1500 1525  
1501 1526  
1502 1527         When not traced, a fault normally results in the posting of a signal to
1503 1528         the lwp that incurred the fault. If an lwp stops on a fault, the signal
1504 1529         is posted to the lwp when execution is resumed unless the fault is
1505 1530         cleared by PCCFAULT or by the PRCFAULT option of PCRUN. FLTPAGE is an
1506 1531         exception; no signal is posted. The pr_info field in the lwpstatus
1507 1532         structure identifies the signal to be sent and contains machine-
1508 1533         specific information about the fault.
1509 1534  
1510 1535     PCCFAULT
1511 1536         The current fault, if any, is cleared; the associated signal will not
1512 1537         be sent to the specific or representative lwp.
1513 1538  
1514 1539     PCSENTRY PCSEXIT
1515 1540         These control operations instruct the process's lwps to stop on entry
1516 1541         to or exit from specified system calls. The set of system calls to be
1517 1542         traced is defined via an operand sysset_t structure.
1518 1543  
1519 1544  
1520 1545         When entry to a system call is being traced, an lwp stops after having
1521 1546         begun the call to the system but before the system call arguments have
1522 1547         been fetched from the lwp. When exit from a system call is being
1523 1548         traced, an lwp stops on completion of the system call just prior to
1524 1549         checking for signals and returning to user level. At this point, all
1525 1550         return values have been stored into the lwp's registers.
1526 1551  
1527 1552  
1528 1553         If an lwp is stopped on entry to a system call (PR_SYSENTRY) or when
1529 1554         sleeping in an interruptible system call (PR_ASLEEP is set), it may be
1530 1555         instructed to go directly to system call exit by specifying the
1531 1556         PRSABORT flag in a PCRUN control message. Unless exit from the system
1532 1557         call is being traced, the lwp returns to user level showing EINTR.
1533 1558  
1534 1559     PCWATCH
1535 1560         Set or clear a watched area in the controlled process from a prwatch
1536 1561         structure operand:
1537 1562  
1538 1563           typedef struct prwatch {
1539 1564               uintptr_t pr_vaddr;  /* virtual address of watched area */
1540 1565               size_t pr_size;      /* size of watched area in bytes */
1541 1566               int pr_wflags;       /* watch type flags */
1542 1567           } prwatch_t;
1543 1568  
1544 1569  
1545 1570  
1546 1571         pr_vaddr specifies the virtual address of an area of memory to be
1547 1572         watched in the controlled process. pr_size specifies the size of the
1548 1573         area, in bytes. pr_wflags specifies the type of memory access to be
1549 1574         monitored as a bit-mask of the following flags:
1550 1575  
1551 1576         WA_READ
1552 1577                         read access
1553 1578  
1554 1579  
1555 1580         WA_WRITE
1556 1581                         write access
1557 1582  
1558 1583  
1559 1584         WA_EXEC
1560 1585                         execution access
1561 1586  
1562 1587  
1563 1588         WA_TRAPAFTER
1564 1589                         trap after the instruction completes
1565 1590  
1566 1591  
1567 1592  
1568 1593         If pr_wflags is non-empty, a watched area is established for the
1569 1594         virtual address range specified by pr_vaddr and pr_size. If pr_wflags
1570 1595         is empty, any previously-established watched area starting at the
1571 1596         specified virtual address is cleared; pr_size is ignored.
1572 1597  
1573 1598  
1574 1599         A watchpoint is triggered when an lwp in the traced process makes a
1575 1600         memory reference that covers at least one byte of a watched area and
1576 1601         the memory reference is as specified in pr_wflags. When an lwp triggers
1577 1602         a watchpoint, it incurs a watchpoint trap. If FLTWATCH is being traced,
1578 1603         the lwp stops; otherwise, it is sent a SIGTRAP signal; if SIGTRAP is
1579 1604         being traced and is not blocked, the lwp stops.
1580 1605  
1581 1606  
1582 1607         The watchpoint trap occurs before the instruction completes unless
1583 1608         WA_TRAPAFTER was specified, in which case it occurs after the
1584 1609         instruction completes. If it occurs before completion, the memory is
1585 1610         not modified. If it occurs after completion, the memory is modified (if
1586 1611         the access is a write access).
1587 1612  
1588 1613  
1589 1614         Physical i/o is an exception for watchpoint traps. In this instance,
1590 1615         there is no guarantee that memory before the watched area has already
1591 1616         been modified (or in the case of WA_TRAPAFTER, that the memory
1592 1617         following the watched area has not been modified) when the watchpoint
1593 1618         trap occurs and the lwp stops.
1594 1619  
1595 1620  
1596 1621         pr_info in the lwpstatus structure contains information pertinent to
1597 1622         the watchpoint trap. In particular, the si_addr field contains the
1598 1623         virtual address of the memory reference that triggered the watchpoint,
1599 1624         and the si_code field contains one of TRAP_RWATCH, TRAP_WWATCH, or
1600 1625         TRAP_XWATCH, indicating read, write, or execute access, respectively.
1601 1626         The si_trapafter field is zero unless WA_TRAPAFTER is in effect for
1602 1627         this watched area; non-zero indicates that the current instruction is
1603 1628         not the instruction that incurred the watchpoint trap. The si_pc field
1604 1629         contains the virtual address of the instruction that incurred the trap.
1605 1630  
1606 1631  
1607 1632         A watchpoint trap may be triggered while executing a system call that
1608 1633         makes reference to the traced process's memory. The lwp that is
1609 1634         executing the system call incurs the watchpoint trap while still in the
1610 1635         system call. If it stops as a result, the lwpstatus structure contains
1611 1636         the system call number and its arguments. If the lwp does not stop, or
1612 1637         if it is set running again without clearing the signal or fault, the
1613 1638         system call fails with EFAULT. If WA_TRAPAFTER was specified, the
1614 1639         memory reference will have completed and the memory will have been
1615 1640         modified (if the access was a write access) when the watchpoint trap
1616 1641         occurs.
1617 1642  
1618 1643  
1619 1644         If more than one of WA_READ, WA_WRITE, and WA_EXEC is specified for a
1620 1645         watched area, and a single instruction incurs more than one of the
1621 1646         specified types, only one is reported when the watchpoint trap occurs.
1622 1647         The precedence is WA_EXEC, WA_READ, WA_WRITE (WA_EXEC and WA_READ take
1623 1648         precedence over WA_WRITE), unless WA_TRAPAFTER was specified, in which
1624 1649         case it is WA_WRITE, WA_READ, WA_EXEC (WA_WRITE takes precedence).
1625 1650  
1626 1651  
1627 1652         PCWATCH fails with EINVAL if an attempt is made to specify overlapping
1628 1653         watched areas or if pr_wflags contains flags other than those specified
1629 1654         above. It fails with ENOMEM if an attempt is made to establish more
1630 1655         watched areas than the system can support (the system can support
1631 1656         thousands).
1632 1657  
1633 1658  
1634 1659         The child of a vfork(2) borrows the parent's address space. When a
1635 1660         vfork(2) is executed by a traced process, all watched areas established
1636 1661         for the parent are suspended until the child terminates or performs an
1637 1662         exec(2). Any watched areas established independently in the child are
1638 1663         cancelled when the parent resumes after the child's termination or
1639 1664         exec(2). PCWATCH fails with EBUSY if applied to the parent of a
1640 1665         vfork(2) before the child has terminated or performed an exec(2).  The
1641 1666         PR_VFORKP flag is set in the pstatus structure for such a parent
1642 1667         process.
1643 1668  
1644 1669  
1645 1670         Certain accesses of the traced process's address space by the operating
1646 1671         system are immune to watchpoints. The initial construction of a signal
1647 1672         stack frame when a signal is delivered to an lwp will not trigger a
1648 1673         watchpoint trap even if the new frame covers watched areas of the
1649 1674         stack. Once the signal handler is entered, watchpoint traps occur
1650 1675         normally. On SPARC based machines, register window overflow and
1651 1676         underflow will not trigger watchpoint traps, even if the register
1652 1677         window save areas cover watched areas of the stack.
1653 1678  
1654 1679  
1655 1680         Watched areas are not inherited by child processes, even if the traced
1656 1681         process's inherit-on-fork mode, PR_FORK, is set (see PCSET, below).
1657 1682         All watched areas are cancelled when the traced process performs a
1658 1683         successful exec(2).
1659 1684  
1660 1685     PCSET PCUNSET
1661 1686         PCSET sets one or more modes of operation for the traced process.
1662 1687         PCUNSET unsets these modes. The modes to be set or unset are specified
1663 1688         by flags in an operand long in the control message:
1664 1689  
1665 1690         PR_FORK
1666 1691                      (inherit-on-fork): When set, the process's tracing flags
1667 1692                      and its inherit-on-fork mode are inherited by the child of
1668 1693                      a fork(2), fork1(2), or vfork(2). When unset, child
1669 1694                      processes start with all tracing flags cleared.
1670 1695  
1671 1696  
1672 1697         PR_RLC
1673 1698                      (run-on-last-close): When set and the last writable /proc
1674 1699                      file descriptor referring to the traced process or any of
1675 1700                      its lwps is closed, all of the process's tracing flags and
1676 1701                      watched areas are cleared, any outstanding stop directives
1677 1702                      are canceled, and if any lwps are stopped on events of
1678 1703                      interest, they are set running as though PCRUN had been
1679 1704                      applied to them. When unset, the process's tracing flags
1680 1705                      and watched areas are retained and lwps are not set
1681 1706                      running on last close.
1682 1707  
1683 1708  
1684 1709         PR_KLC
1685 1710                      (kill-on-last-close): When set and the last writable /proc
1686 1711                      file descriptor referring to the traced process or any of
1687 1712                      its lwps is closed, the process is terminated with
1688 1713                      SIGKILL.
1689 1714  
1690 1715  
1691 1716         PR_ASYNC
1692 1717                      (asynchronous-stop): When set, a stop on an event of
1693 1718                      interest by one lwp does not directly affect any other lwp
1694 1719                      in the process. When unset and an lwp stops on an event of
1695 1720                      interest other than PR_REQUESTED, all other lwps in the
1696 1721                      process are directed to stop.
1697 1722  
1698 1723  
1699 1724         PR_MSACCT
1700 1725                      (microstate accounting): Microstate accounting is now
1701 1726                      continuously enabled.  This flag is deprecated and no
1702 1727                      longer has any effect upon microstate accounting.
1703 1728                      Applications may toggle this flag; however, microstate
1704 1729                      accounting will remain enabled regardless.
1705 1730  
1706 1731  
1707 1732         PR_MSFORK
1708 1733                      (inherit microstate accounting): All processes now inherit
1709 1734                      microstate accounting, as it is continuously enabled. This
1710 1735                      flag has been deprecated and its use no longer has any
1711 1736                      effect upon the behavior of microstate accounting.
1712 1737  
1713 1738  
1714 1739         PR_BPTADJ
1715 1740                      (breakpoint trap pc adjustment): On x86-based machines, a
1716 1741                      breakpoint trap leaves the program counter (the EIP)
1717 1742                      referring to the breakpointed instruction plus one byte.
1718 1743                      When PR_BPTADJ is set, the system will adjust the program
1719 1744                      counter back to the location of the breakpointed
1720 1745                      instruction when the lwp stops on a breakpoint. This flag
1721 1746                      has no effect on SPARC based machines, where breakpoint
1722 1747                      traps leave the program counter referring to the
1723 1748                      breakpointed instruction.
1724 1749  
1725 1750  
1726 1751         PR_PTRACE
1727 1752                      (ptrace-compatibility): When set, a stop on an event of
1728 1753                      interest by the traced process is reported to the parent
1729 1754                      of the traced process by wait(3C), SIGTRAP is sent to the
1730 1755                      traced process when it executes a successful exec(2),
1731 1756                      setuid/setgid flags are not honored for execs performed by
1732 1757                      the traced process, any exec of an object file that the
1733 1758                      traced process cannot read fails, and the process dies
1734 1759                      when its parent dies. This mode is deprecated; it is
1735 1760                      provided only to allow ptrace(3C) to be implemented as a
1736 1761                      library function using /proc.
1737 1762  
1738 1763  
1739 1764  
1740 1765         It is an error (EINVAL) to specify flags other than those described
1741 1766         above or to apply these operations to a system process. The current
1742 1767         modes are reported in the pr_flags field of /proc/pid/status and
1743 1768         /proc/pid/lwp/lwp/lwpstatus.
1744 1769  
1745 1770     PCSREG
1746 1771         Set the general registers for the specific or representative lwp
1747 1772         according to the operand prgregset_t structure.
1748 1773  
1749 1774  
1750 1775         On SPARC based systems, only the condition-code bits of the processor-
1751 1776         status register (R_PSR) of SPARC V8 (32-bit) processes can be modified
1752 1777         by PCSREG. Other privileged registers cannot be modified at all.
1753 1778  
1754 1779  
1755 1780         On x86-based systems, only certain bits of the flags register (EFL) can
1756 1781         be modified by PCSREG: these include the condition codes, direction-
1757 1782         bit, and overflow-bit.
1758 1783  
1759 1784  
1760 1785         PCSREG fails with EBUSY if the lwp is not stopped on an event of
1761 1786         interest.
1762 1787  
1763 1788     PCSVADDR
1764 1789         Set the address at which execution will resume for the specific or
1765 1790         representative lwp from the operand long. On SPARC based systems, both
1766 1791         %pc and %npc are set, with %npc set to the instruction following the
1767 1792         virtual address. On x86-based systems, only %eip is set. PCSVADDR fails
1768 1793         with EBUSY if the lwp is not stopped on an event of interest.
1769 1794  
1770 1795     PCSFPREG
1771 1796         Set the floating-point registers for the specific or representative lwp
1772 1797         according to the operand prfpregset_t structure. An error (EINVAL) is
1773 1798         returned if the system does not support floating-point operations (no
1774 1799         floating-point hardware and the system does not emulate floating-point
1775 1800         machine instructions). PCSFPREG fails with EBUSY if the lwp is not
1776 1801         stopped on an event of interest.
1777 1802  
1778 1803     PCSXREG
1779 1804         Set the extra state registers for the specific or representative lwp
1780 1805         according to the architecture-dependent operand prxregset_t structure.
1781 1806         An error (EINVAL) is returned if the system does not support extra
1782 1807         state registers. PCSXREG fails with EBUSY if the lwp is not stopped on
1783 1808         an event of interest.
1784 1809  
1785 1810     PCSASRS
1786 1811         Set the ancillary state registers for the specific or representative
1787 1812         lwp according to the SPARC V9 platform-dependent operand asrset_t
1788 1813         structure.  An error (EINVAL) is returned if either the target process
1789 1814         or the controlling process is not a 64-bit SPARC V9 process. Most of
1790 1815         the ancillary state registers are privileged registers that cannot be
1791 1816         modified. Only those that can be modified are set; all others are
1792 1817         silently ignored. PCSASRS fails with EBUSY if the lwp is not stopped on
1793 1818         an event of interest.
1794 1819  
1795 1820     PCAGENT
1796 1821         Create an agent lwp in the controlled process with register values from
1797 1822         the operand prgregset_t structure (see PCSREG, above). The agent lwp is
1798 1823         created in the stopped state showing PR_REQUESTED and with its held
1799 1824         signal set (the signal mask) having all signals except SIGKILL and
1800 1825         SIGSTOP blocked.
1801 1826  
1802 1827  
1803 1828         The PCAGENT operation fails with EBUSY unless the process is fully
1804 1829         stopped via /proc, that is, unless all of the lwps in the process are
1805 1830         stopped either on events of interest or on PR_SUSPENDED, or are stopped
1806 1831         on PR_JOBCONTROL and have been directed to stop via PCDSTOP.  It fails
1807 1832         with EBUSY if an agent lwp already exists. It fails with ENOMEM if
1808 1833         system resources for creating new lwps have been exhausted.
1809 1834  
1810 1835  
1811 1836         Any PCRUN operation applied to the process control file or to the
1812 1837         control file of an lwp other than the agent lwp fails with EBUSY as
1813 1838         long as the agent lwp exists. The agent lwp must be caused to terminate
1814 1839         by executing the SYS_lwp_exit system call trap before the process can
1815 1840         be restarted.
1816 1841  
1817 1842  
1818 1843         Once the agent lwp is created, its lwp-ID can be found by reading the
1819 1844         process status file. To facilitate opening the agent lwp's control and
1820 1845         status files, the directory name /propc/pid/lwp/agent is accepted for
1821 1846         lookup operations as an invisible alias for /proc/pid/lwp/lwpid, lwpid
1822 1847         being the lwp-ID of the agent lwp (invisible in the sense that the name
1823 1848         ``agent'' does not appear in a directory listing of /proc/pid/lwp
1824 1849         obtained from ls(1), getdents(2), or readdir(3C)).
1825 1850  
1826 1851  
1827 1852         The purpose of the agent lwp is to perform operations in the controlled
1828 1853         process on behalf of the controlling process: to gather information not
1829 1854         directly available via /proc files, or in general to make the process
1830 1855         change state in ways not directly available via /proc control
1831 1856         operations. To make use of an agent lwp, the controlling process must
1832 1857         be capable of making it execute system calls (specifically, the
1833 1858         SYS_lwp_exit system call trap). The register values given to the agent
1834 1859         lwp on creation are typically the registers of the representative lwp,
1835 1860         so that the agent lwp can use its stack.
1836 1861  
1837 1862  
1838 1863         If the controlling process neglects to force the agent lwp to execute
1839 1864         the SYS_lwp_exit system call (due to either logic error or fatal
1840 1865         failure on the part of the controlling process), the agent lwp will
1841 1866         remain in the target process.  For purposes of being able to debug
1842 1867         these otherwise rogue agents, information as to the creator of the
1843 1868         agent lwp is reflected in that lwp's spymaster file in /proc. Should
1844 1869         the target process generate a core dump with the agent lwp in place,
1845 1870         this information will be available via the NT_SPYMASTER note in the
1846 1871         core file (see core(4)).
1847 1872  
1848 1873  
1849 1874         The agent lwp is not allowed to execute any variation of the SYS_fork
1850 1875         or SYS_exec system call traps. Attempts to do so yield ENOTSUP to the
1851 1876         agent lwp.
1852 1877  
1853 1878  
1854 1879         Symbolic constants for system call trap numbers like SYS_lwp_exit and
1855 1880         SYS_lwp_create can be found in the header file <sys/syscall.h>.
1856 1881  
1857 1882     PCREAD PCWRITE
1858 1883         Read or write the target process's address space via a priovec
1859 1884         structure operand:
1860 1885  
1861 1886           typedef struct priovec {
1862 1887               void *pio_base;      /* buffer in controlling process */
1863 1888               size_t pio_len;      /* size of read/write request in bytes */
1864 1889               off_t pio_offset;    /* virtual address in target process */
1865 1890           } priovec_t;
1866 1891  
1867 1892  
1868 1893  
1869 1894         These operations have the same effect as pread(2) and pwrite(2),
1870 1895         respectively, of the target process's address space file. The
1871 1896         difference is that more than one PCREAD or PCWRITE control operation
1872 1897         can be written to the control file at once, and they can be
1873 1898         interspersed with other control operations in a single write to the
1874 1899         control file. This is useful, for example, when planting many
1875 1900         breakpoint instructions in the process's address space, or when
1876 1901         stepping over a breakpointed instruction. Unlike pread(2) and
1877 1902         pwrite(2), no provision is made for partial reads or writes; if the
1878 1903         operation cannot be performed completely, it fails with EIO.
1879 1904  
1880 1905     PCNICE
1881 1906         The traced process's nice(2) value is incremented by the amount in the
1882 1907         operand long. Only a process with the {PRIV_PROC_PRIOCNTL} privilege
1883 1908         asserted in its effective set can better a process's priority in this
1884 1909         way, but any user may lower the priority. This operation is not
1885 1910         meaningful for all scheduling classes.
1886 1911  
1887 1912     PCSCRED
1888 1913         Set the target process credentials to the values contained in the
1889 1914         prcred_t structure operand (see /proc/pid/cred). The effective, real,
1890 1915         and saved user-IDs and group-IDs of the target process are set. The
1891 1916         target process's supplementary groups are not changed; the pr_ngroups
1892 1917         and pr_groups members of the structure operand are ignored. Only the
1893 1918         privileged processes can perform this operation; for all others it
1894 1919         fails with EPERM.
1895 1920  
1896 1921     PCSCREDX
1897 1922         Operates like PCSCRED but also sets the supplementary groups; the
1898 1923         length of the data written with this control operation should be
1899 1924         "sizeof (prcred_t) + sizeof (gid_t) * (#groups - 1)".
1900 1925  
1901 1926     PCSPRIV
1902 1927         Set the target process privilege to the values contained in the
1903 1928         prpriv_t operand (see /proc/pid/priv). The effective, permitted,
1904 1929         inheritable, and limit sets are all changed. Privilege flags can also
1905 1930         be set. The process is made privilege aware unless it can relinquish
1906 1931         privilege awareness. See privileges(5).
1907 1932  
1908 1933  
1909 1934         The limit set of the target process cannot be grown. The other
1910 1935         privilege sets must be subsets of the intersection of the effective set
1911 1936         of the calling process with the new limit set of the target process or
1912 1937         subsets of the original values of the sets in the target process.
1913 1938  
1914 1939  
1915 1940         If any of the above restrictions are not met, EPERM is returned. If the
1916 1941         structure written is improperly formatted, EINVAL is returned.
1917 1942  
1918 1943  PROGRAMMING NOTES
1919 1944         For security reasons, except for the psinfo, usage, lpsinfo, lusage,
1920 1945         lwpsinfo, and lwpusage files, which are world-readable, and except for
1921 1946         privileged processes, an open of a /proc file fails unless both the
1922 1947         user-ID and group-ID of the caller match those of the traced process
1923 1948         and the process's object file is readable by the caller. The effective
1924 1949         set of the caller is a superset of both the inheritable and the
1925 1950         permitted set of the target process. The limit set of the caller is a
1926 1951         superset of the limit set of the target process. Except for the world-
1927 1952         readable files just mentioned, files corresponding to setuid and setgid
1928 1953         processes can be opened only by the appropriately privileged process.
1929 1954  
1930 1955  
1931 1956         A process that is missing the basic privilege {PRIV_PROC_INFO} cannot
1932 1957         see any processes under /proc that it cannot send a signal to.
1933 1958  
1934 1959  
1935 1960         A process that has {PRIV_PROC_OWNER} asserted in its effective set can
1936 1961         open any file for reading. To manipulate or control a process, the
1937 1962         controlling process must have at least as many privileges in its
1938 1963         effective set as the target process has in its effective, inheritable,
1939 1964         and permitted sets. The limit set of the controlling process must be a
1940 1965         superset of the limit set of the target process. Additional
1941 1966         restrictions apply if any of the uids of the target process are 0. See
1942 1967         privileges(5).
1943 1968  
1944 1969  
1945 1970         Even if held by a privileged process, an open process or lwp file
1946 1971         descriptor (other than file descriptors for the world-readable files)
1947 1972         becomes invalid if the traced process performs an exec(2) of a
1948 1973         setuid/setgid object file or an object file that the traced process
1949 1974         cannot read. Any operation performed on an invalid file descriptor,
1950 1975         except close(2), fails with EAGAIN. In this situation, if any tracing
1951 1976         flags are set and the process or any lwp file descriptor is open for
1952 1977         writing, the process will have been directed to stop and its run-on-
1953 1978         last-close flag will have been set (see PCSET). This enables a
1954 1979         controlling process (if it has permission) to reopen the /proc files to
1955 1980         get new valid file descriptors, close the invalid file descriptors,
1956 1981         unset the run-on-last-close flag (if desired), and proceed. Just
1957 1982         closing the invalid file descriptors causes the traced process to
1958 1983         resume execution with all tracing flags cleared. Any process not
1959 1984         currently open for writing via /proc, but that has left-over tracing
1960 1985         flags from a previous open, and that executes a setuid/setgid or
1961 1986         unreadable object file, will not be stopped but will have all its
1962 1987         tracing flags cleared.
1963 1988  
1964 1989  
1965 1990         To wait for one or more of a set of processes or lwps to stop or
1966 1991         terminate, /proc file descriptors (other than those obtained by opening
1967 1992         the cwd or root directories or by opening files in the fd or object
1968 1993         directories) can be used in a poll(2) system call. When requested and
1969 1994         returned, either of the polling events POLLPRI or POLLWRNORM indicates
1970 1995         that the process or lwp stopped on an event of interest. Although they
1971 1996         cannot be requested, the polling events POLLHUP, POLLERR, and POLLNVAL
1972 1997         may be returned. POLLHUP indicates that the process or lwp has
1973 1998         terminated. POLLERR indicates that the file descriptor has become
1974 1999         invalid. POLLNVAL is returned immediately if POLLPRI or POLLWRNORM is
1975 2000         requested on a file descriptor referring to a system process (see
1976 2001         PCSTOP). The requested events may be empty to wait simply for
1977 2002         termination.
1978 2003  
1979 2004  FILES
1980 2005         /proc
1981 2006  
1982 2007             directory (list of processes)
1983 2008  
1984 2009  
1985 2010         /proc/pid
1986 2011  
1987 2012             specific process directory
1988 2013  
1989 2014  
1990 2015         /proc/self
1991 2016  
1992 2017             alias for a process's own directory
1993 2018  
1994 2019  
1995 2020         /proc/pid/as
1996 2021  
1997 2022             address space file
1998 2023  
1999 2024  
2000 2025         /proc/pid/ctl
2001 2026  
2002 2027             process control file
2003 2028  
2004 2029  
2005 2030         /proc/pid/status
2006 2031  
2007 2032             process status
2008 2033  
2009 2034  
2010 2035         /proc/pid/lstatus
2011 2036  
2012 2037             array of lwp status structs
2013 2038  
2014 2039  
2015 2040         /proc/pid/psinfo
2016 2041  
2017 2042             process ps(1) info
2018 2043  
2019 2044  
2020 2045         /proc/pid/lpsinfo
2021 2046  
2022 2047             array of lwp ps(1) info structs
2023 2048  
2024 2049  
2025 2050         /proc/pid/map
2026 2051  
2027 2052             address space map
2028 2053  
2029 2054  
2030 2055         /proc/pid/xmap
2031 2056  
2032 2057             extended address space map
2033 2058  
2034 2059  
2035 2060         /proc/pid/rmap
2036 2061  
2037 2062             reserved address map
2038 2063  
2039 2064  
2040 2065         /proc/pid/cred
2041 2066  
2042 2067             process credentials
2043 2068  
2044 2069  
2045 2070         /proc/pid/priv
2046 2071  
2047 2072             process privileges
2048 2073  
2049 2074  
  
    | 
      ↓ open down ↓ | 
    1184 lines elided | 
    
      ↑ open up ↑ | 
  
2050 2075         /proc/pid/sigact
2051 2076  
2052 2077             process signal actions
2053 2078  
2054 2079  
2055 2080         /proc/pid/auxv
2056 2081  
2057 2082             process aux vector
2058 2083  
2059 2084  
     2085 +       /proc/pid/argv
     2086 +
     2087 +           process argument vector
     2088 +
     2089 +
2060 2090         /proc/pid/ldt
2061 2091  
2062 2092             process LDT (x86 only)
2063 2093  
2064 2094  
2065 2095         /proc/pid/usage
2066 2096  
2067 2097             process usage
2068 2098  
2069 2099  
2070 2100         /proc/pid/lusage
2071 2101  
2072 2102             array of lwp usage structs
2073 2103  
2074 2104  
2075 2105         /proc/pid/path
2076 2106  
2077 2107             symbolic links to process open files
2078 2108  
2079 2109  
2080 2110         /proc/pid/pagedata
2081 2111  
2082 2112             process page data
2083 2113  
2084 2114  
2085 2115         /proc/pid/watch
2086 2116  
2087 2117             active watchpoints
2088 2118  
2089 2119  
2090 2120         /proc/pid/cwd
2091 2121  
2092 2122             alias for the current working directory
2093 2123  
2094 2124  
2095 2125         /proc/pid/root
2096 2126  
2097 2127             alias for the root directory
2098 2128  
2099 2129  
2100 2130         /proc/pid/fd
2101 2131  
2102 2132             directory (list of open files)
2103 2133  
2104 2134  
2105 2135         /proc/pid/fd/*
2106 2136  
2107 2137             aliases for process's open files
2108 2138  
2109 2139  
2110 2140         /proc/pid/object
2111 2141  
2112 2142             directory (list of mapped files)
2113 2143  
2114 2144  
2115 2145         /proc/pid/object/a.out
2116 2146  
2117 2147             alias for process's executable file
2118 2148  
2119 2149  
2120 2150         /proc/pid/object/*
2121 2151  
2122 2152             aliases for other mapped files
2123 2153  
2124 2154  
2125 2155         /proc/pid/lwp
2126 2156  
2127 2157             directory (list of lwps)
2128 2158  
2129 2159  
2130 2160         /proc/pid/lwp/lwpid
2131 2161  
2132 2162             specific lwp directory
2133 2163  
2134 2164  
2135 2165         /proc/pid/lwp/agent
2136 2166  
2137 2167             alias for the agent lwp directory
2138 2168  
2139 2169  
2140 2170         /proc/pid/lwp/lwpid/lwpctl
2141 2171  
2142 2172             lwp control file
2143 2173  
2144 2174  
2145 2175         /proc/pid/lwp/lwpid/lwpstatus
2146 2176  
2147 2177             lwp status
2148 2178  
2149 2179  
2150 2180         /proc/pid/lwp/lwpid/lwpsinfo
2151 2181  
2152 2182             lwp ps(1) info
2153 2183  
2154 2184  
2155 2185         /proc/pid/lwp/lwpid/lwpusage
2156 2186  
2157 2187             lwp usage
2158 2188  
2159 2189  
2160 2190         /proc/pid/lwp/lwpid/gwindows
2161 2191  
2162 2192             register windows (SPARC only)
2163 2193  
2164 2194  
2165 2195         /proc/pid/lwp/lwpid/xregs
2166 2196  
2167 2197             extra state registers
2168 2198  
2169 2199  
2170 2200         /proc/pid/lwp/lwpid/asrs
2171 2201  
2172 2202             ancillary state registers (SPARC V9 only)
2173 2203  
2174 2204  
2175 2205         /proc/pid/lwp/lwpid/spymaster
2176 2206  
2177 2207             For an agent LWP, the controlling process
2178 2208  
2179 2209  
2180 2210  SEE ALSO
2181 2211         ls(1), ps(1), chroot(1M), alarm(2), brk(2), chdir(2), chroot(2),
2182 2212         close(2), creat(2), dup(2), exec(2), fcntl(2), fork(2), fork1(2),
2183 2213         fstat(2), getdents(2), getustack(2), kill(2), lseek(2), mmap(2),
2184 2214         nice(2), open(2), poll(2), pread(2), ptrace(3C), pwrite(2), read(2),
2185 2215         readlink(2), readv(2), shmget(2), sigaction(2), sigaltstack(2),
2186 2216         vfork(2), write(2), writev(2), _stack_grow(3C), readdir(3C),
2187 2217         pthread_create(3C), pthread_join(3C), siginfo.h(3HEAD),
2188 2218         signal.h(3HEAD), thr_create(3C), thr_join(3C), types32.h(3HEAD),
2189 2219         ucontext.h(3HEAD), wait(3C), contract(4), core(4), process(4),
2190 2220         lfcompile(5), privileges(5)
2191 2221  
2192 2222  DIAGNOSTICS
2193 2223         Errors that can occur in addition to the errors normally associated
2194 2224         with file system access:
2195 2225  
2196 2226         E2BIG
2197 2227                      Data to be returned in a read(2) of the page data file
2198 2228                      exceeds the size of the read buffer provided by the
2199 2229                      caller.
2200 2230  
2201 2231  
2202 2232         EACCES
2203 2233                      An attempt was made to examine a process that ran under a
2204 2234                      different uid than the controlling process and
2205 2235                      {PRIV_PROC_OWNER} was not asserted in the effective set.
2206 2236  
2207 2237  
2208 2238         EAGAIN
2209 2239                      The traced process has performed an exec(2) of a
2210 2240                      setuid/setgid object file or of an object file that it
2211 2241                      cannot read; all further operations on the process or lwp
2212 2242                      file descriptor (except close(2)) elicit this error.
2213 2243  
2214 2244  
2215 2245         EBUSY
2216 2246                      PCSTOP, PCDSTOP, PCWSTOP, or PCTWSTOP was applied to a
2217 2247                      system process; an exclusive open(2) was attempted on a
2218 2248                      /proc file for a process already open for writing; PCRUN,
2219 2249                      PCSREG, PCSVADDR, PCSFPREG, or PCSXREG was applied to a
2220 2250                      process or lwp not stopped on an event of interest; an
2221 2251                      attempt was made to mount /proc when it was already
2222 2252                      mounted; PCAGENT was applied to a process that was not
2223 2253                      fully stopped or that already had an agent lwp.
2224 2254  
2225 2255  
2226 2256         EINVAL
2227 2257                      In general, this means that some invalid argument was
2228 2258                      supplied to a system call. A non-exhaustive list of
2229 2259                      conditions eliciting this error includes: a control
2230 2260                      message operation code is undefined; an out-of-range
2231 2261                      signal number was specified with PCSSIG, PCKILL, or
2232 2262                      PCUNKILL; SIGKILL was specified with PCUNKILL; PCSFPREG
2233 2263                      was applied on a system that does not support floating-
2234 2264                      point operations; PCSXREG was applied on a system that
2235 2265                      does not support extra state registers.
2236 2266  
2237 2267  
2238 2268         EINTR
2239 2269                      A signal was received by the controlling process while
2240 2270                      waiting for the traced process or lwp to stop via PCSTOP,
2241 2271                      PCWSTOP, or PCTWSTOP.
2242 2272  
2243 2273  
2244 2274         EIO
2245 2275                      A write(2) was attempted at an illegal address in the
2246 2276                      traced process.
2247 2277  
2248 2278  
2249 2279         ENOENT
2250 2280                      The traced process or lwp has terminated after being
2251 2281                      opened. The basic privilege {PRIV_PROC_INFO} is not
2252 2282                      asserted in the effective set of the calling process and
2253 2283                      the calling process cannot send a signal to the target
2254 2284                      process.
2255 2285  
2256 2286  
2257 2287         ENOMEM
2258 2288                      The system-imposed limit on the number of page data file
2259 2289                      descriptors was reached on an open of /proc/pid/pagedata;
2260 2290                      an attempt was made with PCWATCH to establish more watched
2261 2291                      areas than the system can support; the PCAGENT operation
2262 2292                      was issued when the system was out of resources for
2263 2293                      creating lwps.
2264 2294  
2265 2295  
2266 2296         ENOSYS
2267 2297                      An attempt was made to perform an unsupported operation
2268 2298                      (such as creat(2), link(2), or unlink(2)) on an entry in
2269 2299                      /proc.
2270 2300  
2271 2301  
2272 2302         EOVERFLOW
2273 2303                      A 32-bit controlling process attempted to read or write
2274 2304                      the as file or attempted to read the map, rmap, or
2275 2305                      pagedata file of a 64-bit target process. A 32-bit
2276 2306                      controlling process attempted to apply one of the control
2277 2307                      operations PCSREG, PCSXREG, PCSVADDR, PCWATCH, PCAGENT,
2278 2308                      PCREAD, PCWRITE to a 64-bit target process.
2279 2309  
2280 2310  
2281 2311         EPERM
2282 2312                      The process that issued the PCSCRED or PCSCREDX operation
2283 2313                      did not have the {PRIV_PROC_SETID} privilege asserted in
2284 2314                      its effective set, or the process that issued the PCNICE
2285 2315                      operation did not have the {PRIV_PROC_PRIOCNTL} in its
2286 2316                      effective set.
2287 2317  
2288 2318                      An attempt was made to control a process of which the E,
2289 2319                      P, and I privilege sets were not a subset of the effective
2290 2320                      set of the controlling process or the limit set of the
2291 2321                      controlling process is not a superset of limit set of the
2292 2322                      controlled process.
2293 2323  
2294 2324                      Any of the uids of the target process are 0 or an attempt
2295 2325                      was made to change any of the uids to 0 using PCSCRED and
2296 2326                      the security policy imposed additional restrictions. See
2297 2327                      privileges(5).
2298 2328  
2299 2329  
2300 2330  NOTES
2301 2331         Descriptions of structures in this document include only interesting
2302 2332         structure elements, not filler and padding fields, and may show
2303 2333         elements out of order for descriptive clarity. The actual structure
2304 2334         definitions are contained in <procfs.h>.
2305 2335  
2306 2336  BUGS
2307 2337         Because the old ioctl(2)-based version of /proc is currently supported
2308 2338         for binary compatibility with old applications, the top-level directory
2309 2339         for a process, /proc/pid, is not world-readable, but it is world-
2310 2340         searchable. Thus, anyone can open /proc/pid/psinfo even though ls(1)
2311 2341         applied to /proc/pid will fail for anyone but the owner or an
2312 2342         appropriately privileged process. Support for the old ioctl(2)-based
  
    | 
      ↓ open down ↓ | 
    243 lines elided | 
    
      ↑ open up ↑ | 
  
2313 2343         version of /proc will be dropped in a future release, at which time the
2314 2344         top-level directory for a process will be made world-readable.
2315 2345  
2316 2346  
2317 2347         On SPARC based machines, the types gregset_t and fpregset_t defined in
2318 2348         <sys/regset.h> are similar to but not the same as the types prgregset_t
2319 2349         and prfpregset_t defined in <procfs.h>.
2320 2350  
2321 2351  
2322 2352  
2323      -                                March 31, 2013                         PROC(4)
     2353 +                                 May 19, 2014                          PROC(4)
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX