logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

runchoom.8 (5695B)


  1. .\" runchoom.8
  2. .\" wcm, 2011.03.18 - 2011.03.22
  3. .\" ===
  4. .TH runchoom 8 "January 2013" "runtools-2.07" "runtools"
  5. .SH NAME
  6. runchoom \- abate linux oom killer on a process
  7. .SH SYNOPSIS
  8. .B runchoom [\-hV] [-ev] [\-b
  9. .I base
  10. .B ] [\-k
  11. .I key
  12. .B ] [\-p
  13. .I pid
  14. .B ] [\-s
  15. .I str
  16. .B ]
  17. .I program
  18. .B [
  19. .I args ...
  20. .B ]
  21. .SH DESCRIPTION
  22. .B runchoom
  23. writes the string ``-17'' and a newline into the procfile
  24. .IR /proc/<pid>/oom_adj ,
  25. where
  26. .I <pid>
  27. is the process id of
  28. .BR runchoom .
  29. It then execs
  30. .I program
  31. with any arguments given in
  32. .IR args .
  33. .PP
  34. If
  35. .I program
  36. does not contain a ``/'' slash character,
  37. .B runchoom
  38. will perform a shell-like search for the executable using the
  39. .B PATH
  40. variable in the current environment.
  41. .SH OPTIONS
  42. .TP
  43. .B \-b base
  44. Base directory.
  45. Normally
  46. .B runchoom
  47. uses the compiled-in default value
  48. .I /proc
  49. for the initial path element of the target procfile.
  50. The
  51. .B \-b
  52. option may be used to specify an alternative,
  53. and should be given with a leading `/'.
  54. This option overrides any definition of CHOOM_BASE in the environment.
  55. .TP
  56. .B \-e
  57. Error fail.
  58. Normally
  59. .B runchoom
  60. ignores any of the following conditions and proceeds to exec
  61. .I program
  62. anyway:
  63. the target procfile does not exist;
  64. the target procfile cannot be opened or written to.
  65. By specifying the
  66. .B \-e
  67. option,
  68. .B runchoom
  69. will instead fail at any of these conditions,
  70. and not proceed to exec
  71. .IR program .
  72. .TP
  73. .B \-h
  74. Help.
  75. Print a brief usage message to stderr and exit.
  76. .TP
  77. .B \-k key
  78. Key.
  79. Normally
  80. .B runchoom
  81. uses the compiled-in default value
  82. .I oom_adj
  83. for the last element of the target procfile.
  84. The
  85. .B \-k
  86. option may be used to specify an alternative.
  87. This option overrides any definition of CHOOM_KEY in the environment.
  88. .TP
  89. .B \-p pid
  90. Pid.
  91. Normally
  92. .B runchoom
  93. uses the value returned by
  94. .BR getpid (2)
  95. to determine the
  96. .I <pid>
  97. element of the target procfile.
  98. The
  99. .B \-p
  100. option may be used to specify an alternative,
  101. and should be given as a numeric value.
  102. .TP
  103. .B \-s str
  104. Setting.
  105. Normally
  106. .B runchoom
  107. uses the compiled-in default string ``-17'' as the setting to write
  108. into the target procfile.
  109. The
  110. .B \-s
  111. option may be used to specify an alternative.
  112. This option overrides any definition of CHOOM_SET in the environment.
  113. Note that
  114. .B runchoom
  115. adds a terminal newline to any string written into the target procfile.
  116. .TP
  117. .B \-v
  118. Verbose.
  119. Normally
  120. .B runchoom
  121. runs quietly.
  122. The
  123. .B \-v
  124. option may be used to generate some messages to stderr.
  125. .TP
  126. .B \-V
  127. Version.
  128. Print the version number to stderr and exit.
  129. .SH ENVIRONMENT
  130. The following environmental variables are inspected if they
  131. are not otherwise specified on the command-line,
  132. and may be used to override the compiled-in defaults:
  133. .PP
  134. CHOOM_BASE
  135. .RS
  136. The initial path element of the target procfile.
  137. .RE
  138. .PP
  139. CHOOM_KEY
  140. .RS
  141. The final path element of the target procfile.
  142. .RE
  143. .PP
  144. CHOOM_SET
  145. .RS
  146. The string to write into the target procfile.
  147. Note that
  148. .B runchoom
  149. adds a terminal newline to any string written into the target procfile.
  150. .RE
  151. .SH EXAMPLE
  152. The
  153. .B runchoom
  154. utility was specifically designed to protect an instance of
  155. .BR perpd (8)
  156. from the SIGKILLs generated by a linux kernel
  157. (from 2.6.11)
  158. when it is attempting to free up system resources from an overcommitment of memory.
  159. However, the utility is implemented in a platform-independent sense
  160. such that,
  161. by default,
  162. it has no effect (and no failure) on any system where the target procfile
  163. is not present.
  164. .PP
  165. Its primary usage is intended within the
  166. .I rc.perp
  167. bootscript run by the
  168. .BR perpboot (8)
  169. utility.
  170. The following script can normally be used verbatim on any platform:
  171. .PP
  172. .RS
  173. .nf
  174. #!/bin/sh -e
  175. # rc.perp: perpd startup script for perpboot
  176. # ===
  177. ### --- configure ---
  178. PERPD_OPTS="-a6"
  179. ## exec perpd:
  180. ## * options as configured above
  181. ## * runchoom(8) abate linux oom-killer
  182. ## * runlimit(8) configured in ./rlimit.conf
  183. ## * PERP_BASE defined in environment by perpboot(8)
  184. exec \\
  185. runchoom \\
  186. runlimit -F ./rlimit.conf \\
  187. perpd ${PERPD_OPTS} ${PERP_BASE}
  188. ### EOF
  189. .fi
  190. .RE
  191. .SH NOTES
  192. On a system where the
  193. .I oom_adj
  194. procfile is operative,
  195. the setting installed by
  196. .B runchoom
  197. will be inherited by all child processes.
  198. As shown in the above example, then,
  199. all the individual services running under the
  200. .BR perpd (8)
  201. process tree will acquire the -17 setting for ``oom killer'' abatement.
  202. .PP
  203. Presumably this is desirable.
  204. If not, the
  205. .B runchoom
  206. utility may be used within the individual
  207. .BR perpetrate (5)
  208. runscripts of any selected services to
  209. reset the
  210. .I oom_adj
  211. parameter of a process to a default state:
  212. .PP
  213. .RS
  214. .nf
  215. #!/bin/sh
  216. ...
  217. exec \\
  218. runchoom -s "0" \\
  219. myservice ...
  220. ### EOF
  221. .fi
  222. .RE
  223. .SH EXIT STATUS
  224. .B runchoom
  225. exits with one of the following values:
  226. .TP
  227. 0
  228. .I program
  229. was invoked and completed successfully.
  230. In this case,
  231. the exit code is returned by the
  232. .IR program ,
  233. rather than by
  234. .B runchoom
  235. itself.
  236. .TP
  237. 100
  238. .B runchoom
  239. failed because of a usage error,
  240. such as an invalid command\-line option or argument.
  241. In this case,
  242. .B runchoom
  243. prints a brief error message and usage help to stderr on exit.
  244. .TP
  245. 111
  246. .B runchoom
  247. failed due to some system or resource error.
  248. In this case,
  249. .B runchoom
  250. prints a brief diagnostic message to stderr on exit.
  251. .TP
  252. 1\-127
  253. .I program
  254. was invoked and failed with its own non-zero exit status.
  255. .SH BUGS
  256. The need for this utility.
  257. .SH AUTHOR
  258. Wayne Marshall, http://b0llix.net/perp/
  259. .SH SEE ALSO
  260. .nh
  261. .BR runtools_intro (8),
  262. .BR runargs (8),
  263. .BR runargv0 (8),
  264. .BR rundetach (8),
  265. .BR rundeux (8),
  266. .BR runenv (8),
  267. .BR runfile (8),
  268. .BR runlimit (8),
  269. .BR runlock (8),
  270. .BR runpause (8),
  271. .BR runsession (8),
  272. .BR runtool (8),
  273. .BR runtrap (8),
  274. .BR runuid (8),
  275. .BR perpd (8),
  276. .BR perpboot (8),
  277. .BR proc (5)
  278. (on relevant platforms)
  279. .\" EOF