proc 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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. .TP 10n
  268. .B "period\ \fInu
  269. Set the real-time scheduling period of the process to
  270. .IR nu ,
  271. where
  272. .I n
  273. is an optionally signed number containing an optional decimal point and
  274. .I u
  275. is one of
  276. .BR s ,
  277. .BR ms ,
  278. .BR us ,
  279. .BR µs ,
  280. .BR ns ,
  281. or
  282. empty. The time is interpreted, respectively, as
  283. .IR seconds ,
  284. .IR milliseconds ,
  285. .IR microseconds ,
  286. .IR microseconds ,
  287. .IR nanoseconds ,
  288. or, in the case of an absent units specifier, as
  289. .IR nanoseconds .
  290. If the time specifier is signed, it is interpreted as an increment or decrement
  291. from a previously set value.
  292. See
  293. .IR realtime (3).
  294. .TP 10n
  295. .B "deadline\ \fInu
  296. Set the real-time deadline interval of the process to
  297. .IR nu ,
  298. where
  299. .I n
  300. and
  301. .I u
  302. are interpreted as for
  303. .B period
  304. above.
  305. See
  306. .IR realtime (3).
  307. .TP 10n
  308. .B "cost\ \fInu
  309. Set the real-time cost (maximum CPU time per period) of the process to
  310. .IR nu ,
  311. where
  312. .I n
  313. and
  314. .I u
  315. are interpreted as for
  316. .B period
  317. above.
  318. .TP 10n
  319. .B "sporadic
  320. Use sporadic scheduling for the real-time process.
  321. See
  322. .IR realtime (3).
  323. .TP 10n
  324. .B "yieldonblock
  325. Make the real-time process yield on blocking I/O.
  326. See
  327. .IR realtime (3).
  328. .TP 10n
  329. .B "admit
  330. Given real-time
  331. .IR period ,
  332. .I deadline
  333. and
  334. .I cost
  335. are set (an unset
  336. .I deadline
  337. will set
  338. .I deadline
  339. to
  340. .IR period ),
  341. perform a schedulability test and start scheduling the process as a real-time
  342. process if the test succeeds. If the test fails, the
  343. .B write
  344. will fail with error set to the reason for failure.
  345. See
  346. .IR realtime (3).
  347. .PP
  348. The priority is interpreted by Plan 9's multilevel process scheduler.
  349. Priorities run from 0 to 19, with higher
  350. numbers representing higher priorities.
  351. A process has a base priority and
  352. a running priority which is less than or equal to the base priority.
  353. As a process uses up more of its allocated time, its priority is lowered.
  354. Unless
  355. explicitly set, user processes have base priority 10, kernel processes
  356. 13.
  357. Children inherit the parent's base priority.
  358. .PP
  359. The read-only
  360. .B profile
  361. file contains the instruction frequency count information used for multiprocess profiling; see
  362. .B tprof
  363. in
  364. .IR prof (1).
  365. The information is gleaned by sampling the program's user-level program counter
  366. at interrupt time.
  367. .PP
  368. Strings written to the
  369. .B note
  370. file will be posted as a note to the process
  371. (see
  372. .IR notify (2)).
  373. The note should be less than
  374. .B ERRLEN-1
  375. characters long;
  376. the last character is reserved for a terminating NUL character.
  377. A read of at least
  378. .B ERRLEN
  379. characters will retrieve the oldest note posted to the
  380. process and prevent its delivery to the process.
  381. The
  382. .B notepg
  383. file is similar, but the note will be delivered to all the
  384. processes in the target process's
  385. .I note group
  386. (see
  387. .IR fork (2)).
  388. However, if the process doing the write is in the group,
  389. it will not receive the note.
  390. The
  391. .B notepg
  392. file is write-only.
  393. .PP
  394. The textual
  395. .B noteid
  396. file may be read to recover an integer identifying the note group of the process
  397. (see
  398. .B RFNOTEG
  399. in
  400. .IR fork (2)).
  401. The file may be written to cause the process to change to another note group,
  402. provided the group exists and is owned by the same user.
  403. .SH FILES
  404. .nf
  405. .B /sys/src/9/*/mem.h
  406. .B /sys/src/9/*/dat.h
  407. .fi
  408. .SH SEE ALSO
  409. .IR debugger (2),
  410. .IR mach (2),
  411. .IR cons (3)
  412. .SH SOURCE
  413. .B /sys/src/9/port/devproc.c