man(1) Manual page archive


     PROC(3)                                                   PROC(3)

     NAME
          proc - running processes

     SYNOPSIS
          bind #p /proc

          /proc/n/ctl
          /proc/n/mem
          /proc/n/note
          /proc/n/notepg
          /proc/n/proc
          /proc/n/segment
          /proc/n/status
          /proc/n/text
          ...

     DESCRIPTION
          The proc device serves a two-level directory structure.  The
          first level contains numbered directories corresponding to
          pids of live processes; each such directory contains a set
          of files representing the corresponding process.

          The mem file contains the current memory image of the pro-
          cess.  A read or write at offset o, which must be a valid
          virtual address, accesses bytes from address o up to the end
          of the memory segment containing o. Kernel virtual memory,
          including the kernel stack for the process and saved user
          registers (whose addresses are machine-dependent), can be
          accessed through mem.  Writes are permitted only while the
          process is in the Stopped state and only to user addresses
          or registers.

          The read-only proc file contains the kernel per-process
          structure.  Its main use is to recover the kernel stack and
          program counter for kernel debugging.

          The read-only status file contains a string with eight
          fields, each followed by a space.  The fields are: the pro-
          cess name and user name, each 27 characters left justified;
          the process state, 11 characters left justified; the six
          11-character numbers also held in the process's #c/cputime
          file, and the amount of memory used by the process, except
          its stack, in units of 1024 bytes.

          The text file is a pseudonym for the file from which the
          process was executed; its main use is to recover the symbol
          table of the process.

          Textual messages written to the ctl file control the execu-
          tion of the process.  Some presume that the process is in a

     PROC(3)                                                   PROC(3)

          particular state and return an error if it is not.

          stop      Suspend execution of the process, putting it in
                    the Stopped state.

          start     Resume execution of a Stopped process.

          waitstop  Do not affect the process directly but, like all
                    other messages ending with stop, block the process
                    writing the ctl file until the target process is
                    in the Stopped state or exits.  Also like other
                    stop control messages, if the target process would
                    receive a note while the message is pending, it is
                    instead stopped and the debugging process is
                    resumed.

          startstop Allow a Stopped process to resume, and then do a
                    waitstop action.

          hang      Set a bit in the process so that, when it com-
                    pletes an exec(2) system call, it will enter the
                    Stopped state before returning to user mode.  This
                    bit is inherited across a fork(2).

          kill      Kill the process with extreme prejudice.

          Strings written to the note file will be posted as a note to
          the process (see notify(2)). The note should be less than
          `ERRLEN-1' characters long; the last character is reserved
          for a terminating NUL character.  A read of at least
          `ERRLEN' characters will retrieve the oldest note posted to
          the process and prevent its delivery to the process.  The
          notepg file is similar, but the note will be delivered to
          all the processes in the target process's note group (see
          fork(2)). The notepg file is write-only.

     FILES
          /sys/src/9/*/mem.h
          /sys/src/9/*/dat.h

     SEE ALSO
          cons(3)