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