Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ptrace(2)

fcntl(2)

kill(2)

exit(2)

mount(1M)



PROC(4-SysV)        RISC/os Reference Manual         PROC(4-SysV)



NAME
     PROC file system - provide access to processes' address
     space through file system primitives

SYNOPSIS
     #include <sys/fs/prfcntl.h>
     #include <sys/ptrace.h>

DESCRIPTION
     PROC is a filesystem which provides access to processes'
     address spaces through the normal file-related system calls
     (e.g., open(2), read(2), write(2), fcntl(2), etc.).  This
     functionality may be used to examine the text, data or stack
     space of various processes, as well as read their proc
     structures, read their user structures (and write portions
     of same), and manipulate the process by stopping, continu-
     ing, and single-stepping the remote process.  One of the
     design intents of the PROC filesystem is to permit the
     development of more powerful and more efficient debuggers
     and other system-status commands (e.g., ps(1)). PROC may be
     used for primitive inter-process comunication, though it is
     not recommended.

     The filesystem type is called PROC; commands which accept
     filesystem types (e.g., df(1), mount(1M), etc.) will recog-
     nize the string PROC.

     Once the filesystem has been mounted, normal file commands
     may be used on the /proc directory.  You may cd(1) into the
     directory, and do ls(1) commands.  Attempts to create or
     remove files should fail.  Notice that the contents of the
     directory are all 5 digit decimal numbers; these numbers
     correspond to process id's (pids) of active processes on the
     system (see also ps(1)).  If a long listing of the directory
     is done, the size of the file shown is the amount of virtual
     memory the process is currently using.  The owner and group
     of the file correspond to the effective user id and group id
     of the target process.  Normal file protections apply.  The
     create date is meaningless.

     Programs gain access to other processes' address space by
     using open(2).  The name of the file is /proc/NNNNN, where
     NNNNN is the pid of the process you wish to examine.  Lead-
     ing zeroes on the pid are unnecessary when specifying a
     filename, but ls(1) will always print the full 5-digit
     number.  Thus, /proc/123 is the same file as /proc/0123
     which is the same as /proc/00123.  All refer to the process
     whose pid is 123 (decimal).

     Use lseek(2), read(2), and write(2) to examine (or change)
     different parts of the address space.  Note that the only
     parts of the address space which may be examined are those



                         Printed 1/15/91                   Page 1





PROC(4-SysV)        RISC/os Reference Manual         PROC(4-SysV)



     which are currently meaningful in the target process.

     The fcntl(2) commands available are:

     PFCGETPR
          copy the proc structure into the space pointed to by
          arg.

     PFCOPENT
          open the text file associated with the process.  If arg
          is non-zero, it is used as the address whose region is
          examined to determine the appropriate inode, otherwise
          a TEXT or DATA region is used.  Returns a new file
          descriptor.

          errors: ENOENT - the process does not exist, or no
          inode for the text file could be found

     PFCEXCLU
          mark text for exclusive use.  If arg is non-zero, the
          region containing it will be marked, otherwise the TEXT
          region will be marked.

          errors:  ENOENT - the process does not exist, or no
          TEXT region could be found

     PFCSTOP
     PFCWSTOP
          wait for process to stop. PFCSTOP requests that the
          process stop before waiting; PFCWSTOP only waits.  When
          the waited process stops, this call returns success-
          fully if the process has stopped or exited.  If the
          process has not exited, arg is ignored.  If the process
          has exited and arg is non-zero, the exit status is
          copied into the longword pointed to by arg.  If the
          process has exited and arg is zero, -1 is returned and
          errno is set to ENOENT.

          errors:  EINTR - system call was interrupted

     PFCRUN
          make process runnable.

     PFCSMASK
          set signal trace mask.  arg should point to the new
          signal mask.  If the new mask is non-zero, tracing
          begins.  If the new mask is zero, tracing ends.

     PFCGMASK
          get signal trace mask.  The current value of the signal
          mask is copied into the location pointed to by arg.




 Page 2                  Printed 1/15/91





PROC(4-SysV)        RISC/os Reference Manual         PROC(4-SysV)



     PFCCSIG
          clear current signal.

     PFCKILL
          send signal.  arg should point to the signal to be
          sent.

          errors:  BEINVAL - arg points to an invalid signal
          value

     PFCSEXEC
          set the stop on exec flag.

     PFCREXEC
          clear the stop on exec flag.

     PFCNICE
          set nice priority.  arg should point to the new nice
          priority.  Only root can reduce a process' priority.
          The priority cannot be set less than zero.

     PFCSSTEP
          single step process.  Also see ptrace(2).

     PFCGETREGS
     PFCPUTREGS
          The registers may be read into (PFCGETREGS) or written
          from (PFCPUTREGS) memory pointed to by arg.  In this
          case, arg should be a pointer to an array of ints.
          This saves the user from having to hunt through the
          user structure looking for the registers.  Also see
          ptrace(2).

EXAMPLES
     To mount the filesystem, issue the following command:

          # mount    -t    PROC    /proc    /proc

     or add the following line to your /etc/fstab configuration
     file:

          /proc    /proc    PROC rw 0 0

FILES
     /proc/*

ERRORS
     In general, all system calls may return ENOENT, if the pro-
     cess does not exist. fcntl(2) may return EFAULT if arg
     points outside the process' allocated address space.  Other
     errors more specific to particular fcntl(2) calls are listed
     above.



                         Printed 1/15/91                   Page 3





PROC(4-SysV)        RISC/os Reference Manual         PROC(4-SysV)



SEE ALSO
     ptrace(2), fcntl(2), kill(2), exit(2).
     mount(1M) in the System Administrator's Reference Manual.




















































 Page 4                  Printed 1/15/91



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026