Annotation of sys/miscfs/procfs/README, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: README,v 1.6 2002/03/14 00:42:25 miod Exp $ */
! 2: /* $NetBSD: README,v 1.4 1994/06/29 06:34:43 cgd Exp $ */
! 3:
! 4: saute procfs lyonnais
! 5:
! 6: procfs supports two levels of directory. the filesystem root
! 7: directory contains a representation of the system process table.
! 8: this consists of an entry for each active and zombie process, and
! 9: an additional entry "curproc" which always represents the process
! 10: making the lookup request.
! 11:
! 12: each of the sub-directories contains several files. these files
! 13: are used to control and interrogate processes. the files implemented
! 14: are:
! 15:
! 16: file - xxx. the exec'ed file.
! 17:
! 18: status - r/o. returns process status.
! 19:
! 20: ctl - w/o. sends a control message to the process.
! 21: for example:
! 22: echo hup > /proc/curproc/note
! 23: will send a SIGHUP to the shell.
! 24: whereas
! 25: echo attach > /proc/1293/ctl
! 26: would set up process 1293 for debugging.
! 27: see below for more details.
! 28:
! 29: mem - r/w. virtual memory image of the process.
! 30: parts of the address space are readable
! 31: only if they exist in the target process.
! 32: a more reasonable alternative might be
! 33: to return zero pages instead of an error.
! 34: comments?
! 35:
! 36: note - w/o. writing a string here sends the
! 37: equivalent note to the process.
! 38: [ not implemented. ]
! 39:
! 40: notepg - w/o. the same as note, but sends to all
! 41: members of the process group.
! 42: [ not implemented. ]
! 43:
! 44: regs - r/w. process register set. this can be read
! 45: or written any time even if the process
! 46: is not stopped. since the bsd kernel
! 47: is single-processor, this implementation
! 48: will get the "right" register values.
! 49: a multi-proc kernel would need to do some
! 50: synchronisation.
! 51:
! 52: fpregs - r/w. same as regs, but for floating point registers
! 53: when available.
! 54:
! 55: cmdline - r/o. process command line parameters, separated
! 56: by NULs
! 57:
! 58: Note that regs and fpregs are not available if the kernel is compiled
! 59: without option PTRACE.
! 60:
! 61: this then looks like:
! 62:
! 63: % ls -li /proc
! 64: total 0
! 65: 9 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 0
! 66: 17 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 1
! 67: 89 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 10
! 68: 25 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 2
! 69: 2065 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 257
! 70: 2481 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 309
! 71: 265 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 32
! 72: 3129 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 390
! 73: 3209 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 400
! 74: 3217 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 401
! 75: 3273 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 408
! 76: 393 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 48
! 77: 409 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 50
! 78: 465 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 57
! 79: 481 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 59
! 80: 537 dr-xr-xr-x 2 root kmem 0 Sep 21 15:06 66
! 81: 545 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 67
! 82: 657 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 81
! 83: 665 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 82
! 84: 673 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 83
! 85: 681 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 84
! 86: 3273 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 curproc
! 87: % ls -li /proc/curproc
! 88: total 792
! 89: 135147 -r--r--r-- 1 jason staff 0 Aug 11 22:52 cmdline
! 90: 135143 --w------- 1 jason staff 0 Aug 11 22:52 ctl
! 91: 3860 -r-xr-xr-x 1 root bin 167936 Jul 30 14:23 file
! 92: 135142 -rw------- 1 jason staff 108 Aug 11 22:52 fpregs
! 93: 135140 -rw------- 1 jason staff 225280 Aug 11 22:52 mem
! 94: 135145 --w------- 1 jason staff 0 Aug 11 22:52 note
! 95: 135146 --w------- 1 jason staff 0 Aug 11 22:52 notepg
! 96: 135141 -rw------- 1 jason staff 64 Aug 11 22:52 regs
! 97: 135144 -r--r--r-- 1 jason staff 0 Aug 11 22:52 status
! 98: % df /proc/curproc /proc/curproc/file
! 99: Filesystem 512-blocks Used Avail Capacity Mounted on
! 100: proc 2 2 0 100% /proc
! 101: /dev/wd0a 16186 13548 1018 93% /
! 102: % cat /proc/curproc/status
! 103: cat 446 439 400 81 12,0 ctty 748620684 270000 0 0 0 20000 nochan 11 20 20 20 0 21 117
! 104:
! 105:
! 106:
! 107: the basic sequence of commands written to "ctl" would be
! 108:
! 109: attach - this stops the target process and
! 110: arranges for the sending process
! 111: to become the debug control process
! 112: wait - wait for the target process to come to
! 113: a steady state ready for debugging.
! 114: step - single step, with no signal delivery.
! 115: run - continue running, with no signal delivery,
! 116: until next trap or breakpoint.
! 117: <signame> - deliver signal <signame> and continue running.
! 118: detach - continue execution of the target process
! 119: and remove it from control by the debug process
! 120:
! 121: Note that attach, wait, step, run and detach are not available if the
! 122: kernel is compiled without option PTRACE.
! 123:
! 124: in a normal debugging environment, where the target is fork/exec'd by
! 125: the debugger, the debugger should fork and the child should stop itself
! 126: (with a self-inflicted SIGSTOP). the parent should do a "wait" then an
! 127: "attach". as before, the child will hit a breakpoint on the first
! 128: instruction in any newly exec'd image.
CVSweb