1.\"
2.\" Copyright (c) 1992, 1993
3.\"	The Regents of the University of California.  All rights reserved.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software donated to Berkeley by
7.\" Jan-Simon Pendry.
8.\"
9.\" %sccs.include.redist.roff%
10.\"
11.\"	@(#)mount_procfs.8	8.2 (Berkeley) 03/27/94
12.\"
13.\"
14.Dd
15.Dt MOUNT_PROCFS 8
16.Os BSD 4.4
17.Sh NAME
18.Nm mount_procfs
19.Nd mount the process file system
20.Sh SYNOPSIS
21.Nm mount_procfs
22.Op Fl o Ar options
23.Pa /proc
24.Pa mount_point
25.Sh DESCRIPTION
26The
27.Nm mount_procfs
28command attaches an instance of the process
29namespace to the global filesystem namespace.
30The conventional mount point is
31.Pa /proc .
32This command is normally executed by
33.Xr mount 8
34at boot time.
35.Pp
36The options are as follows:
37.Bl -tag -width indent
38.It Fl o
39Options are specified with a
40.Fl o
41flag followed by a comma separated string of options.
42See the
43.Xr mount 8
44man page for possible options and their meanings.
45.El
46.Pp
47The root of the process filesystem
48contains an entry for each active process.
49These processes are visible as a directory whose
50name is the process' pid.
51In addition, the special entry
52.Pa curproc
53references the current process.
54.Pp
55Each directory contains several files.
56.Bl -tag -width status
57.It Pa ctl
58a writeonly file which supports a variety
59of control operations.
60Control commands are written as strings to the
61.Pa ctl
62file.
63The control commands are:
64.Bl -tag -width detach -compact
65.It attach
66stops the target process and arranges for the sending
67process to become the debug control process.
68.It detach
69continue execution of the target process and
70remove it from control by the debug process (which
71need not be the sending process).
72.It run
73continue running the target process until
74a signal is delivered, a breakpoint is hit, or the
75target process exits.
76.It step
77single step the target process, with no signal delivery.
78.It wait
79wait for the target process to come to a steady
80state ready for debugging.
81The target process must be in this state before
82any of the other commands are allowed.
83.El
84.Pp
85The string can also be the name of a signal, lower case
86and without the
87.Dv SIG
88prefix,
89in which case that signal is delivered to the process
90(see
91.Xr sigaction 2 ).
92.It Pa file
93A reference to the vnode from which the process text was read.
94This can be used to gain access to the process' symbol table,
95or to start another copy of the process.
96.It Pa mem
97The complete virtual memory image of the process.
98Only those address which exist in the process can be accessed.
99Reads and writes to this file modify the process.
100Writes to the text segment remain private to the process.
101.It Pa note
102Not implemented.
103.It Pa notepg
104Not implemented.
105.It Pa regs
106Allows read and write access to the process' register set.
107This file contains a binary data structure
108.Dv "struct regs"
109defined in
110.Pa <machine/reg.h> .
111.Pa regs
112can only be written when the process is stopped.
113.It Pa fpregs
114The floating point registers as defined by
115.Dv "struct fpregs"
116in
117.Pa <machine/reg.h> .
118.Pa fpregs
119is only implemented on machines which have distinct general
120purpose and floating point register sets.
121.It Pa status
122The process status.
123This file is readonly and returns a single line containing
124multiple space-separated fields as follows:
125.Pp
126.Bl -bullet -compact
127.It
128command name
129.It
130process id
131.It
132parent process id
133.It
134process group id
135.It
136session id
137.It
138.Ar major,minor
139of the controlling terminal, or
140.Dv -1,-1
141if there is no controlling terminal.
142.It
143a list of process flags:
144.Dv ctty
145if there is a controlling terminal,
146.Dv sldr
147if the process is a session leader,
148.Dv noflags
149if neither of the other two flags are set.
150.It
151the process start time in seconds and microseconds,
152comma separated.
153.It
154the user time in seconds and microseconds,
155comma separated.
156.It
157the system time in seconds and microseconds,
158comma separated.
159.It
160the wait channel message
161.It
162the process credentials consisting of
163the effective user id
164and the list of groups (whose first member
165is the effective group id)
166all comma separated.
167.El
168.El
169.Pp
170In a normal debugging environment,
171where the target is fork/exec'd by the debugger,
172the debugger should fork and the child should stop
173itself (with a self-inflicted
174.Dv SIGSTOP
175for example).
176The parent should issue a
177.Dv wait
178and then an
179.Dv attach
180command via the appropriate
181.Pa ctl
182file.
183The child process will receive a
184.Dv SIGTRAP
185immediately after the call to exec (see
186.Xr execve 2 ).
187.Sh FILES
188.Bl -tag -width /proc/curproc -compact
189.It Pa /proc/#
190.It Pa /proc/curproc
191.It Pa /proc/curproc/ctl
192.It Pa /proc/curproc/file
193.It Pa /proc/curproc/mem
194.It Pa /proc/curproc/note
195.It Pa /proc/curproc/notepg
196.It Pa /proc/curproc/regs
197.It Pa /proc/curproc/fpregs
198.It Pa /proc/curproc/status
199.El
200.Sh SEE ALSO
201.Xr sigaction 2 ,
202.Xr mount 2 ,
203.Xr unmount 2 ,
204.Sh CAVEATS
205No
206.Pa .
207and
208.Pa ..
209entries appear when listing the contents of the
210.Pa /proc
211directory.
212This makes sense in the context of this filesystem, but is inconsistent
213with usual filesystem conventions.
214However, it is still possible to refer to both
215.Pa .
216and
217.Pa ..
218in a pathname.
219.Pp
220This filesystem may not be NFS-exported
221since most of the functionality of
222.Dv procfs
223requires that state be maintained.
224.Sh HISTORY
225The
226.Nm mount_procfs
227utility first appeared in 4.4BSD.
228