1
0

proc 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. .TH PROC 3
  2. .SH NAME
  3. proc \- running processes
  4. .SH SYNOPSIS
  5. .nf
  6. .B bind #p /proc
  7. .BI /proc/ n /args
  8. .BI /proc/ n /ctl
  9. .BI /proc/ n /fd
  10. .BI /proc/ n /fpregs
  11. .BI /proc/ n /kregs
  12. .BI /proc/ n /mem
  13. .BI /proc/ n /note
  14. .BI /proc/ n /noteid
  15. .BI /proc/ n /notepg
  16. .BI /proc/ n /ns
  17. .BI /proc/ n /proc
  18. .BI /proc/ n /profile
  19. .BI /proc/ n /regs
  20. .BI /proc/ n /segment
  21. .BI /proc/ n /status
  22. .BI /proc/ n /text
  23. .BI /proc/ n /wait
  24. \&...
  25. .fi
  26. .SH DESCRIPTION
  27. The
  28. .I proc
  29. device serves a two-level directory structure.
  30. The first level contains numbered directories
  31. corresponding to pids of live processes;
  32. each such directory contains a set of files
  33. representing the corresponding process.
  34. .PP
  35. The
  36. .B mem
  37. file contains the current memory image of the process.
  38. A read or write at offset
  39. .IR o ,
  40. which must be a valid virtual address,
  41. accesses bytes from address
  42. .IR o
  43. up to the end of the memory segment containing
  44. .IR o .
  45. Kernel virtual memory, including the kernel stack for the process and
  46. saved user registers (whose addresses are machine-dependent),
  47. can be accessed through
  48. .BR mem .
  49. Writes are permitted only while the process is in the
  50. .B Stopped
  51. state and only to user addresses or registers.
  52. .PP
  53. The read-only
  54. .B proc
  55. file contains the kernel per-process
  56. structure.
  57. Its main use is to recover the kernel stack and program counter
  58. for kernel debugging.
  59. .PP
  60. The files
  61. .BR regs ,
  62. .BR fpregs ,
  63. and
  64. .BR kregs
  65. hold representations of the user-level registers, floating-point registers,
  66. and kernel registers in machine-dependent form.
  67. The
  68. .B kregs
  69. file is read-only.
  70. .PP
  71. The read-only
  72. .B fd
  73. file lists the open file descriptors of the process.
  74. The first line of the file is its current directory; subsequent lines list, one per line,
  75. the open files, giving the decimal file descriptor number; whether the file is open for read
  76. .RB ( r ),
  77. write,
  78. .RB ( w ),
  79. or both
  80. .RB ( rw );
  81. the type, device number, and qid of the file; its I/O unit (the amount of data
  82. that may be transferred on the file as a contiguous piece; see
  83. .IR iounit (2)),
  84. its I/O offset; and its name at the time it was opened.
  85. .PP
  86. The read-only
  87. .B ns
  88. file contains a textual representation of the process's file name space, in the format of
  89. .IR namespace (6)
  90. accepted by
  91. .B newns
  92. (see
  93. .IR auth (2)).
  94. The last line of the file identifies the current working directory of the process, in the form of a
  95. .B cd
  96. command
  97. (see
  98. .IR rc (1)).
  99. The information in this file is based on the names files had when the name space was assembled,
  100. so the names it contains may be inaccessible if the files have been subsequently renamed or rearranged.
  101. .PP
  102. The read-only
  103. .B segment
  104. file contains a textual display of the memory segments
  105. attached to the process. Each line has multiple fields:
  106. the type of segment (\c
  107. .BR Stack ,
  108. .BR Text ,
  109. .BR Data ,
  110. .BR Bss ,
  111. etc.); one-letter flags such as
  112. .B R
  113. for read-only, if any;
  114. starting virtual address, in hexadecimal;
  115. ending virtual address, and reference count.
  116. .PP
  117. The read-only
  118. .B status
  119. file contains a string with twelve fields, each followed by a space.
  120. The fields are:
  121. .IP \-
  122. the process name and user name, each 27 characters left justified
  123. .IP \-
  124. the process state, 11 characters left justified (see
  125. .IR ps (1))
  126. .IP \-
  127. the six 11-character numbers also held in the process's
  128. .B #c/cputime
  129. file
  130. .IP \-
  131. the amount of memory used by the process, except its stack,
  132. in units of 1024 bytes
  133. .IP \-
  134. the base and current scheduling priority, each 11 character numbers
  135. .PP
  136. The read-only
  137. .B args
  138. file contains the arguments of the program when it was created by
  139. .IR exec (2).
  140. If the program was not created by
  141. .BR exec ,
  142. such as by
  143. .IR fork (2),
  144. its
  145. .B args
  146. file will be empty.
  147. The format of the file is a list of quoted strings suitable for
  148. .BR tokenize ;
  149. see
  150. .IR getfields (2).
  151. .PP
  152. The
  153. .B text
  154. file is a pseudonym for the file
  155. from which the process was executed;
  156. its main use is to recover the symbol table of the process.
  157. .PP
  158. The
  159. .B wait
  160. file may be read to recover
  161. records from the exiting children of the process in the format of
  162. .B await
  163. (see
  164. .IR wait (2)).
  165. If the process has no extant children, living or exited,
  166. a read of
  167. .B wait
  168. will block.
  169. It is an error for a process to attempt to read its own
  170. .B wait
  171. file when it has no children.
  172. When a process's
  173. .B wait
  174. file is being read,
  175. the process will draw an error
  176. if it attempts an
  177. .B await
  178. system call; similarly, if a process is in an
  179. .B await
  180. system call, its
  181. .B wait
  182. file cannot be read by any process.
  183. .PP
  184. Textual messages written to the
  185. .B ctl
  186. file control the execution of the process.
  187. Some require that the process is in a particular state
  188. and return an error if it is not.
  189. .TP 10n
  190. .B stop
  191. Suspend execution of the process, putting it in the
  192. .B Stopped
  193. state.
  194. .TP 10n
  195. .B start
  196. Resume execution of a
  197. .B Stopped
  198. process.
  199. .TP 10n
  200. .B waitstop
  201. Do not affect the process directly but, like all other messages ending with
  202. .BR stop ,
  203. block the process writing the
  204. .B ctl
  205. file until the target process is in the
  206. .B Stopped
  207. state or exits.
  208. Also like other
  209. .B stop
  210. control messages,
  211. if the target process would receive a note while the message is pending,
  212. it is instead stopped and the debugging process is resumed.
  213. .TP 10n
  214. .B startstop
  215. Allow a
  216. .B Stopped
  217. process to resume, and then do a
  218. .B waitstop
  219. action.
  220. .TP 10n
  221. .B hang
  222. Set a bit in the process so that,
  223. when it completes an
  224. .IR exec (2)
  225. system call, it will enter the
  226. .B Stopped
  227. state before returning to user mode.
  228. This bit is inherited across
  229. .IR fork (2)
  230. and
  231. .IR exec (2).
  232. .TP 10n
  233. .B "close\ \fIn
  234. Close file descriptor
  235. .I n
  236. in the process.
  237. .TP 10n
  238. .B closefiles
  239. Close all open file descriptors in the process.
  240. .TP 10n
  241. .B nohang
  242. Clear the hang bit.
  243. .TP 10n
  244. .B noswap
  245. Don't allow this process to be swapped out. This should
  246. be used carefully and sparingly or the system could run
  247. out of memory. It is meant for processes that can't be
  248. swapped, like the ones implementing the swap device and for
  249. processes containing sensitive data.
  250. .TP 10n
  251. .B kill
  252. Kill the process the next time it crosses the user/kernel boundary.
  253. .TP 10n
  254. .B private
  255. Make it impossible to read the process's user memory.
  256. This property is inherited on fork, cleared on
  257. .IR exec (2),
  258. and is not otherwise resettable.
  259. .TP 10n
  260. .B "pri\ \fIn
  261. Set the base priority for the process to the integer
  262. .IR n .
  263. .TP 10n
  264. .B "wire\ \fIn
  265. Wire the process to processor
  266. .IR n .
  267. .PD
  268. .PP
  269. The priority is interpreted by Plan 9's multilevel process scheduler.
  270. Priorities run from 0 to 19, with higher
  271. numbers representing higher priorities.
  272. A process has a base priority and
  273. a running priority which is less than or equal to the base priority.
  274. As a process uses up more of its allocated time, its priority is lowered.
  275. Unless
  276. explicitly set, user processes have base priority 10, kernel processes
  277. 13.
  278. Children inherit the parent's base priority.
  279. .PP
  280. The read-only
  281. .B profile
  282. file contains the instruction frequency count information used for multiprocess profiling; see
  283. .B tprof
  284. in
  285. .IR prof (1).
  286. The information is gleaned by sampling the program's user-level program counter
  287. at interrupt time.
  288. .PP
  289. Strings written to the
  290. .B note
  291. file will be posted as a note to the process
  292. (see
  293. .IR notify (2)).
  294. The note should be less than
  295. .B ERRLEN-1
  296. characters long;
  297. the last character is reserved for a terminating NUL character.
  298. A read of at least
  299. .B ERRLEN
  300. characters will retrieve the oldest note posted to the
  301. process and prevent its delivery to the process.
  302. The
  303. .B notepg
  304. file is similar, but the note will be delivered to all the
  305. processes in the target process's
  306. .I note group
  307. (see
  308. .IR fork (2)).
  309. However, if the process doing the write is in the group,
  310. it will not receive the note.
  311. The
  312. .B notepg
  313. file is write-only.
  314. .PP
  315. The textual
  316. .B noteid
  317. file may be read to recover an integer identifying the note group of the process
  318. (see
  319. .B RFNOTEG
  320. in
  321. .IR fork (2)).
  322. The file may be written to cause the process to change to another note group,
  323. provided the group exists and is owned by the same user.
  324. .SH FILES
  325. .nf
  326. .B /sys/src/9/*/mem.h
  327. .B /sys/src/9/*/dat.h
  328. .fi
  329. .SH SEE ALSO
  330. .IR debugger (2),
  331. .IR mach (2),
  332. .IR cons (3)
  333. .SH SOURCE
  334. .B /sys/src/9/port/devproc.c