PROC(4) PROC(4) NAME proc - process file system SYNOPSIS #include <sys/types.h> #include <sys/proc.h> #include <sys/pioctl.h> DESCRIPTION Proc is a file system that contains memory images of each running process in the system. The name of each entry in the directory is the process id of the subject process, expressed in decimal with optional leading zeros. Each pro- cess file is owned by the userid of the subject process. The file mode includes read and write permission for the owner if that userid has read access to the associated text file; all other permission bits are zero. The file size is the sum of the sizes of virtual memory segments in the sub- ject process. The subject process is unaffected, except that setuid bits will be ignored if it does an exec(2). (Setuid bits are also ignored if the execing process has traced signals, or stops on exec; see the description of PIOCSMASK and PIOCSEXEC below.) Data may be transferred from or to any locations in the subject's address space through lseek(2), read(2), and write. The text segment begins at address 0; the data segment starts above the text. The user area extends down- ward below address 0x80000000, and is UPAGES*NBPG bytes long (see the header files listed below); the stack segment grows downward below the user area. The text, data, and stack sizes may be determined from the process's `proc' structure (see PIOCGETPR below). It is an error to access addresses between data and stack. No read or write may span a segment boundary; in the user area only the locations of saved user registers are writable. Ioctl(2) calls control the subject process. The third argu- ment usually points to an integer. The ioctl codes are: PIOCSTOP Send signal SIGSTOP to the process, and wait for it to enter the stopped state. PIOCWSTOP Wait for the process to stop. PIOCRUN Make the process runnable again after a stop. PIOCSMASK Define a set of signals to be traced. The pro- cess will stop when it receives any signal whose number, as given in signal(2), corresponds to a 1-bit in the given integer, with the least sig- nificant bit counted as 1. The traced state and PROC(4) PROC(4) mask bits are inherited by the child of a fork(2). When the process file is closed, the mask becomes zero, but the traced state persists. PIOCSEXEC Cause the process to stop after exec(2). This condition is inherited across fork(2) and per- sists when the process file is closed. PIOCREXEC Reverse the effect of PIOCSEXEC. PIOCCSIG Clear the subject's currently pending signal (if any). PIOCKILL Set the subject's currently pending signal to a given number. PIOCOPENT Return a read-only file descriptor for the sub- ject process's text file. (Thus a debugger can find the symbol table without knowing the name of the text file.) PIOCNICE Increment the priority of the subject process by a given amount as if by nice(2). PIOCGETPR Copy the subject's proc structure (see <sys/proc.h>) from the kernel process table into an area pointed to the third argument. (This information, which resides in system space, is not accessible via a normal read.) Any system call is guaranteed to be atomic with respect to the subject process, but nothing prevents more than one pro- cess from opening and controlling the same subject. The following header files are useful in analyzing proc files: <signal.h> list of signal numbers <sys/param.h> size parameters <sys/types.h> special system types <sys/user.h> user structure <sys/proc.h> proc structure <sys/reg.h> locations of saved user registers <sys/pioctl.h> ioctl codes for proc files FILES SEE ALSO adb(1), ps(1), hang(1), fmount(2), signal(2), mount(8), pi(9.1) DIAGNOSTICS These errors can occur in addition to the errors normally associated with the file system; see intro(2): ENOENT The subject process has exited. EIO The subject process has attempted I/O at an illegal address. EBUSY The subject is in the midst of changing virtual mem- ory attributes, or has pages locked for physical PROC(4) PROC(4) I/O. ENOSPC A write has been attempted on a shared text segment and there is no room on the swap space to make a copy. EPERM A non-super-user has attempted to better the subject's priority with PIOCNICE. BUGS A process must be swapped in for reading and writing (but not ioctl); this may cause a noticeable delay. The spectrum of states which result in EBUSY is too conser- vative. A process loaded from a text file with magic number 0407 does not have as a read-only text segment; in this (presum- ably rare) case PIOCOPENT does not work, and the process is accessible even if the text file is read-only. The interface involves too many VAX-specific magic numbers.