xref: /dflybsd-src/sys/vfs/procfs/README (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marinosaute procfs lyonnais
2*86d7f5d3SJohn Marino
3*86d7f5d3SJohn Marinoprocfs supports two levels of directory.  the filesystem root
4*86d7f5d3SJohn Marinodirectory contains a representation of the system process table.
5*86d7f5d3SJohn Marinothis consists of an entry for each active and zombie process, and
6*86d7f5d3SJohn Marinoan additional entry "curproc" which always represents the process
7*86d7f5d3SJohn Marinomaking the lookup request.
8*86d7f5d3SJohn Marino
9*86d7f5d3SJohn Marinoeach of the sub-directories contains several files.  these files
10*86d7f5d3SJohn Marinoare used to control and interrogate processes.  the files implemented
11*86d7f5d3SJohn Marinoare:
12*86d7f5d3SJohn Marino
13*86d7f5d3SJohn Marino	file	- xxx.  the exec'ed file.
14*86d7f5d3SJohn Marino
15*86d7f5d3SJohn Marino	status  - r/o.  returns process status.
16*86d7f5d3SJohn Marino
17*86d7f5d3SJohn Marino	ctl	- w/o.  sends a control message to the process.
18*86d7f5d3SJohn Marino			for example:
19*86d7f5d3SJohn Marino				echo hup > /proc/curproc/note
20*86d7f5d3SJohn Marino			will send a SIGHUP to the shell.
21*86d7f5d3SJohn Marino			whereas
22*86d7f5d3SJohn Marino				echo attach > /proc/1293/ctl
23*86d7f5d3SJohn Marino			would set up process 1293 for debugging.
24*86d7f5d3SJohn Marino			see below for more details.
25*86d7f5d3SJohn Marino
26*86d7f5d3SJohn Marino	mem	- r/w.  virtual memory image of the process.
27*86d7f5d3SJohn Marino			parts of the address space are readable
28*86d7f5d3SJohn Marino			only if they exist in the target process.
29*86d7f5d3SJohn Marino			a more reasonable alternative might be
30*86d7f5d3SJohn Marino			to return zero pages instead of an error.
31*86d7f5d3SJohn Marino			comments?
32*86d7f5d3SJohn Marino
33*86d7f5d3SJohn Marino	note	- w/o.  writing a string here sends the
34*86d7f5d3SJohn Marino			equivalent note to the process.
35*86d7f5d3SJohn Marino			[ not implemented. ]
36*86d7f5d3SJohn Marino
37*86d7f5d3SJohn Marino	notepg	- w/o.  the same as note, but sends to all
38*86d7f5d3SJohn Marino			members of the process group.
39*86d7f5d3SJohn Marino			[ not implemented. ]
40*86d7f5d3SJohn Marino
41*86d7f5d3SJohn Marino	regs	- r/w.	process register set.  this can be read
42*86d7f5d3SJohn Marino			or written any time even if the process
43*86d7f5d3SJohn Marino			is not stopped.  since the bsd kernel
44*86d7f5d3SJohn Marino			is single-processor, this implementation
45*86d7f5d3SJohn Marino			will get the "right" register values.
46*86d7f5d3SJohn Marino			a multi-proc kernel would need to do some
47*86d7f5d3SJohn Marino			synchronisation.
48*86d7f5d3SJohn Marino
49*86d7f5d3SJohn Marinothis then looks like:
50*86d7f5d3SJohn Marino
51*86d7f5d3SJohn Marino% ls -li /proc
52*86d7f5d3SJohn Marinototal 0
53*86d7f5d3SJohn Marino   9 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 0
54*86d7f5d3SJohn Marino  17 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 1
55*86d7f5d3SJohn Marino  89 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 10
56*86d7f5d3SJohn Marino  25 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 2
57*86d7f5d3SJohn Marino2065 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 257
58*86d7f5d3SJohn Marino2481 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 309
59*86d7f5d3SJohn Marino 265 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 32
60*86d7f5d3SJohn Marino3129 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 390
61*86d7f5d3SJohn Marino3209 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 400
62*86d7f5d3SJohn Marino3217 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 401
63*86d7f5d3SJohn Marino3273 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 408
64*86d7f5d3SJohn Marino 393 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 48
65*86d7f5d3SJohn Marino 409 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 50
66*86d7f5d3SJohn Marino 465 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 57
67*86d7f5d3SJohn Marino 481 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 59
68*86d7f5d3SJohn Marino 537 dr-xr-xr-x  2 root  kmem   0 Sep 21 15:06 66
69*86d7f5d3SJohn Marino 545 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 67
70*86d7f5d3SJohn Marino 657 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 81
71*86d7f5d3SJohn Marino 665 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 82
72*86d7f5d3SJohn Marino 673 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 83
73*86d7f5d3SJohn Marino 681 dr-xr-xr-x  2 root  wheel  0 Sep 21 15:06 84
74*86d7f5d3SJohn Marino3273 dr-xr-xr-x  2 jsp   staff  0 Sep 21 15:06 curproc
75*86d7f5d3SJohn Marino% ls -li /proc/curproc
76*86d7f5d3SJohn Marinototal 408
77*86d7f5d3SJohn Marino3341 --w-------  1 jsp  staff       0 Sep 21 15:06 ctl
78*86d7f5d3SJohn Marino1554 -r-xr-xr-x  1 bin  bin     90112 Mar 29 04:52 file
79*86d7f5d3SJohn Marino3339 -rw-------  1 jsp  staff  118784 Sep 21 15:06 mem
80*86d7f5d3SJohn Marino3343 --w-------  1 jsp  staff       0 Sep 21 15:06 note
81*86d7f5d3SJohn Marino3344 --w-------  1 jsp  staff       0 Sep 21 15:06 notepg
82*86d7f5d3SJohn Marino3340 -rw-------  1 jsp  staff       0 Sep 21 15:06 regs
83*86d7f5d3SJohn Marino3342 -r--r--r--  1 jsp  staff       0 Sep 21 15:06 status
84*86d7f5d3SJohn Marino% df /proc/curproc /proc/curproc/file
85*86d7f5d3SJohn MarinoFilesystem  512-blocks     Used    Avail Capacity  Mounted on
86*86d7f5d3SJohn Marinoproc                 4        4        0   100%    /proc
87*86d7f5d3SJohn Marino/dev/ad0s1a     254063   102444   131294    44%    /
88*86d7f5d3SJohn Marino% cat /proc/curproc/status
89*86d7f5d3SJohn Marinocat 446 439 400 81 12,0 ctty 748620684 270000 0 0 0 20000 nochan 11 20 20 20 0 21 117
90*86d7f5d3SJohn Marino
91*86d7f5d3SJohn Marino
92*86d7f5d3SJohn Marino
93*86d7f5d3SJohn Marinothe basic sequence of commands written to "ctl" would be
94*86d7f5d3SJohn Marino
95*86d7f5d3SJohn Marino	attach		- this stops the target process and
96*86d7f5d3SJohn Marino			  arranges for the sending process
97*86d7f5d3SJohn Marino			  to become the debug control process
98*86d7f5d3SJohn Marino	wait		- wait for the target process to come to
99*86d7f5d3SJohn Marino			  a steady state ready for debugging.
100*86d7f5d3SJohn Marino	step		- single step, with no signal delivery.
101*86d7f5d3SJohn Marino	run		- continue running, with no signal delivery,
102*86d7f5d3SJohn Marino			  until next trap or breakpoint.
103*86d7f5d3SJohn Marino	<signame>	- deliver signal <signame> and continue running.
104*86d7f5d3SJohn Marino	detach		- continue execution of the target process
105*86d7f5d3SJohn Marino			  and remove it from control by the debug process
106*86d7f5d3SJohn Marino
107*86d7f5d3SJohn Marinoin a normal debugging environment, where the target is fork/exec'd by
108*86d7f5d3SJohn Marinothe debugger, the debugger should fork and the child should stop itself
109*86d7f5d3SJohn Marino(with a self-inflicted SIGSTOP).  the parent should do a "wait" then an
110*86d7f5d3SJohn Marino"attach".  as before, the child will hit a breakpoint on the first
111*86d7f5d3SJohn Marinoinstruction in any newly exec'd image.
112*86d7f5d3SJohn Marino
113*86d7f5d3SJohn Marino$FreeBSD: src/sys/miscfs/procfs/README,v 1.4 1999/08/28 00:46:53 peter Exp $
114*86d7f5d3SJohn Marino$DragonFly: src/sys/vfs/procfs/README,v 1.3 2005/02/26 12:00:55 swildner Exp $
115