merge in netbsd changes.
[unix-history] / usr / src / sys / miscfs / procfs / README
CommitLineData
2a37c4dc
JSP
1saute procfs lyonnais
2
3procfs supports two levels of directory. the filesystem root
4directory contains a representation of the system process table.
5this consists of an entry for each active and zombie process, and
6an additional entry "curproc" which always represents the process
7making the lookup request.
8
9each of the sub-directories contains several files. these files
10are used to control and interrogate processes. the files implemented
11are:
12
13 file - xxx. the exec'ed file.
14
15 status - r/o. returns process status.
16
17 ctl - w/o. sends a control message to the process.
18 for example:
19 echo hup > /proc/curproc/note
20 will send a SIGHUP to the shell.
21 whereas
22 echo attach > /proc/1293/ctl
23 would set up process 1293 for debugging.
24 see below for more details.
25
26 mem - r/w. virtual memory image of the process.
27 parts of the address space are readable
28 only if they exist in the target process.
29 a more reasonable alternative might be
30 to return zero pages instead of an error.
31 comments?
32
33 note - w/o. writing a string here sends the
34 equivalent note to the process.
35 [ not implemented. ]
36
37 notepg - w/o. the same as note, but sends to all
38 members of the process group.
39 [ not implemented. ]
40
41 regs - r/w. process register set. this can be read
42 or written any time even if the process
43 is not stopped. since the bsd kernel
44 is single-processor, this implementation
45 will get the "right" register values.
46 a multi-proc kernel would need to do some
47 synchronisation.
48
49this then looks like:
50
51% ls -li /proc
52total 0
53 9 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 0
54 17 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 1
55 89 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 10
56 25 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 2
572065 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 257
582481 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 309
59 265 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 32
603129 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 390
613209 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 400
623217 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 401
633273 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 408
64 393 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 48
65 409 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 50
66 465 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 57
67 481 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 59
68 537 dr-xr-xr-x 2 root kmem 0 Sep 21 15:06 66
69 545 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 67
70 657 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 81
71 665 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 82
72 673 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 83
73 681 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 84
743273 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 curproc
75% ls -li /proc/curproc
76total 408
773341 --w------- 1 jsp staff 0 Sep 21 15:06 ctl
781554 -r-xr-xr-x 1 bin bin 90112 Mar 29 04:52 file
793339 -rw------- 1 jsp staff 118784 Sep 21 15:06 mem
803343 --w------- 1 jsp staff 0 Sep 21 15:06 note
813344 --w------- 1 jsp staff 0 Sep 21 15:06 notepg
823340 -rw------- 1 jsp staff 0 Sep 21 15:06 regs
833342 -r--r--r-- 1 jsp staff 0 Sep 21 15:06 status
84% df /proc/curproc /proc/curproc/file
85Filesystem 512-blocks Used Avail Capacity Mounted on
86proc 2 2 0 100% /proc
87/dev/wd0a 16186 13548 1018 93% /
88% cat /proc/curproc/status
89cat 446 439 400 81 12,0 ctty 748620684 270000 0 0 0 20000 nochan 11 20 20 20 0 21 117
90
91
92
93the basic sequence of commands written to "ctl" would be
94
95 attach - this stops the target process and
96 arranges for the sending process
97 to become the debug control process
98 wait - wait for the target process to come to
99 a steady state ready for debugging.
100 step - single step, with no signal delivery.
101 run - continue running, with no signal delivery,
102 until next trap or breakpoint.
103 <signame> - deliver signal <signame> and continue running.
104 detach - continue execution of the target process
105 and remove it from control by the debug process
106
107in a normal debugging environment, where the target is fork/exec'd by
108the debugger, the debugger should fork and the child should stop itself
109(with a self-inflicted SIGSTOP). the parent should do a "wait" then an
110"attach". as before, the child will hit a breakpoint on the first
111instruction in any newly exec'd image.
112
113$Id: README,v 3.1 1993/12/15 09:40:17 jsp Exp $