Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open(2)

ptrace(2)

sigaction(2)

signal(2)

proc(4)



proc(4)                          UNIX System V                          proc(4)


NAME
      /proc - process file system

DESCRIPTION
      /proc is a file system that provides access to the image of each active
      process in the system.  The name of each entry in the /proc directory is
      a decimal number corresponding to the process ID.  The owner of each
      ``file'' is determined by the process's user-ID.

      Standard system call interfaces are used to access /proc files:  open,
      close, read, write, and ioctl.  An open for reading and writing enables
      process control; a read-only open allows inspection but not control.  As
      with ordinary files, more than one process can open the same /proc file
      at the same time.  Exclusive open is provided to allow controlling
      processes to avoid collisions:  an open for writing that specifies O_EXCL
      fails if the file is already open for writing; if such an exclusive open
      succeeds, subsequent attempts to open the file for writing, with or
      without the O_EXCL flag, fail until the exclusively-opened file
      descriptor is closed.  (Exception: a super-user open that does not
      specify O_EXCL succeeds even if the file is exclusively opened.)  There
      can be any number of read-only opens, even when an exclusive write open
      is in effect on the file.

      Data may be transferred from or to any locations in the traced process's
      address space by applying lseek to position the file at the virtual
      address of interest followed by read or write.  The PIOCMAP operation can
      be applied to determine the accessible areas (mappings) of the address
      space.  A contiguous area of the address space may appear as multiple
      mappings due to varying read/write/execute permissions.  I/O transfers
      may span contiguous mappings.  An I/O request extending into an unmapped
      area is truncated at the boundary.

      Information and control operations are provided through ioctl.  These
      have the form:

            #include <sys/types.h>
            #include <sys/signal.h>
            #include <sys/fault.h>
            #include <sys/syscall.h>
            #include <sys/procfs.h>
            void *p;
            retval = ioctl(fildes, code, p);

      The argument p is a generic pointer whose type depends on the specific
      ioctl code.  Where not specifically mentioned below, its value should be
      zero.  sys/procfs.h contains definitions of ioctl codes and data
      structures used by the operations.  Certain operations can be performed
      only if the process file is open for writing; these include all
      operations that affect process control.





10/89                                                                    Page 1







proc(4)                          UNIX System V                          proc(4)


      Process information and control operations involve the use of sets of
      flags.  The set types sigset_t, fltset_t, and sysset_t correspond,
      respectively, to signal, fault, and system call enumerations defined in
      sys/signal.h, sys/fault.h, and sys/syscall.h.  Each set type is large
      enough to hold flags for its own enumeration.  Although they are of
      different sizes, they have a common structure and can be manipulated by
      these macros:

            prfillset(&set);            /* turn on all flags in set */
            premptyset(&set);           /* turn off all flags in set */
            praddset(&set, flag);       /* turn on the specified flag */
            prdelset(&set, flag);       /* turn off the specified flag */
            r = prismember(&set, flag); /* != 0 iff flag is turned on */

      One of prfillset or premptyset must be used to initialize set before it
      is used in any other operation.  flag must be a member of the enumeration
      corresponding to set.

      The allowable ioctl codes follow.  Those requiring write access are
      marked with an asterisk (*).  Except where noted, an ioctl to a process
      that has terminated elicits the error ENOENT.

   PIOCSTATUS
      This returns status information for the process; p is a pointer to a
      prstatus structure:

      typedef struct prstatus {
        long      pr_flags;     /* Process flags */
        short     pr_why;       /* Reason for process stop (if stopped) */
        short     pr_what;      /* More detailed reason */
        struct siginfo pr_info; /* Info associated with signal or fault */
        short     pr_cursig;    /* Current signal */
        sigset_t  pr_sigpend;   /* Set of other pending signals */
        sigset_t  pr_sighold;   /* Set of held signals */
        struct sigaltstack pr_altstack; /* Alternate signal stack info */
        struct sigaction pr_action; /* Signal action for current signal */
        pid_t     pr_pid;       /* Process id */
        pid_t     pr_ppid;      /* Parent process id */
        pid_t     pr_pgrp;      /* Process group id */
        pid_t     pr_sid;       /* Session id */
        timestruc_t pr_utime;   /* Process user cpu time */
        timestruc_t pr_stime;   /* Process system cpu time */
        timestruc_t pr_cutime;  /* Sum of children's user times */
        timestruc_t pr_cstime;  /* Sum of children's system times */
        char      pr_clname[8]; /* Scheduling class name */
        long      pr_filler[20];/* Filler area for future expansion */
        long      pr_instr;     /* Current instruction */
        gregset_t pr_reg;       /* General registers */
      } prstatus_t;





Page 2                                                                    10/89







proc(4)                          UNIX System V                          proc(4)


      pr_flags is a bit-mask holding these flags:

            PR_STOPPED    process is stopped
            PR_ISTOP      process is stopped on an event of interest (see
                          PIOCSTOP)
            PR_DSTOP      process has a stop directive in effect (see PIOCSTOP)
            PR_ASLEEP     process is in an interruptible sleep within a system
                          call
            PR_FORK       process has its inherit-on-fork flag set (see
                          PIOCSFORK)
            PR_RLC        process has its run-on-last-close flag set (see
                          PIOCSRLC)
            PR_PTRACE     process is being traced via ptrace
            PR_PCINVAL    process program counter refers to an invalid address
            PR_ISSYS      process is a system process (see PIOCSTOP)

      pr_why and pr_what together describe, for a stopped process, the reason
      that the process is stopped.  Possible values of pr_why are:

            PR_REQUESTED indicates that the process stopped because PIOCSTOP
            was applied; pr_what is unused in this case.

            PR_SIGNALLED indicates that the process stopped on receipt of a
            signal (see PIOCSTRACE); pr_what holds the signal number that
            caused the stop (for a newly-stopped process, the same value is in
            pr_cursig).

            PR_FAULTED indicates that the process stopped on incurring a
            hardware fault (see PIOCSFAULT); pr_what holds the fault number
            that caused the stop.

            PR_SYSENTRY and PR_SYSEXIT indicate a stop on entry to or exit from
            a system call (see PIOCSENTRY and PIOCSEXIT); pr_what holds the
            system call number.

            PR_JOBCONTROL indicates that the process stopped due to the default
            action of a job control stop signal (see sigaction); pr_what holds
            the stopping signal number.

      pr_info, when the process is in a PR_SIGNALLED or PR_FAULTED stop,
      contains additional information pertinent to the particular signal or
      fault (see sys/siginfo.h).

      pr_cursig names the current signal-that is, the next signal to be
      delivered to the process.  pr_sigpend identifies any other pending
      signals.  pr_sighold identifies those signals whose delivery is being
      delayed if sent to the process.

      pr_altstack contains the alternate signal stack information for the
      process (see sigaltstack).  pr_action contains the signal action
      information pertaining to the current signal (see sigaction); it is
      undefined if pr_cursig is zero.


10/89                                                                    Page 3







proc(4)                          UNIX System V                          proc(4)


      pr_pid, pr_ppid, pr_pgrp, and pr_sid are, respectively, the process ID,
      the ID of the process's parent, the process's process group ID, and the
      process's session ID.

      pr_utime, pr_stime, pr_cutime, and pr_cstime are, respectively, the user
      CPU and system CPU time consumed by the process, and the cumulative user
      CPU and system CPU time consumed by the process's children, in seconds
      and nanoseconds.

      pr_clname contains the name of the process's scheduling class.

      The pr_filler area is reserved for future use.

      pr_instr contains the machine instruction to which the program counter
      refers.  The amount of data retrieved from the process is machine-
      dependent; on the 3B2, it is a single byte.  In general, the size is that
      of the machine's smallest instruction.  If the program counter refers to
      an invalid address, PR_PCINVAL is set and pr_instr is undefined.

      pr_reg is an array holding the contents of the general registers.  On the
      3B2 the predefined constants R_R0, R_R1, ... R_R8, R_FP, R_AP, R_PS,
      R_SP, and R_PC can be used as indices to refer to the corresponding
      registers.

   PIOCSTOP*, PIOCWSTOP
      PIOCSTOP directs the process to stop and waits until it has stopped;
      PIOCWSTOP simply waits for the process to stop.  These operations
      complete when the process stops on an event of interest, immediately if
      already so stopped.  If p is non-zero it points to an instance of
      prstatus_t to be filled with status information for the stopped process.

      An ``event of interest'' is either a PR_REQUESTED stop or a stop that has
      been specified in the process's tracing flags (set by PIOCSTRACE,
      PIOCSFAULT, PIOCSENTRY, and PIOCSEXIT).  A PR_JOBCONTROL stop is
      specifically not an event of interest.  (A process may stop twice due to
      a stop signal, first showing PR_SIGNALLED if the signal is traced and
      again showing PR_JOBCONTROL if the process is set running without
      clearing the signal.)  If the process is controlled by ptrace, it comes
      to a PR_SIGNALLED stop on receipt of any signal; this is an event of
      interest only if the signal is in the traced signal set.  If PIOCSTOP is
      applied to a process that is stopped, but not on an event of interest,
      the stop directive takes effect when the process is restarted by the
      competing mechanism; at that time the process enters a PR_REQUESTED stop
      before executing any user-level code.

      ioctls are interruptible by signals so that, for example, an alarm can be
      set to avoid waiting forever for a process that may never stop on an
      event of interest.  If PIOCSTOP is interrupted, the stop directive
      remains in effect even though the ioctl returns an error.





Page 4                                                                    10/89







proc(4)                          UNIX System V                          proc(4)


      A system process (indicated by the PR_ISSYS flag) never executes at user
      level, has no user-level address space visible through /proc, and cannot
      be stopped.  Applying PIOCSTOP or PIOCWSTOP to a system process elicits
      the error EBUSY.

   PIOCRUN*
      The traced process is made runnable again after a stop.  If p is non-zero
      it points to a prrun structure describing additional actions to be
      performed:

      typedef struct prrun {
        long      pr_flags;     /* Flags */
        sigset_t  pr_trace;     /* Set of signals to be traced */
        sigset_t  pr_sighold;   /* Set of signals to be held */
        fltset_t  pr_fault;     /* Set of faults to be traced */
        caddr_t   pr_vaddr;     /* Virtual address at which to resume */
        long      pr_filler[8]; /* Filler area for future expansion */
      } prrun_t;

      pr_flags is a bit-mask describing optional actions; the remainder of the
      entries are meaningful only if the appropriate bits are set in pr_flags.
      pr_filler is reserved for future use; this area must be filled with zeros
      by the user's program.  Flag definitions:

            PRCSIG clears the current signal, if any (see PIOCSSIG).

            PRCFAULT clears the current fault, if any (see PIOCCFAULT).

            PRSTRACE sets the traced signal set to pr_trace (see PIOCSTRACE).

            PRSHOLD sets the held signal set to pr_sighold (see PIOCSHOLD).

            PRSFAULT sets the traced fault set to pr_fault (see PIOCSFAULT).

            PRSVADDR sets the address at which execution resumes to pr_vaddr.

            PRSTEP directs the process to single-step-i.e., to run and to
            execute a single machine instruction.  On completion of the
            instruction, a hardware trace trap occurs.  If FLTTRACE is being
            traced, the process stops, otherwise it is sent SIGTRAP; if SIGTRAP
            is being traced and not held, the process stops.  This operation
            requires hardware support and may not be implemented on all
            processors.

            PRSABORT is meaningful only if the process is in a PR_SYSENTRY stop
            or is marked PR_ASLEEP; it instructs the process to abort execution
            of the system call (see PIOCSENTRY, PIOCSEXIT).

            PRSTOP directs the process to stop again as soon as possible after
            resuming execution (see PIOCSTOP).  In particular if the process is
            stopped on PR_SIGNALLED or PR_FAULTED, the next stop will show
            PR_REQUESTED, no other stop will have intervened, and the process


10/89                                                                    Page 5







proc(4)                          UNIX System V                          proc(4)


            will not have executed any user-level code.

      PIOCRUN fails (EBUSY) if applied to a process that is not stopped on an
      event of interest.  Once PIOCRUN has been applied, the process is no
      longer stopped on an event of interest even if, due to a competing
      mechanism, it remains stopped.

   PIOCSTRACE*
      This defines a set of signals to be traced:  the receipt of one of these
      signals causes the traced process to stop.  The set of signals is defined
      via an instance of sigset_t addressed by p.  Receipt of SIGKILL cannot be
      traced.

      If a signal that is included in the held signal set is sent to the traced
      process, the signal is not received and does not cause a process stop
      until it is removed from the held signal set, either by the process
      itself or by setting the held signal set with PIOCSHOLD or the PRSHOLD
      option of PIOCRUN.

   PIOCGTRACE
      The current traced signal set is returned in an instance of sigset_t
      addressed by p.

   PIOCSSIG*
      The current signal and its associated signal information are set
      according to the contents of the siginfo structure addressed by p (see
      sys/siginfo.h).  If the specified signal number is zero or if p is zero,
      the current signal is cleared.  The semantics of this operation are
      different from those of kill or PIOCKILL in that the signal is delivered
      to the process immediately after execution is resumed (even if it is
      being held) and an additional PR_SIGNALLED stop does not intervene even
      if the signal is traced.  Setting the current signal to SIGKILL
      terminates the process immediately, even if it is stopped.

   PIOCKILL*
      A signal is sent to the process with semantics identical to those of
      kill; p points to an int naming the signal.  Sending SIGKILL terminates
      the process immediately.

   PIOCUNKILL*
      A signal is deleted, i.e. it is removed from the set of pending signals;
      the current signal (if any) is unaffected.  p points to an int naming the
      signal.  It is an error to attempt to delete SIGKILL.

   PIOCGHOLD, PIOCSHOLD*
      PIOCGHOLD returns the set of held signals (signals whose delivery will be
      delayed if sent to the process) in an instance of sigset_t addressed by
      p.  PIOCSHOLD correspondingly sets the held signal set but does not allow
      SIGKILL or SIGSTOP to be held.





Page 6                                                                    10/89







proc(4)                          UNIX System V                          proc(4)


   PIOCMAXSIG, PIOCACTION
      These operations provide information about the signal actions associated
      with the traced process (see sigaction).  PIOCMAXSIG returns, in the int
      addressed by p, the maximum signal number understood by the system.  This
      can be used to allocate storage for use with the PIOCACTION operation,
      which returns the traced process's signal actions in an array of
      sigaction structures addressed by p.  Signal numbers are displaced by 1
      from array indices, so that the action for signal number n appears in
      position n-1 of the array.

   PIOCSFAULT*
      This defines a set of hardware faults to be traced:  on incurring one of
      these faults the traced process stops.  The set is defined via an
      instance of fltset_t addressed by p.  Fault names are defined in
      sys/fault.h and include the following.  Some of these may not occur on
      all processors; there may be processor-specific faults in addition to
      these.

            FLTILL        illegal instruction
            FLTPRIV       privileged instruction
            FLTBPT        breakpoint trap
            FLTTRACE      trace trap
            FLTACCESS     memory access fault
            FLTBOUNDS     memory bounds violation
            FLTIOVF       integer overflow
            FLTIZDIV      integer zero divide
            FLTFPE        floating-point exception
            FLTSTACK      unrecoverable stack fault
            FLTPAGE       recoverable page fault

      When not traced, a fault normally results in the posting of a signal to
      the process that incurred the fault.  If the process stops on a fault,
      the signal is posted to the process when execution is resumed unless the
      fault is cleared by PIOCCFAULT or by the PRCFAULT option of PIOCRUN.
      FLTPAGE is an exception; no signal is posted.  There may be additional
      processor-specific faults like this.  pr_info in the prstatus structure
      identifies the signal to be sent and contains machine-specific
      information about the fault.

   PIOCGFAULT
      The current traced fault set is returned in an instance of fltset_t
      addressed by p.

   PIOCCFAULT*
      The current fault (if any) is cleared; the associated signal is not sent
      to the process.

   PIOCSENTRY*, PIOCSEXIT*
      These operations instruct the process to stop on entry to or exit from
      specified system calls.  The set of syscalls to be traced is defined via
      an instance of sysset_t addressed by p.



10/89                                                                    Page 7







proc(4)                          UNIX System V                          proc(4)


      When entry to a system call is being traced, the traced process stops
      after having begun the call to the system but before the system call
      arguments have been fetched from the process.  When exit from a system
      call is being traced, the traced process stops on completion of the
      system call just prior to checking for signals and returning to user
      level.  At this point all return values have been stored into the traced
      process's saved registers.

      If the traced process is stopped on entry to a system call (PR_SYSENTRY)
      or when sleeping in an interruptible system call (PR_ASLEEP is set), it
      may be instructed to go directly to system call exit by specifying the
      PRSABORT flag in a PIOCRUN request.  Unless exit from the system call is
      being traced the process returns to user level showing error EINTR.

   PIOCGENTRY, PIOCGEXIT
      These return the current traced system call entry or exit set in an
      instance of sysset_t addressed by p.

   PIOCSFORK*, PIOCRFORK*
      PIOCSFORK sets the inherit-on-fork flag in the traced process:  the
      process's tracing flags are inherited by the child of a fork.  PIOCRFORK
      turns this flag off:  child processes start with all tracing flags
      cleared.

   PIOCSRLC*, PIOCRRLC*
      PIOCSRLC sets the run-on-last-close flag in the traced process:  when the
      last writable /proc file descriptor referring to the traced process is
      closed, all of the process's tracing flags are cleared, any outstanding
      stop directive is canceled, and if the process is stopped, it is set
      running as though PIOCRUN had been applied to it.  PIOCRRLC turns this
      flag off:  the process's tracing flags are retained and the process is
      not set running when the process file is closed.

   PIOCGREG, PIOCSREG*
      These operations respectively get and set the saved process registers
      into or out of an array addressed by p; the array has type gregset_t.
      Register contents are accessible using a set of predefined indices (see
      PIOCSTATUS).  Only certain bits of the processor-status word (PSW) can be
      modified by PIOCSREG; on the 3B2 these include the condition-code bits
      and the trace-enable bit.  Other privileged registers cannot be modified
      at all.  PIOCSREG fails (EBUSY) if applied to a process that is not
      stopped on an event of interest.

   PIOCGFPREG, PIOCSFPREG*
      These operations respectively get and set the saved process floating-
      point registers into or out of a structure addressed by p; the structure
      has type fpregset_t.  An error (EINVAL) is returned if there is no
      floating-point hardware on the machine.  PIOCSFPREG fails (EBUSY) if
      applied to a process that is not stopped on an event of interest.





Page 8                                                                    10/89







proc(4)                          UNIX System V                          proc(4)


   PIOCNICE*
      The traced process's nice priority is incremented by the amount contained
      in the int addressed by p.  Only the super-user may better a process's
      priority in this way, but any user may make the priority worse.

   PIOCPSINFO
      This returns miscellaneous process information such as that reported by
      ps(1).  p is a pointer to a prpsinfo structure containing at least the
      following fields:

      typedef struct prpsinfo {
        char    pr_state;  /* numeric process state (see pr_sname) */
        char    pr_sname;  /* printable character representing pr_state */
        char    pr_zomb;   /* !=0: process terminated but not waited for */
        char    pr_nice;   /* nice for cpu usage */
        u_long  pr_flag;   /* process flags */
        uid_t   pr_uid;    /* real user id */
        gid_t   pr_gid;    /* real group id */
        pid_t   pr_pid;    /* unique process id */
        pid_t   pr_ppid;   /* process id of parent */
        pid_t   pr_pgrp;   /* pid of process group leader */
        pid_t   pr_sid;    /* session id */
        caddr_t pr_addr;   /* physical address of process */
        long    pr_size;   /* size of process image in pages */
        long    pr_rssize; /* resident set size in pages */
        caddr_t pr_wchan;  /* wait addr for sleeping process */
        timestruc_t pr_start;  /* process start time, sec+nsec since epoch */
        timestruc_t pr_time;   /* usr+sys cpu time for this process */
        long    pr_pri;    /* priority, high value is high priority */
        char    pr_oldpri; /* pre-SVR4, low value is high priority */
        char    pr_cpu;    /* pre-SVR4, cpu usage for scheduling */
        dev_t   pr_ttydev; /* controlling tty device (PRNODEV if none) */
        char    pr_clname[8];  /* Scheduling class name */
        char    pr_fname[16];  /* last component of execed pathname */
        char    pr_psargs[PRARGSZ]; /* initial characters of arg list */
        long    pr_filler[20]; /* for future expansion */
      } prpsinfo_t;

      Some of the entries in prpsinfo, such as pr_state and pr_flag, are
      system-specific and should not be expected to retain their meanings
      across different versions of the operating system.  pr_addr is a vestige
      of the past and has no real meaning in current systems.

      PIOCPSINFO can be applied to a zombie process (one that has terminated
      but whose parent has not yet performed a wait on it).

   PIOCNMAP, PIOCMAP
      These operations provide information about the memory mappings (virtual
      address ranges) associated with the traced process.  PIOCNMAP returns, in
      the int addressed by p, the number of mappings that are currently active.
      This can be used to allocate storage for use with the PIOCMAP operation,
      which returns the list of currently active mappings.  For PIOCMAP, p


10/89                                                                    Page 9







proc(4)                          UNIX System V                          proc(4)


      addresses an array of elements of type prmap_t; one array element (one
      structure) is returned for each mapping, plus an additional element
      containing all zeros to mark the end of the list.

      typedef struct prmap {
        caddr_t  pr_vaddr;      /* Virtual address base */
        u_long   pr_size;       /* Size of mapping in bytes */
        off_t    pr_off;        /* Offset into mapped object, if any */
        long     pr_mflags;     /* Protection and attribute flags */
        long     pr_filler[4];  /* Filler for future expansion */
      } prmap_t;

      pr_vaddr is the virtual address base (the lower limit) of the mapping
      within the traced process and pr_size is its size in bytes.  pr_off is
      the offset within the mapped object (if any) to which the address base is
      mapped.

      pr_mflags is a bit-mask of protection and attribute flags:

            MA_READ       mapping is readable by the traced process
            MA_WRITE      mapping is writable by the traced process
            MA_EXEC       mapping is executable by the traced process
            MA_SHARED     mapping changes are shared by the mapped object
            MA_BREAK      mapping is grown by the brk system call
            MA_STACK      mapping is grown automatically on stack faults

   PIOCOPENM
      The return value retval provides a read-only file descriptor for a mapped
      object associated with the traced process.  If p is zero the traced
      process's execed file (its a.out file) is found.  This enables a debugger
      to find the object file symbol table without having to know the path name
      of the executable file.  If p is non-zero it points to a caddr_t
      containing a virtual address within the traced process and the mapped
      object, if any, associated with that address is found; this can be used
      to get a file descriptor for a shared library that is attached to the
      process.  On error (invalid address or no mapped object for the
      designated address), -1 is returned.

   PIOCCRED
      Fetch the set of credentials associated with the process.  p points to an
      instance of prcred_t, which is filled by the operation:

            typedef struct prcred {
                uid_t    pr_euid;     /* Effective user id */
                uid_t    pr_ruid;     /* Real user id */
                uid_t    pr_suid;     /* Saved user id (from exec) */
                uid_t    pr_egid;     /* Effective group id */
                uid_t    pr_rgid;     /* Real group id */
                uid_t    pr_sgid;     /* Saved group id (from exec) */
                u_int    pr_ngroups;  /* Number of supplementary groups */
            } prcred_t;



Page 10                                                                   10/89







proc(4)                          UNIX System V                          proc(4)


   PIOCGROUPS
      Fetch the set of supplementary group IDs associated with the process.  p
      points to an array of elements of type uid_t, which will be filled by the
      operation.  PIOCCRED can be applied beforehand to determine the number of
      groups (pr_ngroups) that will be returned and the amount of storage that
      should be allocated to hold them.

   PIOCGETPR, PIOCGETU
      These operations copy, respectively, the traced process's proc structure
      and user area into the buffer addressed by p.  They are provided for
      completeness but it should be unnecessary to access either of these
      structures directly since relevant status information is available
      through other control operations.  Their use is discouraged because a
      program making use of them is tied to a particular version of the
      operating system.

      PIOCGETPR can be applied to a zombie process (see PIOCPSINFO).

NOTES
      Each operation (ioctl or I/O) is guaranteed to be atomic with respect to
      the traced process, except when applied to a system process.

      For security reasons, except for the super-user, an open of a /proc file
      fails unless both the user-ID and group-ID of the caller match those of
      the traced process and the process's object file is readable by the
      caller.  Files corresponding to setuid and setgid processes can be opened
      only by the super-user.  Even if held by the super-user, an open process
      file descriptor becomes invalid if the traced process performs an exec of
      a setuid/setgid object file or an object file that it cannot read.  Any
      operation performed on an invalid file descriptor, except close, fails
      with EAGAIN.  In this situation, if any tracing flags are set and the
      process file is open for writing, the process will have been directed to
      stop and its run-on-last-close flag will have been set (see PIOCSRLC).
      This enables a controlling process (if it has permission) to reopen the
      process file to get a new valid file descriptor, close the invalid file
      descriptor, and proceed.  Just closing the invalid file descriptor causes
      the traced process to resume execution with no tracing flags set.  Any
      process not currently open for writing via /proc but that has left-over
      tracing flags from a previous open and that execs a setuid/setgid or
      unreadable object file will not be stopped but will have all its tracing
      flags cleared.

      For reasons of symmetry and efficiency there are more control operations
      than strictly necessary.

FILES
      /proc     directory (list of active processes)
      /proc/nnnnnprocess image

SEE ALSO
      open(2), ptrace(2), sigaction(2), signal(2)



10/89                                                                   Page 11







proc(4)                          UNIX System V                          proc(4)


DIAGNOSTICS
      Errors that can occur in addition to the errors normally associated with
      file system access:

      ENOENT      The traced process has exited after being opened.

      EIO         I/O was attempted at an illegal address in the traced
                  process.

      EBADF       An I/O or ioctl operation requiring write access was
                  attempted on a file descriptor not open for writing.

      EBUSY       PIOCSTOP or PIOCWSTOP was applied to a system process; an
                  exclusive open was attempted on a process file already
                  already open for writing; an open for writing was attempted
                  and an exclusive open is in effect on the process file;
                  PIOCRUN, PIOCSREG or PIOCSFPREG was applied to a process not
                  stopped on an event of interest; an attempt was made to mount
                  /proc when it is already mounted.

      EPERM       Someone other than the super-user attempted to better a
                  process's priority by issuing PIOCNICE.

      ENOSYS      An attempt was made to perform an unsupported operation (such
                  as create, remove, link, or unlink) on an entry in /proc.

      EFAULT      An I/O or ioctl request referred to an invalid address in the
                  controlling process.

      EINVAL      In general this means that some invalid argument was supplied
                  to a system call.  The list of conditions eliciting this
                  error includes:  the ioctl code is undefined; an ioctl
                  operation was issued on a file descriptor referring to the
                  /proc directory; an out-of-range signal number was specified
                  with PIOCSSIG, PIOCKILL, or PIOCUNKILL; SIGKILL was specified
                  with PIOCUNKILL; an illegal virtual address was specified in
                  a PIOCOPENM request; PIOCGFPREG or PIOCSFPREG was issued on a
                  machine without floating-point hardware.

      EINTR       A signal was received by the controlling process while
                  waiting for the traced process to stop via PIOCSTOP or
                  PIOCWSTOP.

      EAGAIN      The traced process has performed an exec of a setuid/setgid
                  object file or of an object file that it cannot read; all
                  further operations on the process file descriptor (except
                  close) elicit this error.







Page 12                                                                   10/89





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