Print this page
Code review comments from jeffpc
7029 want per-process exploit mitigation features (secflags)
7030 want basic address space layout randomization (aslr)
7031 noexec_user_stack should be a secflag
7032 want a means to forbid mappings around NULL.
   1 '\" te
   2 .\" Copyright 1989 AT&T
   3 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
   4 .\" Copyright (c) 2013, Joyent, Inc. All rights reserved.
   5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
   8 .TH PROC 4 "Mar 31, 2013"
   9 .SH NAME
  10 proc \- /proc, the process file system
  11 .SH DESCRIPTION
  12 .sp
  13 .LP
  14 \fB/proc\fR is a file system that provides access to the state of each process
  15 and light-weight process (lwp) in the system. The name of each entry in the
  16 \fB/proc\fR directory is a decimal number corresponding to a process-ID. These
  17 entries are themselves subdirectories. Access to process state is provided by
  18 additional files contained within each subdirectory; the hierarchy is described
  19 more completely below. In this document, ``\fB/proc\fR file'' refers to a
  20 non-directory file within the hierarchy rooted at \fB/proc\fR. The owner of
  21 each \fB/proc\fR file and subdirectory is determined by the user-ID of the
  22 process.
  23 .sp
  24 .LP
  25 \fB/proc\fR can be mounted on any mount point, in addition to the standard
  26 \fB/proc\fR mount point, and can be mounted several places at once. Such
  27 additional mounts are allowed in order to facilitate the confinement of
  28 processes to subtrees of the file system via \fBchroot\fR(1M) and yet allow
  29 such processes access to commands like \fBps\fR(1).
  30 .sp
  31 .LP
  32 Standard system calls are used to access \fB/proc\fR files: \fBopen\fR(2),


 157 writing the address space, reading the address-map files, and setting the
 158 target process's registers. There is no restriction on operations applied by a
 159 64-bit process to either a 32-bit or a 64-bit target processes.
 160 .sp
 161 .LP
 162 The format of the contents of any \fB/proc\fR file depends on the data model of
 163 the observer (the controlling process), not on the data model of the target
 164 process. A 64-bit debugger does not have to translate the information it reads
 165 from a \fB/proc\fR file for a 32-bit process from 32-bit format to 64-bit
 166 format. However, it usually has to be aware of the data model of the target
 167 process. The \fBpr_dmodel\fR field of the \fBstatus\fR files indicates the
 168 target process's data model.
 169 .sp
 170 .LP
 171 To help deal with system data structures that are read from 32-bit processes, a
 172 64-bit controlling program can be compiled with the C preprocessor symbol
 173 \fB_SYSCALL32\fR defined before system header files are included. This makes
 174 explicit 32-bit fixed-width data structures (like \fBcstruct stat32\fR) visible
 175 to the 64-bit program. See \fBtypes32.h\fR(3HEAD).
 176 .SH DIRECTORY STRUCTURE
 177 .sp
 178 .LP
 179 At the top level, the directory \fB/proc\fR contains entries each of which
 180 names an existing process in the system. These entries are themselves
 181 directories. Except where otherwise noted, the files described below can be
 182 opened for reading only. In addition, if a process becomes a \fIzombie\fR (one
 183 that has exited but whose parent has not yet performed a \fBwait\fR(3C) upon
 184 it), most of its associated \fB/proc\fR files disappear from the hierarchy;
 185 subsequent attempts to open them, or to read or write files opened before the
 186 process exited, will elicit the error \fBENOENT\fR.
 187 .sp
 188 .LP
 189 Although process state and consequently the contents of \fB/proc\fR files can
 190 change from instant to instant, a single \fBread\fR(2) of a \fB/proc\fR file is
 191 guaranteed to return a sane representation of state; that is, the read will be
 192 atomic with respect to the state of the process. No such guarantee applies to
 193 successive reads applied to a \fB/proc\fR file for a running process. In
 194 addition, atomicity is not guaranteed for \fBI/O\fR applied to the \fBas\fR
 195 (address-space) file for a running process or for a process whose address space
 196 contains memory shared by another running process.
 197 .sp
 198 .LP
 199 A number of structure definitions are used to describe the files. These
 200 structures may grow by the addition of elements at the end in future releases
 201 of the system and it is not legitimate for a program to assume that they will
 202 not.
 203 .SH STRUCTURE OF \fB/proc/\fR\fIpid\fR
 204 .sp
 205 .LP
 206 A given directory \fB/proc/\fR\fIpid\fR contains the following entries. A
 207 process can use the invisible alias \fB/proc/self\fR if it wishes to open one
 208 of its own \fB/proc\fR files (invisible in the sense that the name ``self''
 209 does not appear in a directory listing of \fB/proc\fR obtained from
 210 \fBls\fR(1), \fBgetdents\fR(2), or \fBreaddir\fR(3C)).
 211 .SS "contracts"
 212 .sp
 213 .LP
 214 A directory containing references to the contracts held by the process. Each
 215 entry is a symlink to the contract's directory under \fB/system/contract\fR.
 216 See \fBcontract\fR(4).
 217 .SS "as"
 218 .sp
 219 .LP
 220 Contains the address-space image of the process; it can be opened for both
 221 reading and writing. \fBlseek\fR(2) is used to position the file at the virtual
 222 address of interest and then the address space can be examined or changed
 223 through \fBread\fR(2) or \fBwrite\fR(2) (or by using \fBpread\fR(2) or
 224 \fBpwrite\fR(2) for the combined operation).
 225 .SS "ctl"
 226 .sp
 227 .LP
 228 A write-only file to which structured messages are written directing the system
 229 to change some aspect of the process's state or control its behavior in some
 230 way. The seek offset is not relevant when writing to this file. Individual lwps
 231 also have associated \fBlwpctl\fR files in the lwp subdirectories. A control
 232 message may be written either to the process's \fBctl\fR file or to a specific
 233 \fBlwpctl\fR file with operation-specific effects. The effect of a control
 234 message is immediately reflected in the state of the process visible through
 235 appropriate status and information files. The types of control messages are
 236 described in detail later. See \fBCONTROL MESSAGES\fR.
 237 .SS "status"
 238 .sp
 239 .LP
 240 Contains state information about the process and the representative lwp. The
 241 file contains a \fBpstatus\fR structure which contains an embedded
 242 \fBlwpstatus\fR structure for the representative lwp, as follows:
 243 .sp
 244 .in +2
 245 .nf
 246 typedef struct pstatus {
 247      int pr_flags;            /* flags (see below) */
 248      int pr_nlwp;             /* number of active lwps in the process */
 249      int pr_nzomb;            /* number of zombie lwps in the process */
 250      pid_tpr_pid;             /* process id */
 251      pid_tpr_ppid;            /* parent process id */
 252      pid_tpr_pgid;            /* process group id */
 253      pid_tpr_sid;             /* session id */
 254      id_t pr_aslwpid;         /* obsolete */
 255      id_t pr_agentid;         /* lwp-id of the agent lwp, if any */
 256      sigset_t pr_sigpend;     /* set of process pending signals */
 257      uintptr_t pr_brkbase;    /* virtual address of the process heap */
 258      size_t pr_brksize;       /* size of the process heap, in bytes */


 847 .fi
 848 .in -2
 849 
 850 The preceding constants are listed in \fB<sys/regset.h>\fR\&.
 851 .RE
 852 
 853 .sp
 854 .LP
 855 \fBpr_fpreg\fR is a structure holding the contents of the floating-point
 856 registers.
 857 .sp
 858 .LP
 859 SPARC registers, both general and floating-point, as seen by a 64-bit
 860 controlling process are the V9 versions of the registers, even if the target
 861 process is a 32-bit (V8) process. V8 registers are a subset of the V9
 862 registers.
 863 .sp
 864 .LP
 865 If the lwp is not stopped, all register values are undefined.
 866 .SS "psinfo"
 867 .sp
 868 .LP
 869 Contains miscellaneous information about the process and the representative lwp
 870 needed by the \fBps\fR(1) command. \fBpsinfo\fR remains accessible after a
 871 process becomes a \fIzombie\fR. The file contains a \fBpsinfo\fR structure
 872 which contains an embedded \fBlwpsinfo\fR structure for the representative lwp,
 873 as follows:
 874 .sp
 875 .in +2
 876 .nf
 877 typedef struct psinfo {
 878     int pr_flag;             /* process flags (DEPRECATED: see below) */
 879     int pr_nlwp;             /* number of active lwps in the process */
 880     int pr_nzomb;            /* number of zombie lwps in the process */
 881     pid_t pr_pid;            /* process id */
 882     pid_t pr_ppid;           /* process id of parent */
 883     pid_t pr_pgid;           /* process id of process group leader */
 884     pid_t pr_sid;            /* session id */
 885     uid_t pr_uid;            /* real user id */
 886     uid_t pr_euid;           /* effective user id */
 887     gid_t pr_gid;            /* real group id */


 966 .sp
 967 .LP
 968 Some of the entries in \fBlwpsinfo\fR, such as \fBpr_addr\fR, \fBpr_wchan\fR,
 969 \fBpr_stype\fR, \fBpr_state\fR, and \fBpr_name\fR, refer to internal kernel
 970 data structures and should not be expected to retain their meanings across
 971 different versions of the operating system.
 972 .sp
 973 .LP
 974 \fBlwpsinfo_t.pr_flag\fR is a deprecated interface that should no longer be
 975 used.
 976 .sp
 977 .LP
 978 \fBpr_pctcpu\fR is a 16-bit binary fraction, as described above. It represents
 979 the \fBCPU\fR time used by the specific lwp. On a multi-processor machine, the
 980 maximum value is 1/N, where N is the number of \fBCPU\fRs.
 981 .sp
 982 .LP
 983 \fBpr_contract\fR is the id of the process contract of which the process is a
 984 member. See \fBcontract\fR(4) and \fBprocess\fR(4).
 985 .SS "cred"
 986 .sp
 987 .LP
 988 Contains a description of the credentials associated with the process:
 989 .sp
 990 .in +2
 991 .nf
 992 typedef struct prcred {
 993         uid_t pr_euid;      /* effective user id */
 994         uid_t pr_ruid;      /* real user id */
 995         uid_t pr_suid;      /* saved user id (from exec) */
 996         gid_t pr_egid;      /* effective group id */
 997         gid_t pr_rgid;      /* real group id */
 998         gid_t pr_sgid;      /* saved group id (from exec) */
 999         int pr_ngroups;     /* number of supplementary groups */
1000         gid_t pr_groups[1]; /* array of supplementary groups */
1001 } prcred_t;
1002 .fi
1003 .in -2
1004 .sp
1005 
1006 .sp
1007 .LP
1008 The array of associated supplementary groups in \fBpr_groups\fR is of variable
1009 length; the \fBcred\fR file contains all of the supplementary groups.
1010 \fBpr_ngroups\fR indicates the number of supplementary groups. (See also the
1011 \fBPCSCRED\fR and \fBPCSCREDX\fR control operations.)
1012 .SS "priv"
1013 .sp
1014 .LP
1015 Contains a description of the privileges associated with the process:
1016 .sp
1017 .in +2
1018 .nf
1019 typedef struct prpriv {
1020      uint32_t        pr_nsets;      /* number of privilege set */
1021      uint32_t        pr_setsize;    /* size of privilege set */
1022      uint32_t        pr_infosize;   /* size of supplementary data */
1023      priv_chunk_t    pr_sets[1];    /* array of sets */
1024 } prpriv_t;
1025 .fi
1026 .in -2
1027 
1028 .sp
1029 .LP
1030 The actual dimension of the \fBpr_sets\fR[] field is
1031 .sp
1032 .in +2
1033 .nf
1034 pr_sets[pr_nsets][pr_setsize]
1035 .fi
1036 .in -2
1037 
1038 .sp
1039 .LP
1040 which is followed by additional information about the process state
1041 \fBpr_infosize\fR bytes in size.
1042 .sp
1043 .LP
1044 The full size of the structure can be computed using
1045 \fBPRIV_PRPRIV_SIZE\fR(\fBprpriv_t *\fR).
1046 .SS "sigact"



1047 .sp
















1048 .LP
1049 Contains an array of \fBsigaction structures\fR describing the current
1050 dispositions of all signals associated with the traced process (see
1051 \fBsigaction\fR(2)). Signal numbers are displaced by 1 from array indices, so
1052 that the action for signal number \fIn\fR appears in position \fIn\fR-1 of the
1053 array.
1054 .SS "auxv"
1055 .sp
1056 .LP
1057 Contains the initial values of the process's aux vector in an array of
1058 \fBauxv_t\fR structures (see \fB<sys/auxv.h>\fR). The values are those that
1059 were passed by the operating system as startup information to the dynamic
1060 linker.
1061 .SS "ldt"
1062 .sp
1063 .LP
1064 This file exists only on x86-based machines. It is non-empty only if the
1065 process has established a local descriptor table (\fBLDT\fR). If non-empty, the
1066 file contains the array of currently active \fBLDT\fR entries in an array of
1067 elements of type \fBstruct ssd\fR, defined in \fB<sys/sysi86.h>\fR, one element
1068 for each active \fBLDT\fR entry.
1069 .SS "map, xmap"
1070 .sp
1071 .LP
1072 Contain information about the virtual address map of the process. The map file
1073 contains an array of \fBprmap\fR structures while the xmap file contains an
1074 array of \fBprxmap\fR structures. Each structure describes a contiguous virtual
1075 address region in the address space of the traced process:
1076 .sp
1077 .in +2
1078 .nf
1079 typedef struct prmap {
1080         uintptr_tpr_vaddr;         /* virtual address of mapping */
1081         size_t pr_size;            /* size of mapping in bytes */
1082         char pr_mapname[PRMAPSZ];  /* name in /proc/pid/object */
1083         offset_t pr_offset;        /* offset into mapped object, if any */
1084         int pr_mflags;             /* protection and attribute flags */
1085         int pr_pagesize;           /* pagesize for this mapping in bytes */
1086         int pr_shmid;              /* SysV shared memory identifier */
1087 } prmap_t;
1088 .fi
1089 .in -2
1090 .sp


1218 .sp
1219 .LP
1220 \fBpr_rss\fR is the number of resident pages of memory for the mapping. The
1221 number of resident bytes for the mapping may be determined by multiplying
1222 \fBpr_rss\fR by the page size given by \fBpr_pagesize.\fR
1223 .sp
1224 .LP
1225 \fBpr_anon\fR is the number of resident anonymous memory pages (pages which are
1226 private to this process) for the mapping.
1227 .sp
1228 .LP
1229 \fBpr_locked\fR is the number of locked pages for the mapping. Pages which are
1230 locked are always resident in memory.
1231 .sp
1232 .LP
1233 \fBpr_hatpagesize\fR is the size, in bytes, of the \fBHAT\fR (\fBMMU\fR)
1234 translation for the mapping. \fBpr_hatpagesize\fR may be different than
1235 \fBpr_pagesize.\fR The possible values are hardware architecture specific, and
1236 may change over a mapping's lifetime.
1237 .SS "rmap"
1238 .sp
1239 .LP
1240 Contains information about the reserved address ranges of the process. The file
1241 contains an array of \fBprmap\fR structures, as defined above for the \fBmap\fR
1242 file. Each structure describes a contiguous virtual address region in the
1243 address space of the traced process that is reserved by the system in the sense
1244 that an \fBmmap\fR(2) system call that does not specify \fBMAP_FIXED\fR will
1245 not use any part of it for the new mapping. Examples of such reservations
1246 include the address ranges reserved for the process stack and the individual
1247 thread stacks of a multi-threaded process.
1248 .SS "cwd"
1249 .sp
1250 .LP
1251 A symbolic link to the process's current working directory. See \fBchdir\fR(2).
1252 A \fBreadlink\fR(2) of \fB/proc/\fIpid\fR/cwd\fR yields a null string. However,
1253 it can be opened, listed, and searched as a directory, and can be the target of
1254 \fBchdir\fR(2).
1255 .SS "root"
1256 .sp
1257 .LP
1258 A symbolic link to the process's root directory.
1259 \fB/proc/\fR\fIpid\fR\fB/root\fR can differ from the system root directory if
1260 the process or one of its ancestors executed \fBchroot\fR(2) as super user. It
1261 has the same semantics as \fB/proc/\fR\fIpid\fR\fB/cwd\fR.
1262 .SS "fd"
1263 .sp
1264 .LP
1265 A directory containing references to the open files of the process. Each entry
1266 is a decimal number corresponding to an open file descriptor in the process.
1267 .sp
1268 .LP
1269 If an entry refers to a regular file, it can be opened with normal file system
1270 semantics but, to ensure that the controlling process cannot gain greater
1271 access than the controlled process, with no file access modes other than its
1272 read/write open modes in the controlled process. If an entry refers to a
1273 directory, it can be accessed with the same semantics as
1274 \fB/proc/\fIpid\fR/cwd\fR. An attempt to open any other type of entry fails
1275 with \fBEACCES\fR.
1276 .SS "object"
1277 .sp
1278 .LP
1279 A directory containing read-only files with names corresponding to the
1280 \fBpr_mapname\fR entries in the \fBmap\fR and \fBpagedata\fR files. Opening
1281 such a file yields a file descriptor for the underlying mapped file associated
1282 with an address-space mapping in the process. The file name \fBa.out\fR appears
1283 in the directory as an alias for the process's executable file.
1284 .sp
1285 .LP
1286 The \fBobject\fR directory makes it possible for a controlling process to gain
1287 access to the object file and any shared libraries (and consequently the symbol
1288 tables) without having to know the actual path names of the executable files.
1289 .SS "path"
1290 .sp
1291 .LP
1292 A directory containing symbolic links to files opened by the process. The
1293 directory includes one entry for \fBcwd\fR and \fBroot\fR. The directory also
1294 contains a numerical entry for each file descriptor in the \fBfd\fR directory,
1295 and entries matching those in the \fBobject\fR directory. If this information
1296 is not available, any attempt to read the contents of the symbolic link will
1297 fail. This is most common for files that do not exist in the filesystem
1298 namespace (such as \fBFIFO\fRs and sockets), but can also happen for regular
1299 files. For the file descriptor entries, the path may be different from the one
1300 used by the process to open the file.
1301 .SS "pagedata"
1302 .sp
1303 .LP
1304 Opening the page data file enables tracking of address space references and
1305 modifications on a per-page basis.
1306 .sp
1307 .LP
1308 A \fBread\fR(2) of the page data file descriptor returns structured page data
1309 and atomically clears the page data maintained for the file by the system. That
1310 is to say, each read returns data collected since the last read; the first read
1311 returns data collected since the file was opened. When the call completes, the
1312 read buffer contains the following structure as its header and thereafter
1313 contains a number of section header structures and associated byte arrays that
1314 must be accessed by walking linearly through the buffer.
1315 .sp
1316 .in +2
1317 .nf
1318 typedef struct prpageheader {
1319     timestruc_t pr_tstamp; /* real time stamp, time of read() */
1320     ulong_t pr_nmap;       /* number of address space mappings */
1321     ulong_t pr_npage;      /* total number of pages */
1322 } prpageheader_t;


1364 .ad
1365 .RS 17n
1366 page has been modified.
1367 .RE
1368 
1369 .sp
1370 .LP
1371 If the read buffer is not large enough to contain all of the page data, the
1372 read fails with \fBE2BIG\fR and the page data is not cleared. The required size
1373 of the read buffer can be determined through \fBfstat\fR(2). Application of
1374 \fBlseek\fR(2) to the page data file descriptor is ineffective; every read
1375 starts from the beginning of the file. Closing the page data file descriptor
1376 terminates the system overhead associated with collecting the data.
1377 .sp
1378 .LP
1379 More than one page data file descriptor for the same process can be opened, up
1380 to a system-imposed limit per traced process. A read of one does not affect the
1381 data being collected by the system for the others. An open of the page data
1382 file will fail with \fBENOMEM\fR if the system-imposed limit would be exceeded.
1383 .SS "watch"
1384 .sp
1385 .LP
1386 Contains an array of \fBprwatch\fR structures, one for each watched area
1387 established by the \fBPCWATCH\fR control operation. See \fBPCWATCH\fR for
1388 details.
1389 .SS "usage"
1390 .sp
1391 .LP
1392 Contains process usage information described by a \fBprusage\fR structure which
1393 contains at least the following fields:
1394 .sp
1395 .in +2
1396 .nf
1397 typedef struct prusage {
1398     id_t pr_lwpid;           /* lwp id.  0: process or defunct */
1399     int pr_count;            /* number of contributing lwps */
1400     timestruc_t pr_tstamp;   /* real time stamp, time of read() */
1401     timestruc_t pr_create;   /* process/lwp creation time stamp */
1402     timestruc_t pr_term;     /* process/lwp termination time stamp */
1403     timestruc_t pr_rtime;    /* total lwp real (elapsed) time */
1404     timestruc_t pr_utime;    /* user level CPU time */
1405     timestruc_t pr_stime;    /* system call CPU time */
1406     timestruc_t pr_ttime;    /* other system trap CPU time */
1407     timestruc_t pr_tftime;   /* text page fault sleep time */
1408     timestruc_t pr_dftime;   /* data page fault sleep time */
1409     timestruc_t pr_kftime;   /* kernel page fault sleep time */
1410     timestruc_t pr_ltime;    /* user lock wait sleep time */


1417     ulong_t pr_inblk;        /* input blocks */
1418     ulong_t pr_oublk;        /* output blocks */
1419     ulong_t pr_msnd;         /* messages sent */
1420     ulong_t pr_mrcv;         /* messages received */
1421     ulong_t pr_sigs;         /* signals received */
1422     ulong_t pr_vctx;         /* voluntary context switches */
1423     ulong_t pr_ictx;         /* involuntary context switches */
1424     ulong_t pr_sysc;         /* system calls */
1425     ulong_t pr_ioch;         /* chars read and written */
1426 } prusage_t;
1427 .fi
1428 .in -2
1429 
1430 .sp
1431 .LP
1432 Microstate accounting is now continuously enabled. While this information was
1433 previously an estimate, if microstate accounting were not enabled, the current
1434 information is now never an estimate represents time the process has spent in
1435 various states.
1436 .SS "lstatus"
1437 .sp
1438 .LP
1439 Contains a \fBprheader\fR structure followed by an array of \fBlwpstatus\fR
1440 structures, one for each active lwp in the process (see also
1441 \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwpid\fR/\fBlwpstatus\fR, below). The
1442 \fBprheader\fR structure describes the number and size of the array entries
1443 that follow.
1444 .sp
1445 .in +2
1446 .nf
1447 typedef struct prheader {
1448     long pr_nent;        /* number of entries */
1449     size_t pr_entsize;   /* size of each entry, in bytes */
1450 } prheader_t;
1451 .fi
1452 .in -2
1453 
1454 .sp
1455 .LP
1456 The \fBlwpstatus\fR structure may grow by the addition of elements at the end
1457 in future releases of the system. Programs must use \fBpr_entsize\fR in the
1458 file header to index through the array. These comments apply to all \fB/proc\fR
1459 files that include a \fBprheader\fR structure (\fBlpsinfo\fR and \fBlusage\fR,
1460 below).
1461 .SS "lpsinfo"
1462 .sp
1463 .LP
1464 Contains a \fBprheader\fR structure followed by an array of \fBlwpsinfo\fR
1465 structures, one for eachactive and zombie lwp in the process. See also
1466 \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwpid\fR/\fBlwpsinfo\fR, below.
1467 .SS "lusage"
1468 .sp
1469 .LP
1470 Contains a \fBprheader\fR structure followed by an array of \fBprusage\fR
1471 structures, one for each active lwp in the process, plus an additional element
1472 at the beginning that contains the summation over all defunct lwps (lwps that
1473 once existed but no longer exist in the process). Excluding the \fBpr_lwpid\fR,
1474 \fBpr_tstamp\fR, \fBpr_create\fR, and \fBpr_term\fR entries, the entry-by-entry
1475 summation over all these structures is the definition of the process usage
1476 information obtained from the \fBusage\fR file. (See also
1477 \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwpid\fR/\fBlwpusage\fR, below.)
1478 .SS "lwp"
1479 .sp
1480 .LP
1481 A directory containing entries each of which names an active or zombie lwp
1482 within the process. These entries are themselves directories containing
1483 additional files as described below. Only the \fBlwpsinfo\fR file exists in the
1484 directory of a zombie lwp.
1485 .SH STRUCTURE OF \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwpid\fR
1486 .sp
1487 .LP
1488 A given directory \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwpid\fR contains the
1489 following entries:
1490 .SS "lwpctl"
1491 .sp
1492 .LP
1493 Write-only control file. The messages written to this file affect the specific
1494 lwp rather than the representative lwp, as is the case for the process's
1495 \fBctl\fR file.
1496 .SS "lwpstatus"
1497 .sp
1498 .LP
1499 lwp-specific state information. This file contains the \fBlwpstatus\fR
1500 structure for the specific lwp as described above for the representative lwp in
1501 the process's \fBstatus\fR file.
1502 .SS "lwpsinfo"
1503 .sp
1504 .LP
1505 lwp-specific \fBps\fR(1) information. This file contains the \fBlwpsinfo\fR
1506 structure for the specific lwp as described above for the representative lwp in
1507 the process's \fBpsinfo\fR file. The \fBlwpsinfo\fR file remains accessible
1508 after an lwp becomes a zombie.
1509 .SS "lwpusage"
1510 .sp
1511 .LP
1512 This file contains the \fBprusage\fR structure for the specific lwp as
1513 described above for the process's \fBusage\fR file.
1514 .SS "gwindows"
1515 .sp
1516 .LP
1517 This file exists only on SPARC based machines. If it is non-empty, it contains
1518 a \fBgwindows_t\fR structure, defined in \fB<sys/regset.h>\fR, with the values
1519 of those SPARC register windows that could not be stored on the stack when the
1520 lwp stopped. Conditions under which register windows are not stored on the
1521 stack are: the stack pointer refers to nonexistent process memory or the stack
1522 pointer is improperly aligned. If the lwp is not stopped or if there are no
1523 register windows that could not be stored on the stack, the file is empty (the
1524 usual case).
1525 .SS "xregs"
1526 .sp
1527 .LP
1528 Extra state registers. The extra state register set is architecture dependent;
1529 this file is empty if the system does not support extra state registers. If the
1530 file is non-empty, it contains an architecture dependent structure of type
1531 \fBprxregset_t\fR, defined in \fB<procfs.h>\fR, with the values of the lwp's
1532 extra state registers. If the lwp is not stopped, all register values are
1533 undefined. See also the \fBPCSXREG\fR control operation, below.
1534 .SS "asrs"
1535 .sp
1536 .LP
1537 This file exists only for 64-bit SPARC V9 processes. It contains an
1538 \fBasrset_t\fR structure, defined in <\fBsys/regset.h\fR>, containing the
1539 values of the lwp's platform-dependent ancillary state registers. If the lwp is
1540 not stopped, all register values are undefined. See also the \fBPCSASRS\fR
1541 control operation, below.
1542 .SS "spymaster"
1543 .sp
1544 .LP
1545 For an agent lwp (see \fBPCAGENT\fR), this file contains a \fBpsinfo_t\fR
1546 structure that corresponds to the process that created the agent lwp at the
1547 time the agent was created. This structure is identical to that retrieved via
1548 the \fBpsinfo\fR file, with one modification: the \fBpr_time\fR field does not
1549 correspond to the CPU time for the process, but rather to the creation time of
1550 the agent lwp.
1551 .SS "templates"
1552 .sp
1553 .LP
1554 A directory which contains references to the active templates for the lwp,
1555 named by the contract type. Changes made to an active template descriptor do
1556 not affect the original template which was activated, though they do affect the
1557 active template. It is not possible to activate an active template descriptor.
1558 See \fBcontract\fR(4).
1559 .SH CONTROL MESSAGES
1560 .sp
1561 .LP
1562 Process state changes are effected through messages written to a process's
1563 \fBctl\fR file or to an individual lwp's \fBlwpctl\fR file. All control
1564 messages consist of a \fBlong\fR that names the specific operation followed by
1565 additional data containing the operand, if any.
1566 .sp
1567 .LP
1568 Multiple control messages may be combined in a single \fBwrite\fR(2) (or
1569 \fBwritev\fR(2)) to a control file, but no partial writes are permitted. That
1570 is, each control message, operation code plus operand, if any, must be
1571 presented in its entirety to the \fBwrite\fR(2) and not in pieces over several
1572 system calls. If a control operation fails, no subsequent operations contained
1573 in the same \fBwrite\fR(2) are attempted.
1574 .sp
1575 .LP
1576 Descriptions of the allowable control messages follow. In all cases, writing a
1577 message to a control file for a process or lwp that has terminated elicits the
1578 error \fBENOENT\fR.
1579 .SS "PCSTOP PCDSTOP PCWSTOP PCTWSTOP"
1580 .sp
1581 .LP
1582 When applied to the process control file, \fBPCSTOP\fR directs all lwps to stop
1583 and waits for them to stop, \fBPCDSTOP\fR directs all lwps to stop without
1584 waiting for them to stop, and \fBPCWSTOP\fR simply waits for all lwps to stop.
1585 When applied to an lwp control file, \fBPCSTOP\fR directs the specific lwp to
1586 stop and waits until it has stopped, \fBPCDSTOP\fR directs the specific lwp to
1587 stop without waiting for it to stop, and \fBPCWSTOP\fR simply waits for the
1588 specific lwp to stop. When applied to an lwp control file, \fBPCSTOP\fR and
1589 \fBPCWSTOP\fR complete when the lwp stops on an event of interest, immediately
1590 if already so stopped; when applied to the process control file, they complete
1591 when every lwp has stopped either on an event of interest or on a
1592 \fBPR_SUSPENDED\fR stop.
1593 .sp
1594 .LP
1595 \fBPCTWSTOP\fR is identical to \fBPCWSTOP\fR except that it enables the
1596 operation to time out, to avoid waiting forever for a process or lwp that may
1597 never stop on an event of interest. \fBPCTWSTOP\fR takes a \fBlong\fR operand
1598 specifying a number of milliseconds; the wait will terminate successfully after
1599 the specified number of milliseconds even if the process or lwp has not
1600 stopped; a timeout value of zero makes the operation identical to


1609 is traced and again showing \fBPR_JOBCONTROL\fR if the lwp is set running
1610 without clearing the signal.) If \fBPCSTOP\fR or \fBPCDSTOP\fR is applied to an
1611 lwp that is stopped, but not on an event of interest, the stop directive takes
1612 effect when the lwp is restarted by the competing mechanism. At that time, the
1613 lwp enters a \fBPR_REQUESTED\fR stop before executing any user-level code.
1614 .sp
1615 .LP
1616 A write of a control message that blocks is interruptible by a signal so that,
1617 for example, an \fBalarm\fR(2) can be set to avoid waiting forever for a
1618 process or lwp that may never stop on an event of interest. If \fBPCSTOP\fR is
1619 interrupted, the lwp stop directives remain in effect even though the
1620 \fBwrite\fR(2) returns an error. (Use of \fBPCTWSTOP\fR with a non-zero timeout
1621 is recommended over \fBPCWSTOP\fR with an \fBalarm\fR(2).)
1622 .sp
1623 .LP
1624 A system process (indicated by the \fBPR_ISSYS\fR flag) never executes at user
1625 level, has no user-level address space visible through \fB/proc\fR, and cannot
1626 be stopped. Applying one of these operations to a system process or any of its
1627 lwps elicits the error \fBEBUSY\fR.
1628 .SS "PCRUN"
1629 .sp
1630 .LP
1631 Make an lwp runnable again after a stop. This operation takes a \fBlong\fR
1632 operand containing zero or more of the following flags:
1633 .sp
1634 .ne 2
1635 .na
1636 \fB\fBPRCSIG\fR\fR
1637 .ad
1638 .RS 12n
1639 clears the current signal, if any (see \fBPCCSIG\fR).
1640 .RE
1641 
1642 .sp
1643 .ne 2
1644 .na
1645 \fB\fBPRCFAULT\fR\fR
1646 .ad
1647 .RS 12n
1648 clears the current fault, if any (see \fBPCCFAULT\fR).
1649 .RE


1690 .sp
1691 .LP
1692 When applied to an lwp control file, \fBPCRUN\fR clears any outstanding
1693 directed-stop request and makes the specific lwp runnable. The operation fails
1694 with \fBEBUSY\fR if the specific lwp is not stopped on an event of interest or
1695 has not been directed to stop or if the agent lwp exists and this is not the
1696 agent lwp (see \fBPCAGENT\fR).
1697 .sp
1698 .LP
1699 When applied to the process control file, a representative lwp is chosen for
1700 the operation as described for \fB/proc/\fR\fIpid\fR\fB/status\fR. The
1701 operation fails with \fBEBUSY\fR if the representative lwp is not stopped on an
1702 event of interest or has not been directed to stop or if the agent lwp exists.
1703 If \fBPRSTEP\fR or \fBPRSTOP\fR was requested, the representative lwp is made
1704 runnable and its outstanding directed-stop request is cleared; otherwise all
1705 outstanding directed-stop requests are cleared and, if it was stopped on an
1706 event of interest, the representative lwp is marked \fBPR_REQUESTED\fR. If, as
1707 a consequence, all lwps are in the \fBPR_REQUESTED\fR or \fBPR_SUSPENDED\fR
1708 stop state, all lwps showing \fBPR_REQUESTED\fR are made runnable.
1709 .SS "PCSTRACE"
1710 .sp
1711 .LP
1712 Define a set of signals to be traced in the process. The receipt of one of
1713 these signals by an lwp causes the lwp to stop. The set of signals is defined
1714 using an operand \fBsigset_t\fR contained in the control message. Receipt of
1715 \fBSIGKILL\fR cannot be traced; if specified, it is silently ignored.
1716 .sp
1717 .LP
1718 If a signal that is included in an lwp's held signal set (the signal mask) is
1719 sent to the lwp, the signal is not received and does not cause a stop until it
1720 is removed from the held signal set, either by the lwp itself or by setting the
1721 held signal set with \fBPCSHOLD\fR.
1722 .SS "PCCSIG"
1723 .sp
1724 .LP
1725 The current signal, if any, is cleared from the specific or representative lwp.
1726 .SS "PCSSIG"
1727 .sp
1728 .LP
1729 The current signal and its associated signal information for the specific or
1730 representative lwp are set according to the contents of the operand
1731 \fBsiginfo\fR structure (see \fB<sys/siginfo.h>\fR). If the specified signal
1732 number is zero, the current signal is cleared. The semantics of this operation
1733 are different from those of \fBkill\fR(2) in that the signal is delivered to
1734 the lwp immediately after execution is resumed (even if it is being blocked)
1735 and an additional \fBPR_SIGNALLED\fR stop does not intervene even if the signal
1736 is traced. Setting the current signal to \fBSIGKILL\fR terminates the process
1737 immediately.
1738 .SS "PCKILL"
1739 .sp
1740 .LP
1741 If applied to the process control file, a signal is sent to the process with
1742 semantics identical to those of \fBkill\fR(2). If applied to an lwp control
1743 file, a directed signal is sent to the specific lwp. The signal is named in a
1744 \fBlong\fR operand contained in the message. Sending \fBSIGKILL\fR terminates
1745 the process immediately.
1746 .SS "PCUNKILL"
1747 .sp
1748 .LP
1749 A signal is deleted, that is, it is removed from the set of pending signals. If
1750 applied to the process control file, the signal is deleted from the process's
1751 pending signals. If applied to an lwp control file, the signal is deleted from
1752 the lwp's pending signals. The current signal (if any) is unaffected. The
1753 signal is named in a \fBlong\fR operand in the control message. It is an error
1754 (\fBEINVAL\fR) to attempt to delete \fBSIGKILL\fR.
1755 .SS "PCSHOLD"
1756 .sp
1757 .LP
1758 Set the set of held signals for the specific or representative lwp (signals
1759 whose delivery will be blocked if sent to the lwp). The set of signals is
1760 specified with a \fBsigset_t\fR operand. \fBSIGKILL\fR and \fBSIGSTOP\fR cannot
1761 be held; if specified, they are silently ignored.
1762 .SS "PCSFAULT"
1763 .sp
1764 .LP
1765 Define a set of hardware faults to be traced in the process. On incurring one
1766 of these faults, an lwp stops. The set is defined via the operand
1767 \fBfltset_t\fR structure. Fault names are defined in \fB<sys/fault.h>\fR and
1768 include the following. Some of these may not occur on all processors; there may
1769 be processor-specific faults in addition to these.
1770 .sp
1771 .ne 2
1772 .na
1773 \fB\fBFLTILL\fR\fR
1774 .ad
1775 .RS 13n
1776 illegal instruction
1777 .RE
1778 
1779 .sp
1780 .ne 2
1781 .na
1782 \fB\fBFLTPRIV\fR\fR
1783 .ad


1868 
1869 .sp
1870 .ne 2
1871 .na
1872 \fB\fBFLTPAGE\fR\fR
1873 .ad
1874 .RS 13n
1875 recoverable page fault
1876 .RE
1877 
1878 .sp
1879 .LP
1880 When not traced, a fault normally results in the posting of a signal to the lwp
1881 that incurred the fault. If an lwp stops on a fault, the signal is posted to
1882 the lwp when execution is resumed unless the fault is cleared by \fBPCCFAULT\fR
1883 or by the \fBPRCFAULT\fR option of \fBPCRUN\fR. \fBFLTPAGE\fR is an exception;
1884 no signal is posted. The \fBpr_info\fR field in the \fBlwpstatus\fR structure
1885 identifies the signal to be sent and contains machine-specific information
1886 about the fault.
1887 .SS "PCCFAULT"
1888 .sp
1889 .LP
1890 The current fault, if any, is cleared; the associated signal will not be sent
1891 to the specific or representative lwp.
1892 .SS "PCSENTRY PCSEXIT"
1893 .sp
1894 .LP
1895 These control operations instruct the process's lwps to stop on entry to or
1896 exit from specified system calls. The set of system calls to be traced is
1897 defined via an operand \fBsysset_t\fR structure.
1898 .sp
1899 .LP
1900 When entry to a system call is being traced, an lwp stops after having begun
1901 the call to the system but before the system call arguments have been fetched
1902 from the lwp. When exit from a system call is being traced, an lwp stops on
1903 completion of the system call just prior to checking for signals and returning
1904 to user level. At this point, all return values have been stored into the lwp's
1905 registers.
1906 .sp
1907 .LP
1908 If an lwp is stopped on entry to a system call (\fBPR_SYSENTRY\fR) or when
1909 sleeping in an interruptible system call (\fBPR_ASLEEP\fR is set), it may be
1910 instructed to go directly to system call exit by specifying the \fBPRSABORT\fR
1911 flag in a \fBPCRUN\fR control message. Unless exit from the system call is
1912 being traced, the lwp returns to user level showing \fBEINTR\fR.
1913 .SS "PCWATCH"
1914 .sp
1915 .LP
1916 Set or clear a watched area in the controlled process from a \fBprwatch\fR
1917 structure operand:
1918 .sp
1919 .in +2
1920 .nf
1921 typedef struct prwatch {
1922     uintptr_t pr_vaddr;  /* virtual address of watched area */
1923     size_t pr_size;      /* size of watched area in bytes */
1924     int pr_wflags;       /* watch type flags */
1925 } prwatch_t;
1926 .fi
1927 .in -2
1928 
1929 .sp
1930 .LP
1931 \fBpr_vaddr\fR specifies the virtual address of an area of memory to be watched
1932 in the controlled process. \fBpr_size\fR specifies the size of the area, in
1933 bytes. \fBpr_wflags\fR specifies the type of memory access to be monitored as a
1934 bit-mask of the following flags:


2043 \fBexec\fR(2). \fBPCWATCH\fR fails with \fBEBUSY\fR if applied to the parent of
2044 a \fBvfork\fR(2) before the child has terminated or performed an \fBexec\fR(2).
2045 The \fBPR_VFORKP\fR flag is set in the \fBpstatus\fR structure for such a
2046 parent process.
2047 .sp
2048 .LP
2049 Certain accesses of the traced process's address space by the operating system
2050 are immune to watchpoints. The initial construction of a signal stack frame
2051 when a signal is delivered to an lwp will not trigger a watchpoint trap even if
2052 the new frame covers watched areas of the stack. Once the signal handler is
2053 entered, watchpoint traps occur normally. On SPARC based machines, register
2054 window overflow and underflow will not trigger watchpoint traps, even if the
2055 register window save areas cover watched areas of the stack.
2056 .sp
2057 .LP
2058 Watched areas are not inherited by child processes, even if the traced
2059 process's inherit-on-fork mode, \fBPR_FORK\fR, is set (see \fBPCSET\fR, below).
2060 All watched areas are cancelled when the traced process performs a successful
2061 \fBexec\fR(2).
2062 .SS "PCSET PCUNSET"
2063 .sp
2064 .LP
2065 \fBPCSET\fR sets one or more modes of operation for the traced process.
2066 \fBPCUNSET\fR unsets these modes. The modes to be set or unset are specified by
2067 flags in an operand \fBlong\fR in the control message:
2068 .sp
2069 .ne 2
2070 .na
2071 \fB\fBPR_FORK\fR\fR
2072 .ad
2073 .RS 13n
2074 (inherit-on-fork): When set, the process's tracing flags and its
2075 inherit-on-fork mode are inherited by the child of a \fBfork\fR(2),
2076 \fBfork1\fR(2), or \fBvfork\fR(2). When unset, child processes start with all
2077 tracing flags cleared.
2078 .RE
2079 
2080 .sp
2081 .ne 2
2082 .na
2083 \fB\fBPR_RLC\fR\fR


2159 \fB\fBPR_PTRACE\fR\fR
2160 .ad
2161 .RS 13n
2162 (ptrace-compatibility): When set, a stop on an event of interest by the traced
2163 process is reported to the parent of the traced process by \fBwait\fR(3C),
2164 \fBSIGTRAP\fR is sent to the traced process when it executes a successful
2165 \fBexec\fR(2), setuid/setgid flags are not honored for execs performed by the
2166 traced process, any exec of an object file that the traced process cannot read
2167 fails, and the process dies when its parent dies. This mode is deprecated; it
2168 is provided only to allow \fBptrace\fR(3C) to be implemented as a library
2169 function using \fB/proc\fR.
2170 .RE
2171 
2172 .sp
2173 .LP
2174 It is an error (\fBEINVAL\fR) to specify flags other than those described above
2175 or to apply these operations to a system process. The current modes are
2176 reported in the \fBpr_flags\fR field of \fB/proc/\fR\fIpid\fR\fB/status\fR and
2177 \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwp\fR\fB/lwpstatus\fR.
2178 .SS "PCSREG"
2179 .sp
2180 .LP
2181 Set the general registers for the specific or representative lwp according to
2182 the operand \fBprgregset_t\fR structure.
2183 .sp
2184 .LP
2185 On SPARC based systems, only the condition-code bits of the processor-status
2186 register (R_PSR) of SPARC V8 (32-bit) processes can be modified by
2187 \fBPCSREG\fR. Other privileged registers cannot be modified at all.
2188 .sp
2189 .LP
2190 On x86-based systems, only certain bits of the flags register (EFL) can be
2191 modified by \fBPCSREG\fR: these include the condition codes, direction-bit, and
2192 overflow-bit.
2193 .sp
2194 .LP
2195 \fBPCSREG\fR fails with \fBEBUSY\fR if the lwp is not stopped on an event of
2196 interest.
2197 .SS "PCSVADDR"
2198 .sp
2199 .LP
2200 Set the address at which execution will resume for the specific or
2201 representative lwp from the operand \fBlong\fR. On SPARC based systems, both
2202 %pc and %npc are set, with %npc set to the instruction following the virtual
2203 address. On x86-based systems, only %eip is set. \fBPCSVADDR\fR fails with
2204 \fBEBUSY\fR if the lwp is not stopped on an event of interest.
2205 .SS "PCSFPREG"
2206 .sp
2207 .LP
2208 Set the floating-point registers for the specific or representative lwp
2209 according to the operand \fBprfpregset_t\fR structure. An error (\fBEINVAL\fR)
2210 is returned if the system does not support floating-point operations (no
2211 floating-point hardware and the system does not emulate floating-point machine
2212 instructions). \fBPCSFPREG\fR fails with \fBEBUSY\fR if the lwp is not stopped
2213 on an event of interest.
2214 .SS "PCSXREG"
2215 .sp
2216 .LP
2217 Set the extra state registers for the specific or representative lwp according
2218 to the architecture-dependent operand \fBprxregset_t\fR structure. An error
2219 (\fBEINVAL\fR) is returned if the system does not support extra state
2220 registers. \fBPCSXREG\fR fails with \fBEBUSY\fR if the lwp is not stopped on an
2221 event of interest.
2222 .SS "PCSASRS"
2223 .sp
2224 .LP
2225 Set the ancillary state registers for the specific or representative lwp
2226 according to the SPARC V9 platform-dependent operand \fBasrset_t\fR structure.
2227 An error (\fBEINVAL\fR) is returned if either the target process or the
2228 controlling process is not a 64-bit SPARC V9 process. Most of the ancillary
2229 state registers are privileged registers that cannot be modified. Only those
2230 that can be modified are set; all others are silently ignored. \fBPCSASRS\fR
2231 fails with \fBEBUSY\fR if the lwp is not stopped on an event of interest.
2232 .SS "PCAGENT"
2233 .sp
2234 .LP
2235 Create an agent lwp in the controlled process with register values from the
2236 operand \fBprgregset_t\fR structure (see \fBPCSREG\fR, above). The agent lwp is
2237 created in the stopped state showing \fBPR_REQUESTED\fR and with its held
2238 signal set (the signal mask) having all signals except \fBSIGKILL\fR and
2239 \fBSIGSTOP\fR blocked.
2240 .sp
2241 .LP
2242 The \fBPCAGENT\fR operation fails with \fBEBUSY\fR unless the process is fully
2243 stopped via \fB/proc\fR, that is, unless all of the lwps in the process are
2244 stopped either on events of interest or on \fBPR_SUSPENDED\fR, or are stopped
2245 on \fBPR_JOBCONTROL\fR and have been directed to stop via \fBPCDSTOP\fR.  It
2246 fails with \fBEBUSY\fR if an agent lwp already exists. It fails with
2247 \fBENOMEM\fR if system resources for creating new lwps have been exhausted.
2248 .sp
2249 .LP
2250 Any \fBPCRUN\fR operation applied to the process control file or to the control
2251 file of an lwp other than the agent lwp fails with \fBEBUSY\fR as long as the
2252 agent lwp exists. The agent lwp must be caused to terminate by executing the
2253 \fBSYS_lwp_exit\fR system call trap before the process can be restarted.


2274 .sp
2275 .LP
2276 If the controlling process neglects to force the agent lwp to execute the
2277 \fBSYS_lwp_exit\fR system call (due to either logic error or fatal failure on
2278 the part of the controlling process), the agent lwp will remain in the target
2279 process.  For purposes of being able to debug these otherwise rogue agents,
2280 information as to the creator of the agent lwp is reflected in that lwp's
2281 \fBspymaster\fR file in \fB/proc\fR. Should the target process generate a core
2282 dump with the agent lwp in place, this information will be available via the
2283 \fBNT_SPYMASTER\fR note in the core file (see \fBcore\fR(4)).
2284 .sp
2285 .LP
2286 The agent lwp is not allowed to execute any variation of the \fBSYS_fork\fR or
2287 \fBSYS_exec\fR system call traps. Attempts to do so yield \fBENOTSUP\fR to the
2288 agent lwp.
2289 .sp
2290 .LP
2291 Symbolic constants for system call trap numbers like \fBSYS_lwp_exit\fR and
2292 \fBSYS_lwp_create\fR can be found in the header file <\fBsys/syscall.h\fR>.
2293 .SS "PCREAD PCWRITE"
2294 .sp
2295 .LP
2296 Read or write the target process's address space via a \fBpriovec\fR structure
2297 operand:
2298 .sp
2299 .in +2
2300 .nf
2301 typedef struct priovec {
2302     void *pio_base;      /* buffer in controlling process */
2303     size_t pio_len;      /* size of read/write request in bytes */
2304     off_t pio_offset;    /* virtual address in target process */
2305 } priovec_t;
2306 .fi
2307 .in -2
2308 
2309 .sp
2310 .LP
2311 These operations have the same effect as \fBpread\fR(2) and \fBpwrite\fR(2),
2312 respectively, of the target process's address space file. The difference is
2313 that more than one \fBPCREAD\fR or \fBPCWRITE\fR control operation can be
2314 written to the control file at once, and they can be interspersed with other
2315 control operations in a single write to the control file. This is useful, for
2316 example, when planting many breakpoint instructions in the process's address
2317 space, or when stepping over a breakpointed instruction. Unlike \fBpread\fR(2)
2318 and \fBpwrite\fR(2), no provision is made for partial reads or writes; if the
2319 operation cannot be performed completely, it fails with \fBEIO\fR.
2320 .SS "PCNICE"
2321 .sp
2322 .LP
2323 The traced process's \fBnice\fR(2) value is incremented by the amount in the
2324 operand \fBlong\fR. Only a process with the {\fBPRIV_PROC_PRIOCNTL\fR}
2325 privilege asserted in its effective set can better a process's priority in this
2326 way, but any user may lower the priority. This operation is not meaningful for
2327 all scheduling classes.
2328 .SS "PCSCRED"
2329 .sp
2330 .LP
2331 Set the target process credentials to the values contained in the
2332 \fBprcred_t\fR structure operand (see \fB/proc/\fR\fIpid\fR\fB/cred\fR). The
2333 effective, real, and saved user-IDs and group-IDs of the target process are
2334 set. The target process's supplementary groups are not changed; the
2335 \fBpr_ngroups\fR and \fBpr_groups\fR members of the structure operand are
2336 ignored. Only the privileged processes can perform this operation; for all
2337 others it fails with \fBEPERM\fR.
2338 .SS "PCSCREDX"
2339 .sp
2340 .LP
2341 Operates like \fBPCSCRED\fR but also sets the supplementary groups; the length
2342 of the data written with this control operation should be "sizeof
2343 (\fBprcred_t\fR) + sizeof (\fBgid_t)\fR * (#groups - 1)".
2344 .SS "PCSPRIV"
2345 .sp
2346 .LP
2347 Set the target process privilege to the values contained in the \fBprpriv_t\fR
2348 operand (see \fB/proc/pid/priv\fR). The effective, permitted, inheritable, and
2349 limit sets are all changed. Privilege flags can also be set. The process is
2350 made privilege aware unless it can relinquish privilege awareness. See
2351 \fBprivileges\fR(5).
2352 .sp
2353 .LP
2354 The limit set of the target process cannot be grown. The other privilege sets
2355 must be subsets of the intersection of the effective set of the calling process
2356 with the new limit set of the target process or subsets of the original values
2357 of the sets in the target process.
2358 .sp
2359 .LP
2360 If any of the above restrictions are not met, \fBEPERM\fR is returned. If the
2361 structure written is improperly formatted, \fBEINVAL\fR is returned.
2362 .SH PROGRAMMING NOTES
2363 .sp
2364 .LP
2365 For security reasons, except for the \fBpsinfo\fR, \fBusage\fR, \fBlpsinfo\fR,
2366 \fBlusage\fR, \fBlwpsinfo\fR, and \fBlwpusage\fR files, which are
2367 world-readable, and except for privileged processes, an open of a \fB/proc\fR
2368 file fails unless both the user-ID and group-ID of the caller match those of
2369 the traced process and the process's object file is readable by the caller. The
2370 effective set of the caller is a superset of both the inheritable and the
2371 permitted set of the target process. The limit set of the caller is a superset
2372 of the limit set of the target process. Except for the world-readable files
2373 just mentioned, files corresponding to setuid and setgid processes can be
2374 opened only by the appropriately privileged process.
2375 .sp
2376 .LP
2377 A process that is missing the basic privilege {\fBPRIV_PROC_INFO\fR} cannot see
2378 any processes under \fB/proc\fR that it cannot send a signal to.
2379 .sp
2380 .LP
2381 A process that has {\fBPRIV_PROC_OWNER\fR} asserted in its effective set can
2382 open any file for reading. To manipulate or control a process, the controlling
2383 process must have at least as many privileges in its effective set as the


2402 flags cleared. Any process not currently open for writing via \fB/proc\fR, but
2403 that has left-over tracing flags from a previous open, and that executes a
2404 setuid/setgid or unreadable object file, will not be stopped but will have all
2405 its tracing flags cleared.
2406 .sp
2407 .LP
2408 To wait for one or more of a set of processes or lwps to stop or terminate,
2409 \fB/proc\fR file descriptors (other than those obtained by opening the
2410 \fBcwd\fR or \fBroot\fR directories or by opening files in the \fBfd\fR or
2411 \fBobject\fR directories) can be used in a \fBpoll\fR(2) system call. When
2412 requested and returned, either of the polling events \fBPOLLPRI\fR or
2413 \fBPOLLWRNORM\fR indicates that the process or lwp stopped on an event of
2414 interest. Although they cannot be requested, the polling events \fBPOLLHUP\fR,
2415 \fBPOLLERR\fR, and \fBPOLLNVAL\fR may be returned. \fBPOLLHUP\fR indicates that
2416 the process or lwp has terminated. \fBPOLLERR\fR indicates that the file
2417 descriptor has become invalid. \fBPOLLNVAL\fR is returned immediately if
2418 \fBPOLLPRI\fR or \fBPOLLWRNORM\fR is requested on a file descriptor referring
2419 to a system process (see \fBPCSTOP\fR). The requested events may be empty to
2420 wait simply for termination.
2421 .SH FILES
2422 .sp
2423 .ne 2
2424 .na
2425 \fB\fB/proc\fR\fR
2426 .ad
2427 .sp .6
2428 .RS 4n
2429 directory (list of processes)
2430 .RE
2431 
2432 .sp
2433 .ne 2
2434 .na
2435 \fB\fB/proc/\fIpid\fR\fR\fR
2436 .ad
2437 .sp .6
2438 .RS 4n
2439 specific process directory
2440 .RE
2441 
2442 .sp


2803 .ne 2
2804 .na
2805 \fB\fB/proc/\fIpid\fR/lwp/\fIlwpid\fR/asrs\fR\fR
2806 .ad
2807 .sp .6
2808 .RS 4n
2809 ancillary state registers (SPARC V9 only)
2810 .RE
2811 
2812 .sp
2813 .ne 2
2814 .na
2815 \fB\fB/proc/\fIpid\fR/lwp/\fIlwpid\fR/spymaster\fR\fR
2816 .ad
2817 .sp .6
2818 .RS 4n
2819 For an agent LWP, the controlling process
2820 .RE
2821 
2822 .SH SEE ALSO
2823 .sp
2824 .LP
2825 \fBls\fR(1), \fBps\fR(1), \fBchroot\fR(1M), \fBalarm\fR(2), \fBbrk\fR(2),
2826 \fBchdir\fR(2), \fBchroot\fR(2), \fBclose\fR(2), \fBcreat\fR(2), \fBdup\fR(2),
2827 \fBexec\fR(2), \fBfcntl\fR(2), \fBfork\fR(2), \fBfork1\fR(2), \fBfstat\fR(2),
2828 \fBgetdents\fR(2), \fBgetustack\fR(2), \fBkill\fR(2), \fBlseek\fR(2),
2829 \fBmmap\fR(2), \fBnice\fR(2), \fBopen\fR(2), \fBpoll\fR(2), \fBpread\fR(2),
2830 \fBptrace\fR(3C), \fBpwrite\fR(2), \fBread\fR(2), \fBreadlink\fR(2),
2831 \fBreadv\fR(2), \fBshmget\fR(2), \fBsigaction\fR(2), \fBsigaltstack\fR(2),
2832 \fBvfork\fR(2), \fBwrite\fR(2), \fBwritev\fR(2), \fB_stack_grow\fR(3C),
2833 \fBreaddir\fR(3C), \fBpthread_create\fR(3C), \fBpthread_join\fR(3C),
2834 \fBsiginfo.h\fR(3HEAD), \fBsignal.h\fR(3HEAD), \fBthr_create\fR(3C),
2835 \fBthr_join\fR(3C), \fBtypes32.h\fR(3HEAD), \fBucontext.h\fR(3HEAD),
2836 \fBwait\fR(3C), \fBcontract\fR(4), \fBcore\fR(4), \fBprocess\fR(4),
2837 \fBlfcompile\fR(5), \fBprivileges\fR(5)
2838 .SH DIAGNOSTICS
2839 .sp
2840 .LP
2841 Errors that can occur in addition to the errors normally associated with file
2842 system access:
2843 .sp
2844 .ne 2
2845 .na
2846 \fB\fBE2BIG\fR\fR
2847 .ad
2848 .RS 13n
2849 Data to be returned in a \fBread\fR(2) of the page data file exceeds the size
2850 of the read buffer provided by the caller.
2851 .RE
2852 
2853 .sp
2854 .ne 2
2855 .na
2856 \fB\fBEACCES\fR\fR
2857 .ad
2858 .RS 13n
2859 An attempt was made to examine a process that ran under a different uid than


2974 .na
2975 \fB\fBEPERM\fR\fR
2976 .ad
2977 .RS 13n
2978 The process that issued the \fBPCSCRED\fR or \fBPCSCREDX\fR operation did not
2979 have the {\fBPRIV_PROC_SETID\fR} privilege asserted in its effective set, or
2980 the process that issued the \fBPCNICE\fR operation did not have the
2981 {\fBPRIV_PROC_PRIOCNTL\fR} in its effective set.
2982 .sp
2983 An attempt was made to control a process of which the E, P, and I privilege
2984 sets were not a subset of the effective set of the controlling process or the
2985 limit set of the controlling process is not a superset of limit set of the
2986 controlled process.
2987 .sp
2988 Any of the uids of the target process are 0 or an attempt was made to change
2989 any of the uids to 0 using PCSCRED and the security policy imposed additional
2990 restrictions. See \fBprivileges\fR(5).
2991 .RE
2992 
2993 .SH NOTES
2994 .sp
2995 .LP
2996 Descriptions of structures in this document include only interesting structure
2997 elements, not filler and padding fields, and may show elements out of order for
2998 descriptive clarity. The actual structure definitions are contained in
2999 \fB<procfs.h>\fR\&.
3000 .SH BUGS
3001 .sp
3002 .LP
3003 Because the old \fBioctl\fR(2)-based version of \fB/proc\fR is currently
3004 supported for binary compatibility with old applications, the top-level
3005 directory for a process, \fB/proc/\fR\fIpid\fR, is not world-readable, but it
3006 is world-searchable. Thus, anyone can open \fB/proc/\fR\fIpid\fR\fB/psinfo\fR
3007 even though \fBls\fR(1) applied to \fB/proc/\fR\fIpid\fR will fail for anyone
3008 but the owner or an appropriately privileged process. Support for the old
3009 \fBioctl\fR(2)-based version of \fB/proc\fR will be dropped in a future
3010 release, at which time the top-level directory for a process will be made
3011 world-readable.
3012 .sp
3013 .LP
3014 On SPARC based machines, the types \fBgregset_t\fR and \fBfpregset_t\fR defined
3015 in <\fBsys/regset.h\fR> are similar to but not the same as the types
3016 \fBprgregset_t\fR and \fBprfpregset_t\fR defined in <\fBprocfs.h\fR>.
   1 '\" te
   2 .\" Copyright 1989 AT&T
   3 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
   4 .\" Copyright (c) 2013, Joyent, Inc. All rights reserved.
   5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
   8 .TH PROC 4 "Jun 6, 2016"
   9 .SH NAME
  10 proc \- /proc, the process file system
  11 .SH DESCRIPTION

  12 .LP
  13 \fB/proc\fR is a file system that provides access to the state of each process
  14 and light-weight process (lwp) in the system. The name of each entry in the
  15 \fB/proc\fR directory is a decimal number corresponding to a process-ID. These
  16 entries are themselves subdirectories. Access to process state is provided by
  17 additional files contained within each subdirectory; the hierarchy is described
  18 more completely below. In this document, ``\fB/proc\fR file'' refers to a
  19 non-directory file within the hierarchy rooted at \fB/proc\fR. The owner of
  20 each \fB/proc\fR file and subdirectory is determined by the user-ID of the
  21 process.
  22 .sp
  23 .LP
  24 \fB/proc\fR can be mounted on any mount point, in addition to the standard
  25 \fB/proc\fR mount point, and can be mounted several places at once. Such
  26 additional mounts are allowed in order to facilitate the confinement of
  27 processes to subtrees of the file system via \fBchroot\fR(1M) and yet allow
  28 such processes access to commands like \fBps\fR(1).
  29 .sp
  30 .LP
  31 Standard system calls are used to access \fB/proc\fR files: \fBopen\fR(2),


 156 writing the address space, reading the address-map files, and setting the
 157 target process's registers. There is no restriction on operations applied by a
 158 64-bit process to either a 32-bit or a 64-bit target processes.
 159 .sp
 160 .LP
 161 The format of the contents of any \fB/proc\fR file depends on the data model of
 162 the observer (the controlling process), not on the data model of the target
 163 process. A 64-bit debugger does not have to translate the information it reads
 164 from a \fB/proc\fR file for a 32-bit process from 32-bit format to 64-bit
 165 format. However, it usually has to be aware of the data model of the target
 166 process. The \fBpr_dmodel\fR field of the \fBstatus\fR files indicates the
 167 target process's data model.
 168 .sp
 169 .LP
 170 To help deal with system data structures that are read from 32-bit processes, a
 171 64-bit controlling program can be compiled with the C preprocessor symbol
 172 \fB_SYSCALL32\fR defined before system header files are included. This makes
 173 explicit 32-bit fixed-width data structures (like \fBcstruct stat32\fR) visible
 174 to the 64-bit program. See \fBtypes32.h\fR(3HEAD).
 175 .SH DIRECTORY STRUCTURE

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

 202 .LP
 203 A given directory \fB/proc/\fR\fIpid\fR contains the following entries. A
 204 process can use the invisible alias \fB/proc/self\fR if it wishes to open one
 205 of its own \fB/proc\fR files (invisible in the sense that the name ``self''
 206 does not appear in a directory listing of \fB/proc\fR obtained from
 207 \fBls\fR(1), \fBgetdents\fR(2), or \fBreaddir\fR(3C)).
 208 .SS "contracts"

 209 .LP
 210 A directory containing references to the contracts held by the process. Each
 211 entry is a symlink to the contract's directory under \fB/system/contract\fR.
 212 See \fBcontract\fR(4).
 213 .SS "as"

 214 .LP
 215 Contains the address-space image of the process; it can be opened for both
 216 reading and writing. \fBlseek\fR(2) is used to position the file at the virtual
 217 address of interest and then the address space can be examined or changed
 218 through \fBread\fR(2) or \fBwrite\fR(2) (or by using \fBpread\fR(2) or
 219 \fBpwrite\fR(2) for the combined operation).
 220 .SS "ctl"

 221 .LP
 222 A write-only file to which structured messages are written directing the system
 223 to change some aspect of the process's state or control its behavior in some
 224 way. The seek offset is not relevant when writing to this file. Individual lwps
 225 also have associated \fBlwpctl\fR files in the lwp subdirectories. A control
 226 message may be written either to the process's \fBctl\fR file or to a specific
 227 \fBlwpctl\fR file with operation-specific effects. The effect of a control
 228 message is immediately reflected in the state of the process visible through
 229 appropriate status and information files. The types of control messages are
 230 described in detail later. See \fBCONTROL MESSAGES\fR.
 231 .SS "status"

 232 .LP
 233 Contains state information about the process and the representative lwp. The
 234 file contains a \fBpstatus\fR structure which contains an embedded
 235 \fBlwpstatus\fR structure for the representative lwp, as follows:
 236 .sp
 237 .in +2
 238 .nf
 239 typedef struct pstatus {
 240      int pr_flags;            /* flags (see below) */
 241      int pr_nlwp;             /* number of active lwps in the process */
 242      int pr_nzomb;            /* number of zombie lwps in the process */
 243      pid_tpr_pid;             /* process id */
 244      pid_tpr_ppid;            /* parent process id */
 245      pid_tpr_pgid;            /* process group id */
 246      pid_tpr_sid;             /* session id */
 247      id_t pr_aslwpid;         /* obsolete */
 248      id_t pr_agentid;         /* lwp-id of the agent lwp, if any */
 249      sigset_t pr_sigpend;     /* set of process pending signals */
 250      uintptr_t pr_brkbase;    /* virtual address of the process heap */
 251      size_t pr_brksize;       /* size of the process heap, in bytes */


 840 .fi
 841 .in -2
 842 
 843 The preceding constants are listed in \fB<sys/regset.h>\fR\&.
 844 .RE
 845 
 846 .sp
 847 .LP
 848 \fBpr_fpreg\fR is a structure holding the contents of the floating-point
 849 registers.
 850 .sp
 851 .LP
 852 SPARC registers, both general and floating-point, as seen by a 64-bit
 853 controlling process are the V9 versions of the registers, even if the target
 854 process is a 32-bit (V8) process. V8 registers are a subset of the V9
 855 registers.
 856 .sp
 857 .LP
 858 If the lwp is not stopped, all register values are undefined.
 859 .SS "psinfo"

 860 .LP
 861 Contains miscellaneous information about the process and the representative lwp
 862 needed by the \fBps\fR(1) command. \fBpsinfo\fR remains accessible after a
 863 process becomes a \fIzombie\fR. The file contains a \fBpsinfo\fR structure
 864 which contains an embedded \fBlwpsinfo\fR structure for the representative lwp,
 865 as follows:
 866 .sp
 867 .in +2
 868 .nf
 869 typedef struct psinfo {
 870     int pr_flag;             /* process flags (DEPRECATED: see below) */
 871     int pr_nlwp;             /* number of active lwps in the process */
 872     int pr_nzomb;            /* number of zombie lwps in the process */
 873     pid_t pr_pid;            /* process id */
 874     pid_t pr_ppid;           /* process id of parent */
 875     pid_t pr_pgid;           /* process id of process group leader */
 876     pid_t pr_sid;            /* session id */
 877     uid_t pr_uid;            /* real user id */
 878     uid_t pr_euid;           /* effective user id */
 879     gid_t pr_gid;            /* real group id */


 958 .sp
 959 .LP
 960 Some of the entries in \fBlwpsinfo\fR, such as \fBpr_addr\fR, \fBpr_wchan\fR,
 961 \fBpr_stype\fR, \fBpr_state\fR, and \fBpr_name\fR, refer to internal kernel
 962 data structures and should not be expected to retain their meanings across
 963 different versions of the operating system.
 964 .sp
 965 .LP
 966 \fBlwpsinfo_t.pr_flag\fR is a deprecated interface that should no longer be
 967 used.
 968 .sp
 969 .LP
 970 \fBpr_pctcpu\fR is a 16-bit binary fraction, as described above. It represents
 971 the \fBCPU\fR time used by the specific lwp. On a multi-processor machine, the
 972 maximum value is 1/N, where N is the number of \fBCPU\fRs.
 973 .sp
 974 .LP
 975 \fBpr_contract\fR is the id of the process contract of which the process is a
 976 member. See \fBcontract\fR(4) and \fBprocess\fR(4).
 977 .SS "cred"

 978 .LP
 979 Contains a description of the credentials associated with the process:
 980 .sp
 981 .in +2
 982 .nf
 983 typedef struct prcred {
 984         uid_t pr_euid;      /* effective user id */
 985         uid_t pr_ruid;      /* real user id */
 986         uid_t pr_suid;      /* saved user id (from exec) */
 987         gid_t pr_egid;      /* effective group id */
 988         gid_t pr_rgid;      /* real group id */
 989         gid_t pr_sgid;      /* saved group id (from exec) */
 990         int pr_ngroups;     /* number of supplementary groups */
 991         gid_t pr_groups[1]; /* array of supplementary groups */
 992 } prcred_t;
 993 .fi
 994 .in -2
 995 .sp
 996 
 997 .sp
 998 .LP
 999 The array of associated supplementary groups in \fBpr_groups\fR is of variable
1000 length; the \fBcred\fR file contains all of the supplementary groups.
1001 \fBpr_ngroups\fR indicates the number of supplementary groups. (See also the
1002 \fBPCSCRED\fR and \fBPCSCREDX\fR control operations.)
1003 .SS "priv"

1004 .LP
1005 Contains a description of the privileges associated with the process:
1006 .sp
1007 .in +2
1008 .nf
1009 typedef struct prpriv {
1010      uint32_t        pr_nsets;      /* number of privilege set */
1011      uint32_t        pr_setsize;    /* size of privilege set */
1012      uint32_t        pr_infosize;   /* size of supplementary data */
1013      priv_chunk_t    pr_sets[1];    /* array of sets */
1014 } prpriv_t;
1015 .fi
1016 .in -2
1017 
1018 .sp
1019 .LP
1020 The actual dimension of the \fBpr_sets\fR[] field is
1021 .sp
1022 .in +2
1023 .nf
1024 pr_sets[pr_nsets][pr_setsize]
1025 .fi
1026 .in -2
1027 
1028 .sp
1029 .LP
1030 which is followed by additional information about the process state
1031 \fBpr_infosize\fR bytes in size.
1032 .sp
1033 .LP
1034 The full size of the structure can be computed using
1035 \fBPRIV_PRPRIV_SIZE\fR(\fBprpriv_t *\fR).
1036 .SS "secflags"
1037 .LP
1038 This file contains the security-flags of the process.  It contains a
1039 description of the security flags associated with the process.
1040 .sp
1041 .in +2
1042 .nf
1043 typedef struct prsecflags {
1044         uint32_t pr_version;            /* ABI Versioning of this structure */
1045         secflagset_t pr_effective;      /* Effective flags */
1046         secflagset_t pr_inherit;        /* Inheritable flags */
1047         secflagset_t pr_lower;          /* Lower flags */
1048         secflagset_t pr_upper;          /* Upper flags */
1049 } prsecflags_t;
1050 .in -2
1051 
1052 .sp
1053 .LP
1054 The \fBpr_version\fR field is a version number for the structure, currently
1055 \fBPRSECFLAGS_VERSION_1\fR.
1056 .SS "sigact"
1057 .LP
1058 Contains an array of \fBsigaction structures\fR describing the current
1059 dispositions of all signals associated with the traced process (see
1060 \fBsigaction\fR(2)). Signal numbers are displaced by 1 from array indices, so
1061 that the action for signal number \fIn\fR appears in position \fIn\fR-1 of the
1062 array.
1063 .SS "auxv"

1064 .LP
1065 Contains the initial values of the process's aux vector in an array of
1066 \fBauxv_t\fR structures (see \fB<sys/auxv.h>\fR). The values are those that
1067 were passed by the operating system as startup information to the dynamic
1068 linker.
1069 .SS "ldt"

1070 .LP
1071 This file exists only on x86-based machines. It is non-empty only if the
1072 process has established a local descriptor table (\fBLDT\fR). If non-empty, the
1073 file contains the array of currently active \fBLDT\fR entries in an array of
1074 elements of type \fBstruct ssd\fR, defined in \fB<sys/sysi86.h>\fR, one element
1075 for each active \fBLDT\fR entry.
1076 .SS "map, xmap"

1077 .LP
1078 Contain information about the virtual address map of the process. The map file
1079 contains an array of \fBprmap\fR structures while the xmap file contains an
1080 array of \fBprxmap\fR structures. Each structure describes a contiguous virtual
1081 address region in the address space of the traced process:
1082 .sp
1083 .in +2
1084 .nf
1085 typedef struct prmap {
1086         uintptr_tpr_vaddr;         /* virtual address of mapping */
1087         size_t pr_size;            /* size of mapping in bytes */
1088         char pr_mapname[PRMAPSZ];  /* name in /proc/pid/object */
1089         offset_t pr_offset;        /* offset into mapped object, if any */
1090         int pr_mflags;             /* protection and attribute flags */
1091         int pr_pagesize;           /* pagesize for this mapping in bytes */
1092         int pr_shmid;              /* SysV shared memory identifier */
1093 } prmap_t;
1094 .fi
1095 .in -2
1096 .sp


1224 .sp
1225 .LP
1226 \fBpr_rss\fR is the number of resident pages of memory for the mapping. The
1227 number of resident bytes for the mapping may be determined by multiplying
1228 \fBpr_rss\fR by the page size given by \fBpr_pagesize.\fR
1229 .sp
1230 .LP
1231 \fBpr_anon\fR is the number of resident anonymous memory pages (pages which are
1232 private to this process) for the mapping.
1233 .sp
1234 .LP
1235 \fBpr_locked\fR is the number of locked pages for the mapping. Pages which are
1236 locked are always resident in memory.
1237 .sp
1238 .LP
1239 \fBpr_hatpagesize\fR is the size, in bytes, of the \fBHAT\fR (\fBMMU\fR)
1240 translation for the mapping. \fBpr_hatpagesize\fR may be different than
1241 \fBpr_pagesize.\fR The possible values are hardware architecture specific, and
1242 may change over a mapping's lifetime.
1243 .SS "rmap"

1244 .LP
1245 Contains information about the reserved address ranges of the process. The file
1246 contains an array of \fBprmap\fR structures, as defined above for the \fBmap\fR
1247 file. Each structure describes a contiguous virtual address region in the
1248 address space of the traced process that is reserved by the system in the sense
1249 that an \fBmmap\fR(2) system call that does not specify \fBMAP_FIXED\fR will
1250 not use any part of it for the new mapping. Examples of such reservations
1251 include the address ranges reserved for the process stack and the individual
1252 thread stacks of a multi-threaded process.
1253 .SS "cwd"

1254 .LP
1255 A symbolic link to the process's current working directory. See \fBchdir\fR(2).
1256 A \fBreadlink\fR(2) of \fB/proc/\fIpid\fR/cwd\fR yields a null string. However,
1257 it can be opened, listed, and searched as a directory, and can be the target of
1258 \fBchdir\fR(2).
1259 .SS "root"

1260 .LP
1261 A symbolic link to the process's root directory.
1262 \fB/proc/\fR\fIpid\fR\fB/root\fR can differ from the system root directory if
1263 the process or one of its ancestors executed \fBchroot\fR(2) as super user. It
1264 has the same semantics as \fB/proc/\fR\fIpid\fR\fB/cwd\fR.
1265 .SS "fd"

1266 .LP
1267 A directory containing references to the open files of the process. Each entry
1268 is a decimal number corresponding to an open file descriptor in the process.
1269 .sp
1270 .LP
1271 If an entry refers to a regular file, it can be opened with normal file system
1272 semantics but, to ensure that the controlling process cannot gain greater
1273 access than the controlled process, with no file access modes other than its
1274 read/write open modes in the controlled process. If an entry refers to a
1275 directory, it can be accessed with the same semantics as
1276 \fB/proc/\fIpid\fR/cwd\fR. An attempt to open any other type of entry fails
1277 with \fBEACCES\fR.
1278 .SS "object"

1279 .LP
1280 A directory containing read-only files with names corresponding to the
1281 \fBpr_mapname\fR entries in the \fBmap\fR and \fBpagedata\fR files. Opening
1282 such a file yields a file descriptor for the underlying mapped file associated
1283 with an address-space mapping in the process. The file name \fBa.out\fR appears
1284 in the directory as an alias for the process's executable file.
1285 .sp
1286 .LP
1287 The \fBobject\fR directory makes it possible for a controlling process to gain
1288 access to the object file and any shared libraries (and consequently the symbol
1289 tables) without having to know the actual path names of the executable files.
1290 .SS "path"

1291 .LP
1292 A directory containing symbolic links to files opened by the process. The
1293 directory includes one entry for \fBcwd\fR and \fBroot\fR. The directory also
1294 contains a numerical entry for each file descriptor in the \fBfd\fR directory,
1295 and entries matching those in the \fBobject\fR directory. If this information
1296 is not available, any attempt to read the contents of the symbolic link will
1297 fail. This is most common for files that do not exist in the filesystem
1298 namespace (such as \fBFIFO\fRs and sockets), but can also happen for regular
1299 files. For the file descriptor entries, the path may be different from the one
1300 used by the process to open the file.
1301 .SS "pagedata"

1302 .LP
1303 Opening the page data file enables tracking of address space references and
1304 modifications on a per-page basis.
1305 .sp
1306 .LP
1307 A \fBread\fR(2) of the page data file descriptor returns structured page data
1308 and atomically clears the page data maintained for the file by the system. That
1309 is to say, each read returns data collected since the last read; the first read
1310 returns data collected since the file was opened. When the call completes, the
1311 read buffer contains the following structure as its header and thereafter
1312 contains a number of section header structures and associated byte arrays that
1313 must be accessed by walking linearly through the buffer.
1314 .sp
1315 .in +2
1316 .nf
1317 typedef struct prpageheader {
1318     timestruc_t pr_tstamp; /* real time stamp, time of read() */
1319     ulong_t pr_nmap;       /* number of address space mappings */
1320     ulong_t pr_npage;      /* total number of pages */
1321 } prpageheader_t;


1363 .ad
1364 .RS 17n
1365 page has been modified.
1366 .RE
1367 
1368 .sp
1369 .LP
1370 If the read buffer is not large enough to contain all of the page data, the
1371 read fails with \fBE2BIG\fR and the page data is not cleared. The required size
1372 of the read buffer can be determined through \fBfstat\fR(2). Application of
1373 \fBlseek\fR(2) to the page data file descriptor is ineffective; every read
1374 starts from the beginning of the file. Closing the page data file descriptor
1375 terminates the system overhead associated with collecting the data.
1376 .sp
1377 .LP
1378 More than one page data file descriptor for the same process can be opened, up
1379 to a system-imposed limit per traced process. A read of one does not affect the
1380 data being collected by the system for the others. An open of the page data
1381 file will fail with \fBENOMEM\fR if the system-imposed limit would be exceeded.
1382 .SS "watch"

1383 .LP
1384 Contains an array of \fBprwatch\fR structures, one for each watched area
1385 established by the \fBPCWATCH\fR control operation. See \fBPCWATCH\fR for
1386 details.
1387 .SS "usage"

1388 .LP
1389 Contains process usage information described by a \fBprusage\fR structure which
1390 contains at least the following fields:
1391 .sp
1392 .in +2
1393 .nf
1394 typedef struct prusage {
1395     id_t pr_lwpid;           /* lwp id.  0: process or defunct */
1396     int pr_count;            /* number of contributing lwps */
1397     timestruc_t pr_tstamp;   /* real time stamp, time of read() */
1398     timestruc_t pr_create;   /* process/lwp creation time stamp */
1399     timestruc_t pr_term;     /* process/lwp termination time stamp */
1400     timestruc_t pr_rtime;    /* total lwp real (elapsed) time */
1401     timestruc_t pr_utime;    /* user level CPU time */
1402     timestruc_t pr_stime;    /* system call CPU time */
1403     timestruc_t pr_ttime;    /* other system trap CPU time */
1404     timestruc_t pr_tftime;   /* text page fault sleep time */
1405     timestruc_t pr_dftime;   /* data page fault sleep time */
1406     timestruc_t pr_kftime;   /* kernel page fault sleep time */
1407     timestruc_t pr_ltime;    /* user lock wait sleep time */


1414     ulong_t pr_inblk;        /* input blocks */
1415     ulong_t pr_oublk;        /* output blocks */
1416     ulong_t pr_msnd;         /* messages sent */
1417     ulong_t pr_mrcv;         /* messages received */
1418     ulong_t pr_sigs;         /* signals received */
1419     ulong_t pr_vctx;         /* voluntary context switches */
1420     ulong_t pr_ictx;         /* involuntary context switches */
1421     ulong_t pr_sysc;         /* system calls */
1422     ulong_t pr_ioch;         /* chars read and written */
1423 } prusage_t;
1424 .fi
1425 .in -2
1426 
1427 .sp
1428 .LP
1429 Microstate accounting is now continuously enabled. While this information was
1430 previously an estimate, if microstate accounting were not enabled, the current
1431 information is now never an estimate represents time the process has spent in
1432 various states.
1433 .SS "lstatus"

1434 .LP
1435 Contains a \fBprheader\fR structure followed by an array of \fBlwpstatus\fR
1436 structures, one for each active lwp in the process (see also
1437 \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwpid\fR/\fBlwpstatus\fR, below). The
1438 \fBprheader\fR structure describes the number and size of the array entries
1439 that follow.
1440 .sp
1441 .in +2
1442 .nf
1443 typedef struct prheader {
1444     long pr_nent;        /* number of entries */
1445     size_t pr_entsize;   /* size of each entry, in bytes */
1446 } prheader_t;
1447 .fi
1448 .in -2
1449 
1450 .sp
1451 .LP
1452 The \fBlwpstatus\fR structure may grow by the addition of elements at the end
1453 in future releases of the system. Programs must use \fBpr_entsize\fR in the
1454 file header to index through the array. These comments apply to all \fB/proc\fR
1455 files that include a \fBprheader\fR structure (\fBlpsinfo\fR and \fBlusage\fR,
1456 below).
1457 .SS "lpsinfo"

1458 .LP
1459 Contains a \fBprheader\fR structure followed by an array of \fBlwpsinfo\fR
1460 structures, one for eachactive and zombie lwp in the process. See also
1461 \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwpid\fR/\fBlwpsinfo\fR, below.
1462 .SS "lusage"

1463 .LP
1464 Contains a \fBprheader\fR structure followed by an array of \fBprusage\fR
1465 structures, one for each active lwp in the process, plus an additional element
1466 at the beginning that contains the summation over all defunct lwps (lwps that
1467 once existed but no longer exist in the process). Excluding the \fBpr_lwpid\fR,
1468 \fBpr_tstamp\fR, \fBpr_create\fR, and \fBpr_term\fR entries, the entry-by-entry
1469 summation over all these structures is the definition of the process usage
1470 information obtained from the \fBusage\fR file. (See also
1471 \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwpid\fR/\fBlwpusage\fR, below.)
1472 .SS "lwp"

1473 .LP
1474 A directory containing entries each of which names an active or zombie lwp
1475 within the process. These entries are themselves directories containing
1476 additional files as described below. Only the \fBlwpsinfo\fR file exists in the
1477 directory of a zombie lwp.
1478 .SH STRUCTURE OF \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwpid\fR

1479 .LP
1480 A given directory \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwpid\fR contains the
1481 following entries:
1482 .SS "lwpctl"

1483 .LP
1484 Write-only control file. The messages written to this file affect the specific
1485 lwp rather than the representative lwp, as is the case for the process's
1486 \fBctl\fR file.
1487 .SS "lwpstatus"

1488 .LP
1489 lwp-specific state information. This file contains the \fBlwpstatus\fR
1490 structure for the specific lwp as described above for the representative lwp in
1491 the process's \fBstatus\fR file.
1492 .SS "lwpsinfo"

1493 .LP
1494 lwp-specific \fBps\fR(1) information. This file contains the \fBlwpsinfo\fR
1495 structure for the specific lwp as described above for the representative lwp in
1496 the process's \fBpsinfo\fR file. The \fBlwpsinfo\fR file remains accessible
1497 after an lwp becomes a zombie.
1498 .SS "lwpusage"

1499 .LP
1500 This file contains the \fBprusage\fR structure for the specific lwp as
1501 described above for the process's \fBusage\fR file.
1502 .SS "gwindows"

1503 .LP
1504 This file exists only on SPARC based machines. If it is non-empty, it contains
1505 a \fBgwindows_t\fR structure, defined in \fB<sys/regset.h>\fR, with the values
1506 of those SPARC register windows that could not be stored on the stack when the
1507 lwp stopped. Conditions under which register windows are not stored on the
1508 stack are: the stack pointer refers to nonexistent process memory or the stack
1509 pointer is improperly aligned. If the lwp is not stopped or if there are no
1510 register windows that could not be stored on the stack, the file is empty (the
1511 usual case).
1512 .SS "xregs"

1513 .LP
1514 Extra state registers. The extra state register set is architecture dependent;
1515 this file is empty if the system does not support extra state registers. If the
1516 file is non-empty, it contains an architecture dependent structure of type
1517 \fBprxregset_t\fR, defined in \fB<procfs.h>\fR, with the values of the lwp's
1518 extra state registers. If the lwp is not stopped, all register values are
1519 undefined. See also the \fBPCSXREG\fR control operation, below.
1520 .SS "asrs"

1521 .LP
1522 This file exists only for 64-bit SPARC V9 processes. It contains an
1523 \fBasrset_t\fR structure, defined in <\fBsys/regset.h\fR>, containing the
1524 values of the lwp's platform-dependent ancillary state registers. If the lwp is
1525 not stopped, all register values are undefined. See also the \fBPCSASRS\fR
1526 control operation, below.
1527 .SS "spymaster"

1528 .LP
1529 For an agent lwp (see \fBPCAGENT\fR), this file contains a \fBpsinfo_t\fR
1530 structure that corresponds to the process that created the agent lwp at the
1531 time the agent was created. This structure is identical to that retrieved via
1532 the \fBpsinfo\fR file, with one modification: the \fBpr_time\fR field does not
1533 correspond to the CPU time for the process, but rather to the creation time of
1534 the agent lwp.
1535 .SS "templates"

1536 .LP
1537 A directory which contains references to the active templates for the lwp,
1538 named by the contract type. Changes made to an active template descriptor do
1539 not affect the original template which was activated, though they do affect the
1540 active template. It is not possible to activate an active template descriptor.
1541 See \fBcontract\fR(4).
1542 .SH CONTROL MESSAGES

1543 .LP
1544 Process state changes are effected through messages written to a process's
1545 \fBctl\fR file or to an individual lwp's \fBlwpctl\fR file. All control
1546 messages consist of a \fBlong\fR that names the specific operation followed by
1547 additional data containing the operand, if any.
1548 .sp
1549 .LP
1550 Multiple control messages may be combined in a single \fBwrite\fR(2) (or
1551 \fBwritev\fR(2)) to a control file, but no partial writes are permitted. That
1552 is, each control message, operation code plus operand, if any, must be
1553 presented in its entirety to the \fBwrite\fR(2) and not in pieces over several
1554 system calls. If a control operation fails, no subsequent operations contained
1555 in the same \fBwrite\fR(2) are attempted.
1556 .sp
1557 .LP
1558 Descriptions of the allowable control messages follow. In all cases, writing a
1559 message to a control file for a process or lwp that has terminated elicits the
1560 error \fBENOENT\fR.
1561 .SS "PCSTOP PCDSTOP PCWSTOP PCTWSTOP"

1562 .LP
1563 When applied to the process control file, \fBPCSTOP\fR directs all lwps to stop
1564 and waits for them to stop, \fBPCDSTOP\fR directs all lwps to stop without
1565 waiting for them to stop, and \fBPCWSTOP\fR simply waits for all lwps to stop.
1566 When applied to an lwp control file, \fBPCSTOP\fR directs the specific lwp to
1567 stop and waits until it has stopped, \fBPCDSTOP\fR directs the specific lwp to
1568 stop without waiting for it to stop, and \fBPCWSTOP\fR simply waits for the
1569 specific lwp to stop. When applied to an lwp control file, \fBPCSTOP\fR and
1570 \fBPCWSTOP\fR complete when the lwp stops on an event of interest, immediately
1571 if already so stopped; when applied to the process control file, they complete
1572 when every lwp has stopped either on an event of interest or on a
1573 \fBPR_SUSPENDED\fR stop.
1574 .sp
1575 .LP
1576 \fBPCTWSTOP\fR is identical to \fBPCWSTOP\fR except that it enables the
1577 operation to time out, to avoid waiting forever for a process or lwp that may
1578 never stop on an event of interest. \fBPCTWSTOP\fR takes a \fBlong\fR operand
1579 specifying a number of milliseconds; the wait will terminate successfully after
1580 the specified number of milliseconds even if the process or lwp has not
1581 stopped; a timeout value of zero makes the operation identical to


1590 is traced and again showing \fBPR_JOBCONTROL\fR if the lwp is set running
1591 without clearing the signal.) If \fBPCSTOP\fR or \fBPCDSTOP\fR is applied to an
1592 lwp that is stopped, but not on an event of interest, the stop directive takes
1593 effect when the lwp is restarted by the competing mechanism. At that time, the
1594 lwp enters a \fBPR_REQUESTED\fR stop before executing any user-level code.
1595 .sp
1596 .LP
1597 A write of a control message that blocks is interruptible by a signal so that,
1598 for example, an \fBalarm\fR(2) can be set to avoid waiting forever for a
1599 process or lwp that may never stop on an event of interest. If \fBPCSTOP\fR is
1600 interrupted, the lwp stop directives remain in effect even though the
1601 \fBwrite\fR(2) returns an error. (Use of \fBPCTWSTOP\fR with a non-zero timeout
1602 is recommended over \fBPCWSTOP\fR with an \fBalarm\fR(2).)
1603 .sp
1604 .LP
1605 A system process (indicated by the \fBPR_ISSYS\fR flag) never executes at user
1606 level, has no user-level address space visible through \fB/proc\fR, and cannot
1607 be stopped. Applying one of these operations to a system process or any of its
1608 lwps elicits the error \fBEBUSY\fR.
1609 .SS "PCRUN"

1610 .LP
1611 Make an lwp runnable again after a stop. This operation takes a \fBlong\fR
1612 operand containing zero or more of the following flags:
1613 .sp
1614 .ne 2
1615 .na
1616 \fB\fBPRCSIG\fR\fR
1617 .ad
1618 .RS 12n
1619 clears the current signal, if any (see \fBPCCSIG\fR).
1620 .RE
1621 
1622 .sp
1623 .ne 2
1624 .na
1625 \fB\fBPRCFAULT\fR\fR
1626 .ad
1627 .RS 12n
1628 clears the current fault, if any (see \fBPCCFAULT\fR).
1629 .RE


1670 .sp
1671 .LP
1672 When applied to an lwp control file, \fBPCRUN\fR clears any outstanding
1673 directed-stop request and makes the specific lwp runnable. The operation fails
1674 with \fBEBUSY\fR if the specific lwp is not stopped on an event of interest or
1675 has not been directed to stop or if the agent lwp exists and this is not the
1676 agent lwp (see \fBPCAGENT\fR).
1677 .sp
1678 .LP
1679 When applied to the process control file, a representative lwp is chosen for
1680 the operation as described for \fB/proc/\fR\fIpid\fR\fB/status\fR. The
1681 operation fails with \fBEBUSY\fR if the representative lwp is not stopped on an
1682 event of interest or has not been directed to stop or if the agent lwp exists.
1683 If \fBPRSTEP\fR or \fBPRSTOP\fR was requested, the representative lwp is made
1684 runnable and its outstanding directed-stop request is cleared; otherwise all
1685 outstanding directed-stop requests are cleared and, if it was stopped on an
1686 event of interest, the representative lwp is marked \fBPR_REQUESTED\fR. If, as
1687 a consequence, all lwps are in the \fBPR_REQUESTED\fR or \fBPR_SUSPENDED\fR
1688 stop state, all lwps showing \fBPR_REQUESTED\fR are made runnable.
1689 .SS "PCSTRACE"

1690 .LP
1691 Define a set of signals to be traced in the process. The receipt of one of
1692 these signals by an lwp causes the lwp to stop. The set of signals is defined
1693 using an operand \fBsigset_t\fR contained in the control message. Receipt of
1694 \fBSIGKILL\fR cannot be traced; if specified, it is silently ignored.
1695 .sp
1696 .LP
1697 If a signal that is included in an lwp's held signal set (the signal mask) is
1698 sent to the lwp, the signal is not received and does not cause a stop until it
1699 is removed from the held signal set, either by the lwp itself or by setting the
1700 held signal set with \fBPCSHOLD\fR.
1701 .SS "PCCSIG"

1702 .LP
1703 The current signal, if any, is cleared from the specific or representative lwp.
1704 .SS "PCSSIG"

1705 .LP
1706 The current signal and its associated signal information for the specific or
1707 representative lwp are set according to the contents of the operand
1708 \fBsiginfo\fR structure (see \fB<sys/siginfo.h>\fR). If the specified signal
1709 number is zero, the current signal is cleared. The semantics of this operation
1710 are different from those of \fBkill\fR(2) in that the signal is delivered to
1711 the lwp immediately after execution is resumed (even if it is being blocked)
1712 and an additional \fBPR_SIGNALLED\fR stop does not intervene even if the signal
1713 is traced. Setting the current signal to \fBSIGKILL\fR terminates the process
1714 immediately.
1715 .SS "PCKILL"

1716 .LP
1717 If applied to the process control file, a signal is sent to the process with
1718 semantics identical to those of \fBkill\fR(2). If applied to an lwp control
1719 file, a directed signal is sent to the specific lwp. The signal is named in a
1720 \fBlong\fR operand contained in the message. Sending \fBSIGKILL\fR terminates
1721 the process immediately.
1722 .SS "PCUNKILL"

1723 .LP
1724 A signal is deleted, that is, it is removed from the set of pending signals. If
1725 applied to the process control file, the signal is deleted from the process's
1726 pending signals. If applied to an lwp control file, the signal is deleted from
1727 the lwp's pending signals. The current signal (if any) is unaffected. The
1728 signal is named in a \fBlong\fR operand in the control message. It is an error
1729 (\fBEINVAL\fR) to attempt to delete \fBSIGKILL\fR.
1730 .SS "PCSHOLD"

1731 .LP
1732 Set the set of held signals for the specific or representative lwp (signals
1733 whose delivery will be blocked if sent to the lwp). The set of signals is
1734 specified with a \fBsigset_t\fR operand. \fBSIGKILL\fR and \fBSIGSTOP\fR cannot
1735 be held; if specified, they are silently ignored.
1736 .SS "PCSFAULT"

1737 .LP
1738 Define a set of hardware faults to be traced in the process. On incurring one
1739 of these faults, an lwp stops. The set is defined via the operand
1740 \fBfltset_t\fR structure. Fault names are defined in \fB<sys/fault.h>\fR and
1741 include the following. Some of these may not occur on all processors; there may
1742 be processor-specific faults in addition to these.
1743 .sp
1744 .ne 2
1745 .na
1746 \fB\fBFLTILL\fR\fR
1747 .ad
1748 .RS 13n
1749 illegal instruction
1750 .RE
1751 
1752 .sp
1753 .ne 2
1754 .na
1755 \fB\fBFLTPRIV\fR\fR
1756 .ad


1841 
1842 .sp
1843 .ne 2
1844 .na
1845 \fB\fBFLTPAGE\fR\fR
1846 .ad
1847 .RS 13n
1848 recoverable page fault
1849 .RE
1850 
1851 .sp
1852 .LP
1853 When not traced, a fault normally results in the posting of a signal to the lwp
1854 that incurred the fault. If an lwp stops on a fault, the signal is posted to
1855 the lwp when execution is resumed unless the fault is cleared by \fBPCCFAULT\fR
1856 or by the \fBPRCFAULT\fR option of \fBPCRUN\fR. \fBFLTPAGE\fR is an exception;
1857 no signal is posted. The \fBpr_info\fR field in the \fBlwpstatus\fR structure
1858 identifies the signal to be sent and contains machine-specific information
1859 about the fault.
1860 .SS "PCCFAULT"

1861 .LP
1862 The current fault, if any, is cleared; the associated signal will not be sent
1863 to the specific or representative lwp.
1864 .SS "PCSENTRY PCSEXIT"

1865 .LP
1866 These control operations instruct the process's lwps to stop on entry to or
1867 exit from specified system calls. The set of system calls to be traced is
1868 defined via an operand \fBsysset_t\fR structure.
1869 .sp
1870 .LP
1871 When entry to a system call is being traced, an lwp stops after having begun
1872 the call to the system but before the system call arguments have been fetched
1873 from the lwp. When exit from a system call is being traced, an lwp stops on
1874 completion of the system call just prior to checking for signals and returning
1875 to user level. At this point, all return values have been stored into the lwp's
1876 registers.
1877 .sp
1878 .LP
1879 If an lwp is stopped on entry to a system call (\fBPR_SYSENTRY\fR) or when
1880 sleeping in an interruptible system call (\fBPR_ASLEEP\fR is set), it may be
1881 instructed to go directly to system call exit by specifying the \fBPRSABORT\fR
1882 flag in a \fBPCRUN\fR control message. Unless exit from the system call is
1883 being traced, the lwp returns to user level showing \fBEINTR\fR.
1884 .SS "PCWATCH"

1885 .LP
1886 Set or clear a watched area in the controlled process from a \fBprwatch\fR
1887 structure operand:
1888 .sp
1889 .in +2
1890 .nf
1891 typedef struct prwatch {
1892     uintptr_t pr_vaddr;  /* virtual address of watched area */
1893     size_t pr_size;      /* size of watched area in bytes */
1894     int pr_wflags;       /* watch type flags */
1895 } prwatch_t;
1896 .fi
1897 .in -2
1898 
1899 .sp
1900 .LP
1901 \fBpr_vaddr\fR specifies the virtual address of an area of memory to be watched
1902 in the controlled process. \fBpr_size\fR specifies the size of the area, in
1903 bytes. \fBpr_wflags\fR specifies the type of memory access to be monitored as a
1904 bit-mask of the following flags:


2013 \fBexec\fR(2). \fBPCWATCH\fR fails with \fBEBUSY\fR if applied to the parent of
2014 a \fBvfork\fR(2) before the child has terminated or performed an \fBexec\fR(2).
2015 The \fBPR_VFORKP\fR flag is set in the \fBpstatus\fR structure for such a
2016 parent process.
2017 .sp
2018 .LP
2019 Certain accesses of the traced process's address space by the operating system
2020 are immune to watchpoints. The initial construction of a signal stack frame
2021 when a signal is delivered to an lwp will not trigger a watchpoint trap even if
2022 the new frame covers watched areas of the stack. Once the signal handler is
2023 entered, watchpoint traps occur normally. On SPARC based machines, register
2024 window overflow and underflow will not trigger watchpoint traps, even if the
2025 register window save areas cover watched areas of the stack.
2026 .sp
2027 .LP
2028 Watched areas are not inherited by child processes, even if the traced
2029 process's inherit-on-fork mode, \fBPR_FORK\fR, is set (see \fBPCSET\fR, below).
2030 All watched areas are cancelled when the traced process performs a successful
2031 \fBexec\fR(2).
2032 .SS "PCSET PCUNSET"

2033 .LP
2034 \fBPCSET\fR sets one or more modes of operation for the traced process.
2035 \fBPCUNSET\fR unsets these modes. The modes to be set or unset are specified by
2036 flags in an operand \fBlong\fR in the control message:
2037 .sp
2038 .ne 2
2039 .na
2040 \fB\fBPR_FORK\fR\fR
2041 .ad
2042 .RS 13n
2043 (inherit-on-fork): When set, the process's tracing flags and its
2044 inherit-on-fork mode are inherited by the child of a \fBfork\fR(2),
2045 \fBfork1\fR(2), or \fBvfork\fR(2). When unset, child processes start with all
2046 tracing flags cleared.
2047 .RE
2048 
2049 .sp
2050 .ne 2
2051 .na
2052 \fB\fBPR_RLC\fR\fR


2128 \fB\fBPR_PTRACE\fR\fR
2129 .ad
2130 .RS 13n
2131 (ptrace-compatibility): When set, a stop on an event of interest by the traced
2132 process is reported to the parent of the traced process by \fBwait\fR(3C),
2133 \fBSIGTRAP\fR is sent to the traced process when it executes a successful
2134 \fBexec\fR(2), setuid/setgid flags are not honored for execs performed by the
2135 traced process, any exec of an object file that the traced process cannot read
2136 fails, and the process dies when its parent dies. This mode is deprecated; it
2137 is provided only to allow \fBptrace\fR(3C) to be implemented as a library
2138 function using \fB/proc\fR.
2139 .RE
2140 
2141 .sp
2142 .LP
2143 It is an error (\fBEINVAL\fR) to specify flags other than those described above
2144 or to apply these operations to a system process. The current modes are
2145 reported in the \fBpr_flags\fR field of \fB/proc/\fR\fIpid\fR\fB/status\fR and
2146 \fB/proc/\fR\fIpid\fR\fB/lwp/\fR\fIlwp\fR\fB/lwpstatus\fR.
2147 .SS "PCSREG"

2148 .LP
2149 Set the general registers for the specific or representative lwp according to
2150 the operand \fBprgregset_t\fR structure.
2151 .sp
2152 .LP
2153 On SPARC based systems, only the condition-code bits of the processor-status
2154 register (R_PSR) of SPARC V8 (32-bit) processes can be modified by
2155 \fBPCSREG\fR. Other privileged registers cannot be modified at all.
2156 .sp
2157 .LP
2158 On x86-based systems, only certain bits of the flags register (EFL) can be
2159 modified by \fBPCSREG\fR: these include the condition codes, direction-bit, and
2160 overflow-bit.
2161 .sp
2162 .LP
2163 \fBPCSREG\fR fails with \fBEBUSY\fR if the lwp is not stopped on an event of
2164 interest.
2165 .SS "PCSVADDR"

2166 .LP
2167 Set the address at which execution will resume for the specific or
2168 representative lwp from the operand \fBlong\fR. On SPARC based systems, both
2169 %pc and %npc are set, with %npc set to the instruction following the virtual
2170 address. On x86-based systems, only %eip is set. \fBPCSVADDR\fR fails with
2171 \fBEBUSY\fR if the lwp is not stopped on an event of interest.
2172 .SS "PCSFPREG"

2173 .LP
2174 Set the floating-point registers for the specific or representative lwp
2175 according to the operand \fBprfpregset_t\fR structure. An error (\fBEINVAL\fR)
2176 is returned if the system does not support floating-point operations (no
2177 floating-point hardware and the system does not emulate floating-point machine
2178 instructions). \fBPCSFPREG\fR fails with \fBEBUSY\fR if the lwp is not stopped
2179 on an event of interest.
2180 .SS "PCSXREG"

2181 .LP
2182 Set the extra state registers for the specific or representative lwp according
2183 to the architecture-dependent operand \fBprxregset_t\fR structure. An error
2184 (\fBEINVAL\fR) is returned if the system does not support extra state
2185 registers. \fBPCSXREG\fR fails with \fBEBUSY\fR if the lwp is not stopped on an
2186 event of interest.
2187 .SS "PCSASRS"

2188 .LP
2189 Set the ancillary state registers for the specific or representative lwp
2190 according to the SPARC V9 platform-dependent operand \fBasrset_t\fR structure.
2191 An error (\fBEINVAL\fR) is returned if either the target process or the
2192 controlling process is not a 64-bit SPARC V9 process. Most of the ancillary
2193 state registers are privileged registers that cannot be modified. Only those
2194 that can be modified are set; all others are silently ignored. \fBPCSASRS\fR
2195 fails with \fBEBUSY\fR if the lwp is not stopped on an event of interest.
2196 .SS "PCAGENT"

2197 .LP
2198 Create an agent lwp in the controlled process with register values from the
2199 operand \fBprgregset_t\fR structure (see \fBPCSREG\fR, above). The agent lwp is
2200 created in the stopped state showing \fBPR_REQUESTED\fR and with its held
2201 signal set (the signal mask) having all signals except \fBSIGKILL\fR and
2202 \fBSIGSTOP\fR blocked.
2203 .sp
2204 .LP
2205 The \fBPCAGENT\fR operation fails with \fBEBUSY\fR unless the process is fully
2206 stopped via \fB/proc\fR, that is, unless all of the lwps in the process are
2207 stopped either on events of interest or on \fBPR_SUSPENDED\fR, or are stopped
2208 on \fBPR_JOBCONTROL\fR and have been directed to stop via \fBPCDSTOP\fR.  It
2209 fails with \fBEBUSY\fR if an agent lwp already exists. It fails with
2210 \fBENOMEM\fR if system resources for creating new lwps have been exhausted.
2211 .sp
2212 .LP
2213 Any \fBPCRUN\fR operation applied to the process control file or to the control
2214 file of an lwp other than the agent lwp fails with \fBEBUSY\fR as long as the
2215 agent lwp exists. The agent lwp must be caused to terminate by executing the
2216 \fBSYS_lwp_exit\fR system call trap before the process can be restarted.


2237 .sp
2238 .LP
2239 If the controlling process neglects to force the agent lwp to execute the
2240 \fBSYS_lwp_exit\fR system call (due to either logic error or fatal failure on
2241 the part of the controlling process), the agent lwp will remain in the target
2242 process.  For purposes of being able to debug these otherwise rogue agents,
2243 information as to the creator of the agent lwp is reflected in that lwp's
2244 \fBspymaster\fR file in \fB/proc\fR. Should the target process generate a core
2245 dump with the agent lwp in place, this information will be available via the
2246 \fBNT_SPYMASTER\fR note in the core file (see \fBcore\fR(4)).
2247 .sp
2248 .LP
2249 The agent lwp is not allowed to execute any variation of the \fBSYS_fork\fR or
2250 \fBSYS_exec\fR system call traps. Attempts to do so yield \fBENOTSUP\fR to the
2251 agent lwp.
2252 .sp
2253 .LP
2254 Symbolic constants for system call trap numbers like \fBSYS_lwp_exit\fR and
2255 \fBSYS_lwp_create\fR can be found in the header file <\fBsys/syscall.h\fR>.
2256 .SS "PCREAD PCWRITE"

2257 .LP
2258 Read or write the target process's address space via a \fBpriovec\fR structure
2259 operand:
2260 .sp
2261 .in +2
2262 .nf
2263 typedef struct priovec {
2264     void *pio_base;      /* buffer in controlling process */
2265     size_t pio_len;      /* size of read/write request in bytes */
2266     off_t pio_offset;    /* virtual address in target process */
2267 } priovec_t;
2268 .fi
2269 .in -2
2270 
2271 .sp
2272 .LP
2273 These operations have the same effect as \fBpread\fR(2) and \fBpwrite\fR(2),
2274 respectively, of the target process's address space file. The difference is
2275 that more than one \fBPCREAD\fR or \fBPCWRITE\fR control operation can be
2276 written to the control file at once, and they can be interspersed with other
2277 control operations in a single write to the control file. This is useful, for
2278 example, when planting many breakpoint instructions in the process's address
2279 space, or when stepping over a breakpointed instruction. Unlike \fBpread\fR(2)
2280 and \fBpwrite\fR(2), no provision is made for partial reads or writes; if the
2281 operation cannot be performed completely, it fails with \fBEIO\fR.
2282 .SS "PCNICE"

2283 .LP
2284 The traced process's \fBnice\fR(2) value is incremented by the amount in the
2285 operand \fBlong\fR. Only a process with the {\fBPRIV_PROC_PRIOCNTL\fR}
2286 privilege asserted in its effective set can better a process's priority in this
2287 way, but any user may lower the priority. This operation is not meaningful for
2288 all scheduling classes.
2289 .SS "PCSCRED"

2290 .LP
2291 Set the target process credentials to the values contained in the
2292 \fBprcred_t\fR structure operand (see \fB/proc/\fR\fIpid\fR\fB/cred\fR). The
2293 effective, real, and saved user-IDs and group-IDs of the target process are
2294 set. The target process's supplementary groups are not changed; the
2295 \fBpr_ngroups\fR and \fBpr_groups\fR members of the structure operand are
2296 ignored. Only the privileged processes can perform this operation; for all
2297 others it fails with \fBEPERM\fR.
2298 .SS "PCSCREDX"

2299 .LP
2300 Operates like \fBPCSCRED\fR but also sets the supplementary groups; the length
2301 of the data written with this control operation should be "sizeof
2302 (\fBprcred_t\fR) + sizeof (\fBgid_t)\fR * (#groups - 1)".
2303 .SS "PCSPRIV"

2304 .LP
2305 Set the target process privilege to the values contained in the \fBprpriv_t\fR
2306 operand (see \fB/proc/pid/priv\fR). The effective, permitted, inheritable, and
2307 limit sets are all changed. Privilege flags can also be set. The process is
2308 made privilege aware unless it can relinquish privilege awareness. See
2309 \fBprivileges\fR(5).
2310 .sp
2311 .LP
2312 The limit set of the target process cannot be grown. The other privilege sets
2313 must be subsets of the intersection of the effective set of the calling process
2314 with the new limit set of the target process or subsets of the original values
2315 of the sets in the target process.
2316 .sp
2317 .LP
2318 If any of the above restrictions are not met, \fBEPERM\fR is returned. If the
2319 structure written is improperly formatted, \fBEINVAL\fR is returned.
2320 .SH PROGRAMMING NOTES

2321 .LP
2322 For security reasons, except for the \fBpsinfo\fR, \fBusage\fR, \fBlpsinfo\fR,
2323 \fBlusage\fR, \fBlwpsinfo\fR, and \fBlwpusage\fR files, which are
2324 world-readable, and except for privileged processes, an open of a \fB/proc\fR
2325 file fails unless both the user-ID and group-ID of the caller match those of
2326 the traced process and the process's object file is readable by the caller. The
2327 effective set of the caller is a superset of both the inheritable and the
2328 permitted set of the target process. The limit set of the caller is a superset
2329 of the limit set of the target process. Except for the world-readable files
2330 just mentioned, files corresponding to setuid and setgid processes can be
2331 opened only by the appropriately privileged process.
2332 .sp
2333 .LP
2334 A process that is missing the basic privilege {\fBPRIV_PROC_INFO\fR} cannot see
2335 any processes under \fB/proc\fR that it cannot send a signal to.
2336 .sp
2337 .LP
2338 A process that has {\fBPRIV_PROC_OWNER\fR} asserted in its effective set can
2339 open any file for reading. To manipulate or control a process, the controlling
2340 process must have at least as many privileges in its effective set as the


2359 flags cleared. Any process not currently open for writing via \fB/proc\fR, but
2360 that has left-over tracing flags from a previous open, and that executes a
2361 setuid/setgid or unreadable object file, will not be stopped but will have all
2362 its tracing flags cleared.
2363 .sp
2364 .LP
2365 To wait for one or more of a set of processes or lwps to stop or terminate,
2366 \fB/proc\fR file descriptors (other than those obtained by opening the
2367 \fBcwd\fR or \fBroot\fR directories or by opening files in the \fBfd\fR or
2368 \fBobject\fR directories) can be used in a \fBpoll\fR(2) system call. When
2369 requested and returned, either of the polling events \fBPOLLPRI\fR or
2370 \fBPOLLWRNORM\fR indicates that the process or lwp stopped on an event of
2371 interest. Although they cannot be requested, the polling events \fBPOLLHUP\fR,
2372 \fBPOLLERR\fR, and \fBPOLLNVAL\fR may be returned. \fBPOLLHUP\fR indicates that
2373 the process or lwp has terminated. \fBPOLLERR\fR indicates that the file
2374 descriptor has become invalid. \fBPOLLNVAL\fR is returned immediately if
2375 \fBPOLLPRI\fR or \fBPOLLWRNORM\fR is requested on a file descriptor referring
2376 to a system process (see \fBPCSTOP\fR). The requested events may be empty to
2377 wait simply for termination.
2378 .SH FILES

2379 .ne 2
2380 .na
2381 \fB\fB/proc\fR\fR
2382 .ad
2383 .sp .6
2384 .RS 4n
2385 directory (list of processes)
2386 .RE
2387 
2388 .sp
2389 .ne 2
2390 .na
2391 \fB\fB/proc/\fIpid\fR\fR\fR
2392 .ad
2393 .sp .6
2394 .RS 4n
2395 specific process directory
2396 .RE
2397 
2398 .sp


2759 .ne 2
2760 .na
2761 \fB\fB/proc/\fIpid\fR/lwp/\fIlwpid\fR/asrs\fR\fR
2762 .ad
2763 .sp .6
2764 .RS 4n
2765 ancillary state registers (SPARC V9 only)
2766 .RE
2767 
2768 .sp
2769 .ne 2
2770 .na
2771 \fB\fB/proc/\fIpid\fR/lwp/\fIlwpid\fR/spymaster\fR\fR
2772 .ad
2773 .sp .6
2774 .RS 4n
2775 For an agent LWP, the controlling process
2776 .RE
2777 
2778 .SH SEE ALSO

2779 .LP
2780 \fBls\fR(1), \fBps\fR(1), \fBchroot\fR(1M), \fBalarm\fR(2), \fBbrk\fR(2),
2781 \fBchdir\fR(2), \fBchroot\fR(2), \fBclose\fR(2), \fBcreat\fR(2), \fBdup\fR(2),
2782 \fBexec\fR(2), \fBfcntl\fR(2), \fBfork\fR(2), \fBfork1\fR(2), \fBfstat\fR(2),
2783 \fBgetdents\fR(2), \fBgetustack\fR(2), \fBkill\fR(2), \fBlseek\fR(2),
2784 \fBmmap\fR(2), \fBnice\fR(2), \fBopen\fR(2), \fBpoll\fR(2), \fBpread\fR(2),
2785 \fBptrace\fR(3C), \fBpwrite\fR(2), \fBread\fR(2), \fBreadlink\fR(2),
2786 \fBreadv\fR(2), \fBshmget\fR(2), \fBsigaction\fR(2), \fBsigaltstack\fR(2),
2787 \fBvfork\fR(2), \fBwrite\fR(2), \fBwritev\fR(2), \fB_stack_grow\fR(3C),
2788 \fBreaddir\fR(3C), \fBpthread_create\fR(3C), \fBpthread_join\fR(3C),
2789 \fBsiginfo.h\fR(3HEAD), \fBsignal.h\fR(3HEAD), \fBthr_create\fR(3C),
2790 \fBthr_join\fR(3C), \fBtypes32.h\fR(3HEAD), \fBucontext.h\fR(3HEAD),
2791 \fBwait\fR(3C), \fBcontract\fR(4), \fBcore\fR(4), \fBprocess\fR(4),
2792 \fBlfcompile\fR(5), \fBprivileges\fR(5), \fBsecurity-flags\fR(5)
2793 .SH DIAGNOSTICS

2794 .LP
2795 Errors that can occur in addition to the errors normally associated with file
2796 system access:
2797 .sp
2798 .ne 2
2799 .na
2800 \fB\fBE2BIG\fR\fR
2801 .ad
2802 .RS 13n
2803 Data to be returned in a \fBread\fR(2) of the page data file exceeds the size
2804 of the read buffer provided by the caller.
2805 .RE
2806 
2807 .sp
2808 .ne 2
2809 .na
2810 \fB\fBEACCES\fR\fR
2811 .ad
2812 .RS 13n
2813 An attempt was made to examine a process that ran under a different uid than


2928 .na
2929 \fB\fBEPERM\fR\fR
2930 .ad
2931 .RS 13n
2932 The process that issued the \fBPCSCRED\fR or \fBPCSCREDX\fR operation did not
2933 have the {\fBPRIV_PROC_SETID\fR} privilege asserted in its effective set, or
2934 the process that issued the \fBPCNICE\fR operation did not have the
2935 {\fBPRIV_PROC_PRIOCNTL\fR} in its effective set.
2936 .sp
2937 An attempt was made to control a process of which the E, P, and I privilege
2938 sets were not a subset of the effective set of the controlling process or the
2939 limit set of the controlling process is not a superset of limit set of the
2940 controlled process.
2941 .sp
2942 Any of the uids of the target process are 0 or an attempt was made to change
2943 any of the uids to 0 using PCSCRED and the security policy imposed additional
2944 restrictions. See \fBprivileges\fR(5).
2945 .RE
2946 
2947 .SH NOTES

2948 .LP
2949 Descriptions of structures in this document include only interesting structure
2950 elements, not filler and padding fields, and may show elements out of order for
2951 descriptive clarity. The actual structure definitions are contained in
2952 \fB<procfs.h>\fR\&.
2953 .SH BUGS

2954 .LP
2955 Because the old \fBioctl\fR(2)-based version of \fB/proc\fR is currently
2956 supported for binary compatibility with old applications, the top-level
2957 directory for a process, \fB/proc/\fR\fIpid\fR, is not world-readable, but it
2958 is world-searchable. Thus, anyone can open \fB/proc/\fR\fIpid\fR\fB/psinfo\fR
2959 even though \fBls\fR(1) applied to \fB/proc/\fR\fIpid\fR will fail for anyone
2960 but the owner or an appropriately privileged process. Support for the old
2961 \fBioctl\fR(2)-based version of \fB/proc\fR will be dropped in a future
2962 release, at which time the top-level directory for a process will be made
2963 world-readable.
2964 .sp
2965 .LP
2966 On SPARC based machines, the types \fBgregset_t\fR and \fBfpregset_t\fR defined
2967 in <\fBsys/regset.h\fR> are similar to but not the same as the types
2968 \fBprgregset_t\fR and \fBprfpregset_t\fR defined in <\fBprocfs.h\fR>.