manual-Z-H-11.html 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275
  1. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!--
  4. Generated from manual.tex by tex2page, v 20050501
  5. (running on MzScheme 299.400, unix),
  6. (c) Dorai Sitaram,
  7. http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html
  8. -->
  9. <head>
  10. <title>
  11. The Incomplete Scheme 48 Reference Manual for release 1.6
  12. </title>
  13. <link rel="stylesheet" type="text/css" href="manual-Z-S.css" title=default>
  14. <meta name=robots content="noindex,follow">
  15. </head>
  16. <body>
  17. <div id=content>
  18. <div align=right class=navigation><i>[Go to <span><a href="manual.html">first</a>, <a href="manual-Z-H-10.html">previous</a></span><span>, <a href="manual-Z-H-12.html">next</a></span> page<span>; &nbsp;&nbsp;</span><span><a href="manual-Z-H-2.html#node_toc_start">contents</a></span><span><span>; &nbsp;&nbsp;</span><a href="manual-Z-H-13.html#node_index_start">index</a></span>]</i></div>
  19. <p></p>
  20. <a name="node_chap_9"></a>
  21. <h1 class=chapter>
  22. <div class=chapterheading><a href="manual-Z-H-2.html#node_toc_node_chap_9">Chapter 9</a></div><br>
  23. <a href="manual-Z-H-2.html#node_toc_node_chap_9">Access to POSIX</a></h1>
  24. <p>This chapter describes Scheme&nbsp;48's interface to the POSIX C calls
  25. [<a href="manual-Z-H-12.html#node_bib_1">1</a>].
  26. Scheme versions of most of the functions in POSIX are provided.
  27. Both the interface and implementation are new and are likely to
  28. change in future releases.
  29. Section&nbsp;<a href="#node_sec_9.10">9.10</a> lists which Scheme functions
  30. call which C functions.</p>
  31. <p>
  32. Scheme&nbsp;48's POSIX interface will likely change significantly in the
  33. future.
  34. The implementation is new and may have significant bugs.</p>
  35. <p>
  36. The POSIX bindings are available in several structures:</p>
  37. <p>
  38. </p>
  39. <div align=center><table><tr><td>
  40. <table border=0><tr><td valign=top ><tt>posix-processes</tt> </td><td valign=top >fork, exec, and friends </td></tr>
  41. <tr><td valign=top ><tt>posix-process-data</tt> </td><td valign=top >information about processes </td></tr>
  42. <tr><td valign=top ><tt>posix-files</tt> </td><td valign=top >files and directories </td></tr>
  43. <tr><td valign=top ><tt>posix-i/o</tt> </td><td valign=top >operations on ports </td></tr>
  44. <tr><td valign=top ><tt>posix-time</tt> </td><td valign=top >time functions </td></tr>
  45. <tr><td valign=top ><tt>posix-users</tt> </td><td valign=top >users and groups </td></tr>
  46. <tr><td valign=top ><tt>posix-regexps</tt> </td><td valign=top >regular expression matching </td></tr>
  47. <tr><td valign=top ><tt>posix</tt> </td><td valign=top >all of the above
  48. </td></tr></table>
  49. </td></tr></table></div>
  50. <p>
  51. Scheme&nbsp;48's POSIX interface differs from
  52. Scsh's [<a href="manual-Z-H-12.html#node_bib_11">11</a>,&nbsp;<a href="manual-Z-H-12.html#node_bib_12">12</a>] in several ways.
  53. The interface here lacks Scsh's high-level constructs and utilities,
  54. such as the process notation, <tt>awk</tt> procedure, and parsing
  55. utilities.
  56. Scheme&nbsp;48 uses distinct types for some values that Scsh leaves
  57. as symbols or unboxed integers; these include file types, file modes,
  58. and user and group ids.
  59. Many of the names and other interface details are different, as well.</p>
  60. <p>
  61. </p>
  62. <a name="node_sec_9.1"></a>
  63. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_9.1">9.1&nbsp;&nbsp;Process primitives</a></h2>
  64. <p>The procedures described in this section control the creation of processes
  65. and the execution of programs.
  66. They are in the structures <tt>posix-process</tt> and <tt>posix</tt>.</p>
  67. <p>
  68. </p>
  69. <a name="node_sec_9.1.1"></a>
  70. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.1.1">9.1.1&nbsp;&nbsp;Process creation and termination</a></h3>
  71. <p></p>
  72. <p>
  73. </p>
  74. <ul>
  75. <li><p><tt>(fork<i></i>)&nbsp;-&gt;&nbsp;<i>process-id or <tt>#f</tt></i></tt><a name="node_idx_688"></a>
  76. </p>
  77. <li><p><tt>(fork-and-forget<i> thunk</i>)</tt><a name="node_idx_690"></a>
  78. </p>
  79. </ul><p>
  80. <tt>Fork</tt> creates a new child process and returns the child's process-id in
  81. the parent and <tt>#f</tt> in the child.
  82. <tt>Fork-and-forget</tt> calls <i>thunk</i> in a new process; no process-id
  83. is returned.
  84. <tt>Fork-and-forget</tt> uses an intermediate process to avoid creating
  85. a zombie process.</p>
  86. <p>
  87. </p>
  88. <ul>
  89. <li><p><tt>(process-id?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_692"></a>
  90. </p>
  91. <li><p><tt>(process-id=?<i> process-id0 process-id1</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_694"></a>
  92. </p>
  93. <li><p><tt>(process-id-&gt;integer<i> process-id</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_696"></a>
  94. </p>
  95. <li><p><tt>(integer-&gt;process-id<i> integer</i>)&nbsp;-&gt;&nbsp;<i>process-id</i></tt><a name="node_idx_698"></a>
  96. </p>
  97. </ul><p>
  98. <tt>Process-id?</tt> is a predicate for process-ids,
  99. <tt>process-id=?</tt> compares two to see if they are the same,
  100. and <tt>process-id-uid</tt> returns the actual Unix id.
  101. <tt>Process-id-&gt;integer</tt> and <tt>integer-&gt;process-id</tt>
  102. convert process ids to and from integers.</p>
  103. <p>
  104. </p>
  105. <ul>
  106. <li><p><tt>(process-id-exit-status<i> process-id</i>)&nbsp;-&gt;&nbsp;<i>integer or <tt>#f</tt></i></tt><a name="node_idx_700"></a>
  107. </p>
  108. <li><p><tt>(process-id-terminating-signal<i> process-id</i>)&nbsp;-&gt;&nbsp;<i>signal or <tt>#f</tt></i></tt><a name="node_idx_702"></a>
  109. </p>
  110. <li><p><tt>(wait-for-child-process<i> process-id</i>)</tt><a name="node_idx_704"></a>
  111. </p>
  112. </ul><p>
  113. If a process terminates normally
  114. <tt>process-id-exit-status</tt> will return its exit status.
  115. If the process is still running or was terminated by a signal then
  116. <tt>process-id-exit-status</tt> will return <tt>#f</tt>.
  117. Similarly, if a child process was terminated by a signal
  118. <tt>process-id-terminating-signal</tt> will return that signal and
  119. will return <tt>#f</tt> if the process is still running or terminated
  120. normally.
  121. <tt>Wait-for-child-process</tt> blocks until the child process terminates.
  122. Scheme&nbsp;48 may reap child processes before the user requests their
  123. exit status, but it does not always do so.</p>
  124. <p>
  125. </p>
  126. <ul>
  127. <li><p><tt>(exit<i> status</i>)</tt><a name="node_idx_706"></a>
  128. </p>
  129. </ul><p>
  130. Terminates the current process with the integer <i>status</i>
  131. as its exit status.</p>
  132. <p>
  133. </p>
  134. <a name="node_sec_9.1.2"></a>
  135. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.1.2">9.1.2&nbsp;&nbsp;<tt>Exec</tt></a></h3>
  136. <p></p>
  137. <ul>
  138. <li><p><tt>(exec<i> program-name arg0 <tt>...</tt></i>)</tt><a name="node_idx_708"></a>
  139. </p>
  140. <li><p><tt>(exec-with-environment<i> program-name env arg0 <tt>...</tt></i>)</tt><a name="node_idx_710"></a>
  141. </p>
  142. <li><p><tt>(exec-file<i> filename arg0 <tt>...</tt></i>)</tt><a name="node_idx_712"></a>
  143. </p>
  144. <li><p><tt>(exec-file-with-environment<i> filename env arg0 <tt>...</tt></i>)</tt><a name="node_idx_714"></a>
  145. </p>
  146. <li><p><tt>(exec-with-alias<i> name lookup? maybe-env arguments</i>)</tt><a name="node_idx_716"></a>
  147. </p>
  148. </ul><p>
  149. All of these replace the current program with a new one.
  150. They differ in how the new program is found, what its environment is,
  151. and what arguments it is passed.
  152. <tt>Exec</tt> and <tt>exec-with-environment</tt>
  153. look up the new program in the search path,
  154. while <tt>exec-file</tt> and <tt>exec-file-with-environment</tt>
  155. execute a particular file.
  156. The environment is either inherited from the current process
  157. (<tt>exec</tt> and <tt>exec-file</tt>) or given as an argument
  158. (<tt><tt>...</tt>-with-environment</tt>).
  159. <i>Program-name</i> and <i>filename</i> and any <i>arg<sub><em>i</em></sub></i> should
  160. be <i>os-string-thing</i> arguments (see section&nbsp;<a href="manual-Z-H-7.html#node_sec_5.15">5.15</a>.
  161. <i>Env</i> should be a list of <i>os-string-thing</i> arguments of the form
  162. <tt>&quot;<i>name</i>=<i>value</i>&quot;</tt>.
  163. The first four procedures add their first argument, <i>program-name</i> or
  164. <i>filename</i>, before the <i>arg0 <tt>...</tt></i> arguments.</p>
  165. <p>
  166. <tt>Exec-with-alias</tt> is an omnibus procedure that subsumes the other
  167. four.
  168. <i>Name</i> is looked up in the search path if <i>lookup?</i> is true
  169. and is used as a filename otherwise.
  170. <i>Maybe-env</i> is either a list of <i>os-string-thing</i>s for the environment of the
  171. new program or <tt>#f</tt> in which case the new program inherits its
  172. environment from the current one.
  173. <i>Arguments</i> should be a list of <i>os-string-thing</i>s; unlike with the other four
  174. procedures, <i>name</i> is not added to this list (hence <tt>-with-alias</tt>).</p>
  175. <p>
  176. </p>
  177. <a name="node_sec_9.2"></a>
  178. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_9.2">9.2&nbsp;&nbsp;Signals</a></h2>
  179. <p>There are two varieties of signals available, <em>named</em> and <em>anonymous</em>.
  180. A named signal is one for which we have a symbolic name, such as <tt>kill</tt>
  181. or <tt>pipe</tt>.
  182. Anonymous signals, for which we only have the current operating system's
  183. signal number, have no meaning in other operating systems.
  184. Named signals preserve their meaning in image files.
  185. Not all named signals are available from all OS's and
  186. there may be multiple names for a single OS signal number.</p>
  187. <p>
  188. </p>
  189. <ul>
  190. <li><p><tt>(signal <i>signal-name</i>)&nbsp;-&gt;&nbsp;<i>signal</i></tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(syntax)
  191. </p>
  192. <li><p><tt>(name-&gt;signal<i> symbol</i>)&nbsp;-&gt;&nbsp;<i>signal or <tt>#f</tt></i></tt><a name="node_idx_718"></a>
  193. </p>
  194. <li><p><tt>(integer-&gt;signal<i> integer</i>)&nbsp;-&gt;&nbsp;<i>signal</i></tt><a name="node_idx_720"></a>
  195. </p>
  196. <li><p><tt>(signal?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_722"></a>
  197. </p>
  198. <li><p><tt>(signal-name<i> signal</i>)&nbsp;-&gt;&nbsp;<i>symbol or <tt>#f</tt></i></tt><a name="node_idx_724"></a>
  199. </p>
  200. <li><p><tt>(signal-os-number<i> signal</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_726"></a>
  201. </p>
  202. <li><p><tt>(signal=?<i> signal0 signal1</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_728"></a>
  203. </p>
  204. </ul><p>
  205. The syntax <tt>signal</tt> returns a (named) signal associated with
  206. <i>signal-name</i>.
  207. <tt>Name-&gt;signal</tt> returns a (named) signal or <tt>#f</tt> if the
  208. the signal <i>name</i> is not supported by the operating system.
  209. The signal returned by <tt>integer-&gt;signal</tt> is a named signal if
  210. <i>integer</i> corresponds to a named signal in the current operating
  211. system; otherwise it returns an anonymous signal.
  212. <tt>Signal-name</tt> returns a symbol if <i>signal</i> is named and
  213. <tt>#f</tt> if it is anonymous.
  214. <tt>Signal=?</tt> returns <tt>#t</tt> if <i>signal0</i> and <i>signal1</i>
  215. have the same operating system number and <tt>#f</tt> if they do not.</p>
  216. <p>
  217. </p>
  218. <a name="node_sec_9.2.1"></a>
  219. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.2.1">9.2.1&nbsp;&nbsp;POSIX signals</a></h3>
  220. <p>The following lists the names of the POSIX signals.
  221. </p>
  222. <div align=center><table><tr><td>
  223. <table border=0><tr><td valign=top ><tt>abrt</tt> </td><td valign=top >abort - abnormal termination (as by abort()) </td></tr>
  224. <tr><td valign=top ><tt>alrm</tt> </td><td valign=top >alarm - timeout signal (as by alarm()) </td></tr>
  225. <tr><td valign=top ><tt>fpe </tt> </td><td valign=top >floating point exception </td></tr>
  226. <tr><td valign=top ><tt>hup </tt> </td><td valign=top >hangup - hangup on controlling terminal or death of
  227. controlling process </td></tr>
  228. <tr><td valign=top ><tt>ill </tt> </td><td valign=top >illegal instruction </td></tr>
  229. <tr><td valign=top ><tt>int </tt> </td><td valign=top >interrupt - interaction attention </td></tr>
  230. <tr><td valign=top ><tt>kill</tt> </td><td valign=top >kill - termination signal, cannot be caught or ignored </td></tr>
  231. <tr><td valign=top ><tt>pipe</tt> </td><td valign=top >pipe - write on a pipe with no readers </td></tr>
  232. <tr><td valign=top ><tt>quit</tt> </td><td valign=top >quit - interaction termination </td></tr>
  233. <tr><td valign=top ><tt>segv</tt> </td><td valign=top >segmentation violation - invalid memory reference </td></tr>
  234. <tr><td valign=top ><tt>term</tt> </td><td valign=top >termination - termination signal </td></tr>
  235. <tr><td valign=top ><tt>usr1</tt> </td><td valign=top >user1 - for use by applications </td></tr>
  236. <tr><td valign=top ><tt>usr2</tt> </td><td valign=top >user2 - for use by applications </td></tr>
  237. <tr><td valign=top ><tt>chld</tt> </td><td valign=top >child - child process stopped or terminated </td></tr>
  238. <tr><td valign=top ><tt>cont</tt> </td><td valign=top >continue - continue if stopped </td></tr>
  239. <tr><td valign=top ><tt>stop</tt> </td><td valign=top >stop - cannot be caught or ignored </td></tr>
  240. <tr><td valign=top ><tt>tstp</tt> </td><td valign=top >interactive stop </td></tr>
  241. <tr><td valign=top ><tt>ttin</tt> </td><td valign=top >read from control terminal attempted by background process </td></tr>
  242. <tr><td valign=top ><tt>ttou</tt> </td><td valign=top >write to control terminal attempted by background process </td></tr>
  243. <tr><td valign=top ><tt>bus </tt> </td><td valign=top >bus error - access to undefined portion of memory </td></tr>
  244. <tr><td valign=top ></td></tr></table>
  245. </td></tr></table></div>
  246. <p>
  247. </p>
  248. <a name="node_sec_9.2.2"></a>
  249. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.2.2">9.2.2&nbsp;&nbsp;Other signals</a></h3>
  250. <p>The following lists the names of the non-POSIX signals that the system is
  251. currently aware of.
  252. </p>
  253. <div align=center><table><tr><td>
  254. <table border=0><tr><td valign=top ><tt>trap </tt> </td><td valign=top >trace or breakpoint trap </td></tr>
  255. <tr><td valign=top ><tt>iot </tt> </td><td valign=top >IOT trap - a synonym for ABRT </td></tr>
  256. <tr><td valign=top ><tt>emt </tt> </td><td valign=top ></td></tr>
  257. <tr><td valign=top ><tt>sys </tt> </td><td valign=top >bad argument to routine (SVID) </td></tr>
  258. <tr><td valign=top ><tt>stkflt</tt> </td><td valign=top >stack fault on coprocessor </td></tr>
  259. <tr><td valign=top ><tt>urg </tt> </td><td valign=top >urgent condition on socket (4.2 BSD) </td></tr>
  260. <tr><td valign=top ><tt>io </tt> </td><td valign=top >I/O now possible (4.2 BSD) </td></tr>
  261. <tr><td valign=top ><tt>poll </tt> </td><td valign=top >A synonym for SIGIO (System V) </td></tr>
  262. <tr><td valign=top ><tt>cld </tt> </td><td valign=top >A synonym for SIGCHLD </td></tr>
  263. <tr><td valign=top ><tt>xcpu </tt> </td><td valign=top >CPU time limit exceeded (4.2 BSD) </td></tr>
  264. <tr><td valign=top ><tt>xfsz </tt> </td><td valign=top >File size limit exceeded (4.2 BSD) </td></tr>
  265. <tr><td valign=top ><tt>vtalrm</tt> </td><td valign=top >Virtual alarm clock (4.2 BSD) </td></tr>
  266. <tr><td valign=top ><tt>prof </tt> </td><td valign=top >Profile alarm clock </td></tr>
  267. <tr><td valign=top ><tt>pwr </tt> </td><td valign=top >Power failure (System V) </td></tr>
  268. <tr><td valign=top ><tt>info </tt> </td><td valign=top >A synonym for SIGPWR </td></tr>
  269. <tr><td valign=top ><tt>lost </tt> </td><td valign=top >File lock lost </td></tr>
  270. <tr><td valign=top ><tt>winch </tt> </td><td valign=top >Window resize signal (4.3 BSD, Sun) </td></tr>
  271. <tr><td valign=top ><tt>unused</tt> </td><td valign=top >Unused signal </td></tr>
  272. <tr><td valign=top ></td></tr></table></td></tr></table></div>
  273. <p>
  274. </p>
  275. <a name="node_sec_9.2.3"></a>
  276. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.2.3">9.2.3&nbsp;&nbsp;Sending signals</a></h3>
  277. <p></p>
  278. <ul>
  279. <li><p><tt>(signal-process<i> process-id signal</i>)</tt><a name="node_idx_730"></a>
  280. </p>
  281. </ul><p>
  282. Send <i>signal</i> to the process corresponding to <i>process-id</i>.</p>
  283. <p>
  284. </p>
  285. <a name="node_sec_9.2.4"></a>
  286. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.2.4">9.2.4&nbsp;&nbsp;Receiving signals</a></h3>
  287. <p>Signals received by the Scheme process can be obtained via one or more
  288. signal-queues.
  289. Each signal queue has a list of monitored signals and a queue of
  290. received signals that have yet to be read from the signal-queue.
  291. When the Scheme process receives a signal that signal is added to the
  292. received-signal queues of all signal-queues which are currently monitoring
  293. that particular signal.</p>
  294. <p>
  295. </p>
  296. <ul>
  297. <li><p><tt>(make-signal-queue<i> signals</i>)&nbsp;-&gt;&nbsp;<i>signal-queue</i></tt><a name="node_idx_732"></a>
  298. </p>
  299. <li><p><tt>(signal-queue?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_734"></a>
  300. </p>
  301. <li><p><tt>(signal-queue-monitored-signals<i> signal-queue</i>)&nbsp;-&gt;&nbsp;<i>list of signals</i></tt><a name="node_idx_736"></a>
  302. </p>
  303. <li><p><tt>(dequeue-signal!<i> signal-queue</i>)&nbsp;-&gt;&nbsp;<i>signal</i></tt><a name="node_idx_738"></a>
  304. </p>
  305. <li><p><tt>(maybe-dequeue-signal!<i> signal-queue</i>)&nbsp;-&gt;&nbsp;<i>signal or <tt>#f</tt></i></tt><a name="node_idx_740"></a>
  306. </p>
  307. </ul><p>
  308. <tt>Make-signal-queue</tt> returns a new signal-queue that will monitor
  309. the signals in the list <i>signals</i>.
  310. <tt>Signal-queue?</tt> is a predicate for signal queues.
  311. <tt>Signal-queue-monitored-signals</tt> returns a list of the signals
  312. currently monitored by <i>signal-queue</i>.
  313. <tt>Dequeue-signal!</tt> and <tt>maybe-dequeue-signal</tt> both return
  314. the next received-but-unread signal from <i>signal-queue</i>.
  315. If <i>signal-queue</i>'s queue of signals is empty <tt>dequeue-signal!</tt>
  316. blocks until an appropriate signal is received.
  317. <tt>Maybe-dequeue-signal!</tt> does not block; it returns <tt>#f</tt> instead.</p>
  318. <p>
  319. There is a bug in the current system that causes an erroneous deadlock
  320. error if threads are blocked waiting for signals and no other threads
  321. are available to run.
  322. A work around is to create a thread that sleeps for a long time, which
  323. prevents any deadlock errors (including real ones):
  324. </p>
  325. <pre class=verbatim>&gt; ,open threads
  326. &gt; (spawn (lambda ()
  327. ; Sleep for a year
  328. (sleep (* 1000 60 60 24 365))))
  329. </pre><p></p>
  330. <p>
  331. </p>
  332. <ul>
  333. <li><p><tt>(add-signal-queue-signal!<i> signal-queue signal</i>)</tt><a name="node_idx_742"></a>
  334. </p>
  335. <li><p><tt>(remove-signal-queue-signal!<i> signal-queue signal</i>)</tt><a name="node_idx_744"></a>
  336. </p>
  337. </ul><p>
  338. These two procedures can be used to add or remove signals from a
  339. signal-queue's list of monitored signals.
  340. When a signal is removed from a signal-queue's list of monitored signals
  341. any occurances of the signal are removed from that signal-queue's pending
  342. signals.
  343. In other words, <tt>dequeue-signal!</tt> and <tt>maybe-dequeue-signal!</tt>
  344. will only return signals that are currently on the signal-queue's list
  345. of signals.</p>
  346. <p>
  347. </p>
  348. <a name="node_sec_9.3"></a>
  349. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_9.3">9.3&nbsp;&nbsp;Process environment</a></h2>
  350. <p>These are in structures <tt>posix-process-data</tt> and <tt>posix</tt>.</p>
  351. <p>
  352. </p>
  353. <a name="node_sec_9.3.1"></a>
  354. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.3.1">9.3.1&nbsp;&nbsp;Process identification</a></h3>
  355. <p></p>
  356. <ul>
  357. <li><p><tt>(get-process-id<i></i>)&nbsp;-&gt;&nbsp;<i> process-id</i></tt><a name="node_idx_746"></a>
  358. </p>
  359. <li><p><tt>(get-parent-process-id<i></i>)&nbsp;-&gt;&nbsp;<i> process-id</i></tt><a name="node_idx_748"></a>
  360. </p>
  361. </ul><p>
  362. These return the process ids of the current process and its parent.
  363. See section&nbsp;<a href="#node_sec_9.1.1">9.1.1</a> for operations on process ids.</p>
  364. <p>
  365. </p>
  366. <ul>
  367. <li><p><tt>(get-user-id<i></i>)&nbsp;-&gt;&nbsp;<i> user-id</i></tt><a name="node_idx_750"></a>
  368. </p>
  369. <li><p><tt>(get-effective-user-id<i></i>)&nbsp;-&gt;&nbsp;<i> user-id</i></tt><a name="node_idx_752"></a>
  370. </p>
  371. <li><p><tt>(set-user-id!<i> user-id</i>)</tt><a name="node_idx_754"></a>
  372. </p>
  373. </ul><p></p>
  374. <p>
  375. </p>
  376. <ul>
  377. <li><p><tt>(get-group-id<i></i>)&nbsp;-&gt;&nbsp;<i> group-id</i></tt><a name="node_idx_756"></a>
  378. </p>
  379. <li><p><tt>(get-effective-group-id<i></i>)&nbsp;-&gt;&nbsp;<i> group-id</i></tt><a name="node_idx_758"></a>
  380. </p>
  381. <li><p><tt>(set-group-id!<i> group-id</i>)</tt><a name="node_idx_760"></a>
  382. </p>
  383. </ul><p>
  384. Every process has both the original and effective user id and group id.
  385. The effective values may be set, but not the original ones.</p>
  386. <p>
  387. </p>
  388. <ul>
  389. <li><p><tt>(get-groups<i></i>)&nbsp;-&gt;&nbsp;<i> group-ids</i></tt><a name="node_idx_762"></a>
  390. </p>
  391. <li><p><tt>(get-login-name<i></i>)&nbsp;-&gt;&nbsp;<i> os-string</i></tt><a name="node_idx_764"></a>
  392. </p>
  393. </ul><p>
  394. <tt>Get-groups</tt> returns a list of the supplementary groups of the
  395. current process.
  396. <tt>Get-login-name</tt> returns a user name for the current process.</p>
  397. <p>
  398. </p>
  399. <p>
  400. </p>
  401. <p>
  402. </p>
  403. <a name="node_sec_9.3.2"></a>
  404. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.3.2">9.3.2&nbsp;&nbsp;Environment variables</a></h3>
  405. <p></p>
  406. <ul>
  407. <li><p><tt>(lookup-environment-variable<i> os-string-thing</i>)&nbsp;-&gt;&nbsp;<i>os-string or <tt>#f</tt></i></tt><a name="node_idx_766"></a>
  408. </p>
  409. <li><p><tt>(environment-alist<i></i>)&nbsp;-&gt;&nbsp;<i>alist</i></tt><a name="node_idx_768"></a>
  410. </p>
  411. </ul><p>
  412. <tt>Lookup-environment-variable</tt> looks up its argument in the
  413. environment list and returns the corresponding value or <tt>#f</tt>
  414. if there is none.
  415. <tt>Environment-alist</tt> returns the entire environment as a list of
  416. <tt>(<i>name-os-string</i> . <i>value-os-string</i>)</tt> pairs.</p>
  417. <p>
  418. </p>
  419. <a name="node_sec_9.4"></a>
  420. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_9.4">9.4&nbsp;&nbsp;Users and groups</a></h2>
  421. <p><i>User-id</i>s and <i>group-id</i>s are boxed integers representing
  422. Unix users and groups.
  423. The procedures in this section are in structures <tt>posix-users</tt> and
  424. <tt>posix</tt>.</p>
  425. <p>
  426. </p>
  427. <ul>
  428. <li><p><tt>(user-id?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_770"></a>
  429. </p>
  430. <li><p><tt>(user-id=?<i> user-id0 user-id1</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_772"></a>
  431. </p>
  432. <li><p><tt>(user-id-&gt;integer<i> user-id</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_774"></a>
  433. </p>
  434. <li><p><tt>(integer-&gt;user-id<i> integer</i>)&nbsp;-&gt;&nbsp;<i>user-id</i></tt><a name="node_idx_776"></a>
  435. </p>
  436. </ul><p></p>
  437. <p>
  438. </p>
  439. <ul>
  440. <li><p><tt>(group-id?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_778"></a>
  441. </p>
  442. <li><p><tt>(group-id=?<i> group-id0 group-id1</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_780"></a>
  443. </p>
  444. <li><p><tt>(group-id-&gt;integer<i> group-id</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_782"></a>
  445. </p>
  446. <li><p><tt>(integer-&gt;group-id<i> integer</i>)&nbsp;-&gt;&nbsp;<i>group-id</i></tt><a name="node_idx_784"></a>
  447. </p>
  448. </ul><p>
  449. User-ids and group-ids have their own
  450. own predicates and comparison, boxing, and unboxing functions.</p>
  451. <p>
  452. </p>
  453. <ul>
  454. <li><p><tt>(user-id-&gt;user-info<i> user-id</i>)&nbsp;-&gt;&nbsp;<i>user-info</i></tt><a name="node_idx_786"></a>
  455. </p>
  456. <li><p><tt>(name-&gt;user-info<i> os-string</i>)&nbsp;-&gt;&nbsp;<i>user-info</i></tt><a name="node_idx_788"></a>
  457. </p>
  458. </ul><p>
  459. These return the user info for a user identified by user-id or name.</p>
  460. <p>
  461. </p>
  462. <ul>
  463. <li><p><tt>(user-info?<i> x</i>)&nbsp;-&gt;&nbsp;<i> boolean</i></tt><a name="node_idx_790"></a>
  464. </p>
  465. <li><p><tt>(user-info-name<i> user-info</i>)&nbsp;-&gt;&nbsp;<i> os-string</i></tt><a name="node_idx_792"></a>
  466. </p>
  467. <li><p><tt>(user-info-id<i> user-info</i>)&nbsp;-&gt;&nbsp;<i> user-id</i></tt><a name="node_idx_794"></a>
  468. </p>
  469. <li><p><tt>(user-info-group<i> user-info</i>)&nbsp;-&gt;&nbsp;<i> group-id</i></tt><a name="node_idx_796"></a>
  470. </p>
  471. <li><p><tt>(user-info-home-directory<i> user-info</i>)&nbsp;-&gt;&nbsp;<i> os-string</i></tt><a name="node_idx_798"></a>
  472. </p>
  473. <li><p><tt>(user-info-shell<i> user-info</i>)&nbsp;-&gt;&nbsp;<i> os-string</i></tt><a name="node_idx_800"></a>
  474. </p>
  475. </ul><p>
  476. A <tt>user-info</tt> contains information about a user.
  477. Available are the user's name, id, group, home directory, and shell.</p>
  478. <p>
  479. </p>
  480. <ul>
  481. <li><p><tt>(group-id-&gt;group-info<i> group-id</i>)&nbsp;-&gt;&nbsp;<i>group-info</i></tt><a name="node_idx_802"></a>
  482. </p>
  483. <li><p><tt>(name-&gt;group-info<i> os-string</i>)&nbsp;-&gt;&nbsp;<i>group-info</i></tt><a name="node_idx_804"></a>
  484. </p>
  485. </ul><p>
  486. These return the group info for a group identified by group-id or name.</p>
  487. <p>
  488. </p>
  489. <ul>
  490. <li><p><tt>(group-info?<i> x</i>)&nbsp;-&gt;&nbsp;<i> boolean</i></tt><a name="node_idx_806"></a>
  491. </p>
  492. <li><p><tt>(group-info-name<i> group-info</i>)&nbsp;-&gt;&nbsp;<i> os-string</i></tt><a name="node_idx_808"></a>
  493. </p>
  494. <li><p><tt>(group-info-id<i> group-info</i>)&nbsp;-&gt;&nbsp;<i> group-id</i></tt><a name="node_idx_810"></a>
  495. </p>
  496. <li><p><tt>(group-info-members<i> group-info</i>)&nbsp;-&gt;&nbsp;<i> user-ids</i></tt><a name="node_idx_812"></a>
  497. </p>
  498. </ul><p>
  499. A <tt>group-info</tt> contains information about a group.
  500. Available are the group's name, id, and a list of members.</p>
  501. <p>
  502. </p>
  503. <a name="node_sec_9.5"></a>
  504. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_9.5">9.5&nbsp;&nbsp;OS and machine identification</a></h2>
  505. <p>These procedures return strings that are supposed to identify the current
  506. OS and machine.
  507. The POSIX standard does not indicate the format of the strings.
  508. The procedures are in structures <tt>posix-platform-names</tt> and <tt>posix</tt>.</p>
  509. <p>
  510. </p>
  511. <ul>
  512. <li><p><tt>(os-name<i></i>)&nbsp;-&gt;&nbsp;<i>string</i></tt><a name="node_idx_814"></a>
  513. </p>
  514. <li><p><tt>(os-node-name<i></i>)&nbsp;-&gt;&nbsp;<i>string</i></tt><a name="node_idx_816"></a>
  515. </p>
  516. <li><p><tt>(os-release-name<i></i>)&nbsp;-&gt;&nbsp;<i>string</i></tt><a name="node_idx_818"></a>
  517. </p>
  518. <li><p><tt>(os-version-name<i></i>)&nbsp;-&gt;&nbsp;<i>string</i></tt><a name="node_idx_820"></a>
  519. </p>
  520. <li><p><tt>(machine-name<i></i>)&nbsp;-&gt;&nbsp;<i>string</i></tt><a name="node_idx_822"></a>
  521. </p>
  522. </ul><p></p>
  523. <p>
  524. </p>
  525. <p>
  526. </p>
  527. <a name="node_sec_9.6"></a>
  528. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_9.6">9.6&nbsp;&nbsp;Files and directories</a></h2>
  529. <p>These procedures are in structures <tt>posix-files</tt> and <tt>posix</tt>.</p>
  530. <p>
  531. </p>
  532. <a name="node_sec_9.6.1"></a>
  533. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.6.1">9.6.1&nbsp;&nbsp;Directory streams</a></h3>
  534. <p>Directory streams are like input ports, with each read operation
  535. returning the next name in the directory.</p>
  536. <p>
  537. </p>
  538. <ul>
  539. <li><p><tt>(open-directory-stream<i> name</i>)&nbsp;-&gt;&nbsp;<i>directory</i></tt><a name="node_idx_824"></a>
  540. </p>
  541. <li><p><tt>(directory-stream?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_826"></a>
  542. </p>
  543. <li><p><tt>(read-directory-stream<i> directory</i>)&nbsp;-&gt;&nbsp;<i>name or <tt>#f</tt></i></tt><a name="node_idx_828"></a>
  544. </p>
  545. <li><p><tt>(close-directory-stream<i> directory</i>)</tt><a name="node_idx_830"></a>
  546. </p>
  547. </ul><p>
  548. <tt>Open-directory-stream</tt> opens a new directory stream.
  549. <tt>Directory-stream?</tt> is a predicate that recognizes directory streams.
  550. <tt>Read-directory-stream</tt> returns the next name in the directory or
  551. <tt>#f</tt> if all names have been read.
  552. <tt>Close-directory-stream</tt> closes a directory stream.</p>
  553. <p>
  554. </p>
  555. <ul>
  556. <li><p><tt>(list-directory<i> name</i>)&nbsp;-&gt;&nbsp;<i>list of os-strings</i></tt><a name="node_idx_832"></a>
  557. </p>
  558. </ul><p>
  559. This is the obvious utility; it returns a list of the names in directory
  560. <i>name</i>.</p>
  561. <p>
  562. </p>
  563. <a name="node_sec_9.6.2"></a>
  564. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.6.2">9.6.2&nbsp;&nbsp;Working directory</a></h3>
  565. <p></p>
  566. <ul>
  567. <li><p><tt>(working-directory<i></i>)&nbsp;-&gt;&nbsp;<i>os-string</i></tt><a name="node_idx_834"></a>
  568. </p>
  569. <li><p><tt>(set-working-directory!<i> os-string-thing</i>)</tt><a name="node_idx_836"></a>
  570. </p>
  571. </ul><p>
  572. These return and set the working directory.</p>
  573. <p>
  574. </p>
  575. <a name="node_sec_9.6.3"></a>
  576. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.6.3">9.6.3&nbsp;&nbsp;File creation and removal</a></h3>
  577. <p></p>
  578. <ul>
  579. <li><p><tt>(open-file<i> path file-options</i>)&nbsp;-&gt;&nbsp;<i>port</i></tt><a name="node_idx_838"></a>
  580. </p>
  581. <li><p><tt>(open-file<i> path file-options file-mode</i>)&nbsp;-&gt;&nbsp;<i>port</i></tt><a name="node_idx_840"></a>
  582. </p>
  583. </ul><p>
  584. <tt>Open-file</tt> opens a port to the file named by <i>path</i>, which
  585. must be a <i>os-string-thing</i> argument.
  586. The <i>file-options</i> argument determines various aspects of the
  587. returned port.
  588. The optional <i>file-mode</i> argument is used only if the file to be opened
  589. does not already exist.
  590. The returned port is an input port if <i>file-options</i> includes
  591. <tt>read-only</tt>; otherwise it returns an output port.
  592. <tt>Dup-switching-mode</tt> can be used to open an input port for
  593. output ports opened with the <tt>read/write</tt> option.</p>
  594. <p>
  595. </p>
  596. <ul>
  597. <li><p><tt>(file-options <i>file-option-name</i> <tt>...</tt>)&nbsp;-&gt;&nbsp;<i>file-options</i></tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(syntax)
  598. </p>
  599. <li><p><tt>(file-options-on?<i> file-options file-options</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_842"></a>
  600. </p>
  601. <li><p><tt>(file-options-union<i> file-options file-options</i>)&nbsp;-&gt;&nbsp;<i>file-options</i></tt><a name="node_idx_844"></a>
  602. </p>
  603. </ul><p>
  604. The syntax <tt>file-options</tt> returns a file-option with the
  605. indicated options set.
  606. <tt>File-options-on?</tt> returns true if its first argument includes all of
  607. the options listed in the second argument. <tt>File-options-union</tt>
  608. returns a file-options argument containing exactly all of the options
  609. listed in either argument.
  610. The following file options may be used with <tt>open-file</tt>.</p>
  611. <p>
  612. </p>
  613. <div align=center><table><tr><td>
  614. <table border=0><tr><td valign=top ></td><td valign=top ><tt>create</tt> </td><td valign=top >create file if it does not already exist; a file-mode argument
  615. is required with this option </td></tr>
  616. <tr><td valign=top ></td><td valign=top ><tt>exclusive</tt> </td><td valign=top >an error will be raised if this option and <tt>create</tt>
  617. are both set and the file already exists </td></tr>
  618. <tr><td valign=top ></td><td valign=top ><tt>no-controlling-tty</tt> </td><td valign=top >if <i>path</i> is a terminal device this option
  619. causes the terminal to not become the controlling terminal of the process</td></tr>
  620. <tr><td valign=top ></td><td valign=top ><tt>truncate</tt> </td><td valign=top >file is truncated </td></tr>
  621. <tr><td valign=top ></td><td valign=top ><tt>append</tt> </td><td valign=top >writes are appended to existing contents </td></tr>
  622. <tr><td valign=top ></td><td valign=top ><tt>nonblocking</tt> </td><td valign=top >read and write operations do not block </td></tr>
  623. <tr><td valign=top ></td><td valign=top ><tt>read-only</tt> </td><td valign=top >port may not be written </td></tr>
  624. <tr><td valign=top ></td><td valign=top ><tt>read-write</tt> </td><td valign=top >file descriptor may be read or written </td></tr>
  625. <tr><td valign=top ></td><td valign=top ><tt>write-only</tt> </td><td valign=top >port may not be read
  626. </td></tr></table>
  627. </td></tr></table></div>
  628. Only one of the last three options may be used. If
  629. <tt>read-write</tt> is specified, an output port is returned.<p>
  630. For example
  631. </p>
  632. <pre class=verbatim>(open-file &quot;some-file.txt&quot;
  633. (file-options create write-only)
  634. (file-mode read owner-write))
  635. </pre><p>
  636. returns an output port that writes to a newly-created file that can be
  637. read by anyone and written only by the owner.
  638. Once the file exists,
  639. </p>
  640. <pre class=verbatim>(open-file &quot;some-file.txt&quot;
  641. (file-options append write-only))
  642. </pre><p>
  643. will open an output port that appends to the file.</p>
  644. <p>
  645. The <tt>append</tt> and <tt>nonblocking</tt> options and the read/write nature of
  646. the port can be read using <tt>i/o-flags</tt>.
  647. The <tt>append</tt> and <tt>nonblocking</tt> options can be set
  648. using <tt>set-i/o-flags!</tt>.</p>
  649. <p>
  650. To keep port operations from blocking the Scheme&nbsp;48 process, output
  651. ports are set to be nonblocking at the time of creation (input ports
  652. are managed using <tt>select()</tt>).
  653. You can use <tt>set-i/o-flags!</tt> to make an output port blocking, for
  654. example just before a fork, but care should be exercised.
  655. The Scheme&nbsp;48 runtime code may get confused if an I/O operation blocks.</p>
  656. <p>
  657. </p>
  658. <ul>
  659. <li><p><tt>(set-file-creation-mask!<i> file-mode</i>)</tt><a name="node_idx_846"></a>
  660. </p>
  661. </ul><p>
  662. Sets the file creation mask to be <i>file-mode</i>.
  663. Bits set in <i>file-mode</i> are cleared in the modes of any files or
  664. directories created by the current process.</p>
  665. <p>
  666. </p>
  667. <ul>
  668. <li><p><tt>(link<i> existing new</i>)</tt><a name="node_idx_848"></a>
  669. </p>
  670. </ul><p>
  671. Both <i>existing</i> and <i>new</i> must be <i>os-string-thing</i> arguments.
  672. <tt>Link</tt> makes path <i>new</i> be a new link to the file
  673. pointed to by path <i>existing</i>.
  674. The two paths must be in the same file system.</p>
  675. <p>
  676. </p>
  677. <p>
  678. </p>
  679. <ul>
  680. <li><p><tt>(make-directory<i> path file-mode</i>)</tt><a name="node_idx_850"></a>
  681. </p>
  682. <li><p><tt>(make-fifo<i> path file-mode</i>)</tt><a name="node_idx_852"></a>
  683. </p>
  684. </ul><p>
  685. These two procedures make new directories and fifo files. In both
  686. cases, <i>path</i> must be a <i>os-string-thing</i> argument.</p>
  687. <p>
  688. </p>
  689. <p>
  690. </p>
  691. <ul>
  692. <li><p><tt>(unlink<i> path</i>)</tt><a name="node_idx_854"></a>
  693. </p>
  694. <li><p><tt>(remove-directory<i> path</i>)</tt><a name="node_idx_856"></a>
  695. </p>
  696. <li><p><tt>(rename<i> old-path new-path</i>)</tt><a name="node_idx_858"></a>
  697. </p>
  698. </ul><p>
  699. <i>Path</i>, <i>old-path</i> and <i>new-path</i> must all be
  700. <i>os-string-thing</i> arguments.
  701. <tt>Unlink</tt> removes the link indicated by <i>path</i>.
  702. <tt>Remove-directory</tt> removes the indicated (empty) directory.
  703. <tt>Rename</tt> moves the file pointed to by <i>old-path</i> to the
  704. location pointed to by <i>new-path</i> (the two paths must be in
  705. the same file system).
  706. Any other links to the file remain unchanged.</p>
  707. <p>
  708. </p>
  709. <p>
  710. </p>
  711. <ul>
  712. <li><p><tt>(accessible?<i> path access-mode . more-modes</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_860"></a>
  713. </p>
  714. <li><p><tt>(access-mode <i>mode-name</i>)&nbsp;-&gt;&nbsp;<i>access-mode</i></tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(syntax)
  715. </p>
  716. </ul><p>
  717. <tt>Accessible?</tt> returns true if <i>path</i> (which must be a
  718. <i>os-string-thing</i> argument) is a file that
  719. can be accessed in the listed mode.
  720. If more than one mode is specified <tt>accessible?</tt> returns true
  721. if all of the specified modes are permitted.
  722. The <i>mode-name</i>s are: <tt>read</tt>, <tt>write</tt>, <tt>execute</tt>,
  723. <tt>exists</tt>.</p>
  724. <p>
  725. </p>
  726. <a name="node_sec_9.6.4"></a>
  727. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.6.4">9.6.4&nbsp;&nbsp;File information</a></h3>
  728. <p></p>
  729. <ul>
  730. <li><p><tt>(get-file-info<i> path</i>)&nbsp;-&gt;&nbsp;<i>file-info</i></tt><a name="node_idx_862"></a>
  731. </p>
  732. <li><p><tt>(get-file/link-info<i> name</i>)&nbsp;-&gt;&nbsp;<i>file-info</i></tt><a name="node_idx_864"></a>
  733. </p>
  734. <li><p><tt>(get-port-info<i> fd-port</i>)&nbsp;-&gt;&nbsp;<i>file-info</i></tt><a name="node_idx_866"></a>
  735. </p>
  736. </ul><p>
  737. <tt>Get-file-info</tt> and <tt>get-file/link-info</tt> both return
  738. a file info record for the file named by <i>path</i>, which must be a
  739. <i>os-string-thing</i> argument.
  740. <tt>Get-file-info</tt> follows symbolic links while <tt>get-file/link-info</tt>
  741. does not.
  742. <tt>Get-port-info</tt> returns a file info record for the file
  743. which <i>port</i> reads from or writes to.
  744. An error is raised if <i>fd-port</i> does not read from or write to a
  745. file descriptor.</p>
  746. <p>
  747. </p>
  748. <ul>
  749. <li><p><tt>(file-info?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_868"></a>
  750. </p>
  751. <li><p><tt>(file-info-name<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>os-string</i></tt><a name="node_idx_870"></a>
  752. </p>
  753. </ul><p>
  754. <tt>File-info?</tt> is a predicate for file-info records.
  755. <tt>File-info-name</tt> is the name which was used to get <tt>file-info</tt>,
  756. either as passed to <tt>get-file-info</tt> or <tt>get-file/link-info</tt>,
  757. or used to open the port passed to <tt>get-port-info</tt>.</p>
  758. <p>
  759. </p>
  760. <ul>
  761. <li><p><tt>(file-info-type<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>file-type</i></tt><a name="node_idx_872"></a>
  762. </p>
  763. <li><p><tt>(file-type?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_874"></a>
  764. </p>
  765. <li><p><tt>(file-type-name<i> file-type</i>)&nbsp;-&gt;&nbsp;<i>symbol</i></tt><a name="node_idx_876"></a>
  766. </p>
  767. <li><p><tt>(file-type <i>type</i>)&nbsp;-&gt;&nbsp;<i>file-type</i></tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(syntax)
  768. </p>
  769. </ul><p>
  770. <tt>File-info-type</tt> returns the type of the file, as a file-type object
  771. File types may be compared using <tt>eq?</tt>.
  772. The valid file types are:</p>
  773. <p>
  774. </p>
  775. <div align=center><table><tr><td>
  776. <table border=0><tr><td valign=top ><tt>regular</tt> </td></tr>
  777. <tr><td valign=top ><tt>directory</tt> </td></tr>
  778. <tr><td valign=top ><tt>character-device</tt> </td></tr>
  779. <tr><td valign=top ><tt>block-device</tt> </td></tr>
  780. <tr><td valign=top ><tt>fifo</tt> </td></tr>
  781. <tr><td valign=top ><tt>symbolic-link</tt> </td></tr>
  782. <tr><td valign=top ><tt>socket</tt> </td></tr>
  783. <tr><td valign=top ><tt>other</tt>
  784. </td></tr></table>
  785. </td></tr></table></div>
  786. <p>
  787. <tt>Symbolic-link</tt> and <tt>socket</tt> are not required by POSIX.</p>
  788. <p>
  789. </p>
  790. <ul>
  791. <li><p><tt>(file-info-device<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_878"></a>
  792. </p>
  793. <li><p><tt>(file-info-inode<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_880"></a>
  794. </p>
  795. </ul><p>
  796. The device and inode numbers uniquely determine a file.</p>
  797. <p>
  798. </p>
  799. <ul>
  800. <li><p><tt>(file-info-link-count<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_882"></a>
  801. </p>
  802. <li><p><tt>(file-info-size<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_884"></a>
  803. </p>
  804. </ul><p>
  805. These return the number of links to a file and the file size in bytes.
  806. The size is only meaningful for regular files.</p>
  807. <p>
  808. </p>
  809. <ul>
  810. <li><p><tt>(file-info-owner<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>user-id</i></tt><a name="node_idx_886"></a>
  811. </p>
  812. <li><p><tt>(file-info-group<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>group-id</i></tt><a name="node_idx_888"></a>
  813. </p>
  814. <li><p><tt>(file-info-mode<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>file-mode</i></tt><a name="node_idx_890"></a>
  815. </p>
  816. </ul><p>
  817. These return the owner, group, and access mode of a file.</p>
  818. <p>
  819. </p>
  820. <ul>
  821. <li><p><tt>(file-info-last-access<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>time</i></tt><a name="node_idx_892"></a>
  822. </p>
  823. <li><p><tt>(file-info-last-modification<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>time</i></tt><a name="node_idx_894"></a>
  824. </p>
  825. <li><p><tt>(file-info-last-info-change<i> file-info</i>)&nbsp;-&gt;&nbsp;<i>time</i></tt><a name="node_idx_896"></a>
  826. </p>
  827. </ul><p>
  828. These return the time the file was last read, modified, or had its
  829. status modified</p>
  830. <p>
  831. </p>
  832. <a name="node_sec_9.6.5"></a>
  833. <h3><a href="manual-Z-H-2.html#node_toc_node_sec_9.6.5">9.6.5&nbsp;&nbsp;File modes</a></h3>
  834. <p>A file mode is a boxed integer representing a file protection mask.</p>
  835. <p>
  836. </p>
  837. <ul>
  838. <li><p><tt>(file-mode permission-name <tt>...</tt>)&nbsp;-&gt;&nbsp;<i>file-mode</i></tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(syntax)
  839. </p>
  840. <li><p><tt>(file-mode?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_898"></a>
  841. </p>
  842. <li><p><tt>(file-mode+<i> file-mode <tt>...</tt></i>)&nbsp;-&gt;&nbsp;<i>file-mode</i></tt><a name="node_idx_900"></a>
  843. </p>
  844. <li><p><tt>(file-mode-<i> file-mode0 file-mode1</i>)&nbsp;-&gt;&nbsp;<i>file-mode</i></tt><a name="node_idx_902"></a>
  845. </p>
  846. </ul><p>
  847. <tt>File-mode</tt> is syntax for creating file modes.
  848. The mode-names are listed below.
  849. <tt>File-mode?</tt> is a predicate for file modes.
  850. <tt>File-mode+</tt> returns a mode that contains all of permissions of
  851. its arguments.
  852. <tt>File-mode-</tt> returns a mode that has all of the permissions of
  853. <i>file-mode0</i> that are not in <i>file-mode1</i>.</p>
  854. <p>
  855. </p>
  856. <ul>
  857. <li><p><tt>(file-mode=?<i> file-mode0 file-mode1</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_904"></a>
  858. </p>
  859. <li><p><tt>(file-mode&lt;=?<i> file-mode0 file-mode1</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_906"></a>
  860. </p>
  861. <li><p><tt>(file-mode&gt;=?<i> file-mode0 file-mode1</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_908"></a>
  862. </p>
  863. </ul><p>
  864. <tt>File-mode=?</tt> returns true if the two modes are exactly the same.
  865. <tt>File-mode&lt;=?</tt> returns true if <i>file-mode0</i> has a subset
  866. of the permissions of <i>file-mode1</i>.
  867. <tt>File-mode&gt;=?</tt> is <tt>file-mode&lt;=?</tt> with the arguments reversed.</p>
  868. <p>
  869. </p>
  870. <ul>
  871. <li><p><tt>(file-mode-&gt;integer<i> file-mode</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_910"></a>
  872. </p>
  873. <li><p><tt>(integer-&gt;file-mode<i> integer</i>)&nbsp;-&gt;&nbsp;<i>file-mode</i></tt><a name="node_idx_912"></a>
  874. </p>
  875. </ul><p>
  876. <tt>Integer-&gt;file-mode</tt> and <tt>file-mode-&gt;integer</tt> translate file modes
  877. to and from the classic Unix file mode masks.
  878. These may not be the masks used by the underlying OS.</p>
  879. <p>
  880. </p>
  881. <div align=center><table><tr><td>
  882. <table border=0><tr><td valign=top >Permission name </td><td valign=top >Bit mask </td></tr>
  883. <tr><td valign=top ><tt>set-uid</tt> </td><td valign=top ><tt>#o4000</tt> </td><td valign=top >set user id when executing </td></tr>
  884. <tr><td valign=top ><tt>set-gid</tt> </td><td valign=top ><tt>#o2000</tt> </td><td valign=top >set group id when executing </td></tr>
  885. <tr><td valign=top ><tt>owner-read</tt> </td><td valign=top ><tt>#o0400</tt> </td><td valign=top >read by owner </td></tr>
  886. <tr><td valign=top ><tt>owner-write</tt> </td><td valign=top ><tt>#o0200</tt> </td><td valign=top >write by owner </td></tr>
  887. <tr><td valign=top ><tt>owner-exec</tt> </td><td valign=top ><tt>#o0100</tt> </td><td valign=top >execute (or search) by owner </td></tr>
  888. <tr><td valign=top ><tt>group-read</tt> </td><td valign=top ><tt>#o0040</tt> </td><td valign=top >read by group </td></tr>
  889. <tr><td valign=top ><tt>group-write</tt> </td><td valign=top ><tt>#o0020</tt> </td><td valign=top >write by group </td></tr>
  890. <tr><td valign=top ><tt>group-exec</tt> </td><td valign=top ><tt>#o0010</tt> </td><td valign=top >execute (or search) by group </td></tr>
  891. <tr><td valign=top ><tt>other-read</tt> </td><td valign=top ><tt>#o0004</tt> </td><td valign=top >read by others </td></tr>
  892. <tr><td valign=top ><tt>other-write</tt> </td><td valign=top ><tt>#o0002</tt> </td><td valign=top >write by others </td></tr>
  893. <tr><td valign=top ><tt>other-exec</tt> </td><td valign=top ><tt>#o0001</tt> </td><td valign=top >execute (or search) by others </td></tr>
  894. <tr><td valign=top ></td></tr></table>
  895. </td></tr></table></div>
  896. <p>
  897. </p>
  898. <div align=center><table><tr><td>
  899. <table border=0><tr><td valign=top colspan=3>Names for sets of permissions </td></tr>
  900. <tr><td valign=top ><tt>owner</tt> </td><td valign=top ><tt>#o0700</tt> </td><td valign=top >read, write, and execute by owner </td></tr>
  901. <tr><td valign=top ><tt>group</tt> </td><td valign=top ><tt>#o0070</tt> </td><td valign=top >read, write, and execute by group </td></tr>
  902. <tr><td valign=top ><tt>other</tt> </td><td valign=top ><tt>#o0007</tt> </td><td valign=top >read, write, and execute by others </td></tr>
  903. <tr><td valign=top ><tt>read</tt> </td><td valign=top ><tt>#o0444</tt> </td><td valign=top >read by anyone </td></tr>
  904. <tr><td valign=top ><tt>write</tt> </td><td valign=top ><tt>#o0222</tt> </td><td valign=top >write by anyone </td></tr>
  905. <tr><td valign=top ><tt>exec</tt> </td><td valign=top ><tt>#o0111</tt> </td><td valign=top >execute by anyone </td></tr>
  906. <tr><td valign=top ><tt>all</tt> </td><td valign=top ><tt>#o0777</tt> </td><td valign=top >anything by anyone
  907. </td></tr></table>
  908. </td></tr></table></div>
  909. <p>
  910. </p>
  911. <a name="node_sec_9.7"></a>
  912. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_9.7">9.7&nbsp;&nbsp;Time</a></h2>
  913. <p>These procedures are in structures <tt>posix-time</tt> and <tt>posix</tt>.</p>
  914. <p>
  915. </p>
  916. <ul>
  917. <li><p><tt>(make-time<i> integer</i>)&nbsp;-&gt;&nbsp;<i>time</i></tt><a name="node_idx_914"></a>
  918. </p>
  919. <li><p><tt>(current-time<i></i>)&nbsp;-&gt;&nbsp;<i>time</i></tt><a name="node_idx_916"></a>
  920. </p>
  921. <li><p><tt>(time?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_918"></a>
  922. </p>
  923. <li><p><tt>(time-seconds<i> time</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_920"></a>
  924. </p>
  925. </ul><p>
  926. A <tt>time</tt> record contains an integer that represents time as
  927. the number of second since the Unix epoch (00:00:00 GMT, January 1, 1970).
  928. <tt>Make-time</tt> and <tt>current-time</tt> return <tt>time</tt>s, with
  929. <tt>make-time</tt>'s using its argument while <tt>current-time</tt>'s has
  930. the current time.
  931. <tt>Time?</tt> is a predicate that recognizes <tt>time</tt>s and
  932. <tt>time-seconds</tt> returns the number of seconds <i>time</i> represents.</p>
  933. <p>
  934. </p>
  935. <ul>
  936. <li><p><tt>(time=?<i> time time</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_922"></a>
  937. </p>
  938. <li><p><tt>(time&lt;?<i> time time</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_924"></a>
  939. </p>
  940. <li><p><tt>(time&lt;=?<i> time time</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_926"></a>
  941. </p>
  942. <li><p><tt>(time&gt;?<i> time time</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_928"></a>
  943. </p>
  944. <li><p><tt>(time&gt;=?<i> time time</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_930"></a>
  945. </p>
  946. </ul><p>
  947. These perform various comparison operations on the <tt>time</tt>s.</p>
  948. <p>
  949. </p>
  950. <ul>
  951. <li><p><tt>(time-&gt;string<i> time</i>)&nbsp;-&gt;&nbsp;<i>string</i></tt><a name="node_idx_932"></a>
  952. </p>
  953. </ul><p>
  954. <tt>Time-&gt;string</tt> returns a string representation of <i>time</i> in the
  955. following form.
  956. </p>
  957. <pre class=verbatim>&quot;Wed Jun 30 21:49:08 1993
  958. &quot;
  959. </pre><p></p>
  960. <p>
  961. </p>
  962. <p>
  963. </p>
  964. <a name="node_sec_9.8"></a>
  965. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_9.8">9.8&nbsp;&nbsp;I/O</a></h2>
  966. <p>These procedures are in structures <tt>posix-i/o</tt> and <tt>posix</tt>.</p>
  967. <p>
  968. </p>
  969. <p>
  970. </p>
  971. <p>
  972. </p>
  973. <p>
  974. </p>
  975. <p>
  976. </p>
  977. <p>
  978. </p>
  979. <p>
  980. </p>
  981. <ul>
  982. <li><p><tt>(open-pipe<i></i>)&nbsp;-&gt;&nbsp;<i>input-port + output-port</i></tt><a name="node_idx_934"></a>
  983. </p>
  984. </ul><p>
  985. <tt>Open-pipe</tt> creates a new pipe and returns the two ends as an
  986. input port and an output port.</p>
  987. <p>
  988. </p>
  989. <p>
  990. A <em>file descriptor</em> port (or <i>fd-port</i>)
  991. is a port that reads to or writes from an OS file descriptor.
  992. Fd-ports are returned by <tt>open-input-file</tt>, <tt>open-output-file</tt>,
  993. <tt>open-file</tt>, <tt>open-pipe</tt>, and other procedures.
  994. </p>
  995. <p>
  996. </p>
  997. <ul>
  998. <li><p><tt>(fd-port?<i> port</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_936"></a>
  999. </p>
  1000. <li><p><tt>(port-&gt;fd<i> port</i>)&nbsp;-&gt;&nbsp;<i>integer or <tt>#f</tt></i></tt><a name="node_idx_938"></a>
  1001. </p>
  1002. </ul><p>
  1003. <tt>Fd-port?</tt> returns true if its argument is an fd-port.
  1004. <tt>Port-&gt;fd</tt> returns the file descriptor associated with
  1005. or <tt>#f</tt> if <i>port</i> is not an fd-port.</p>
  1006. <p>
  1007. </p>
  1008. <ul>
  1009. <li><p><tt>(remap-file-descriptors<i> fd-spec <tt>...</tt></i>)</tt><a name="node_idx_940"></a>
  1010. </p>
  1011. </ul><p>
  1012. <tt>Remap-file-descriptors</tt> reassigns file descriptors to ports.
  1013. The <i>fd-specs</i> indicate which port is to be mapped to each
  1014. file descriptor: the first gets file descriptor <tt>0</tt>, the second gets
  1015. <tt>1</tt>, and so forth.
  1016. A <i>fd-spec</i> is either a port that reads from or writes to
  1017. a file descriptor,
  1018. or <tt>#f</tt>, with <tt>#f</tt> indicating that the corresponding file
  1019. descriptor is not used.
  1020. Any open ports not listed are marked `close-on-exec'.
  1021. The same port may be moved to multiple new file descriptors.</p>
  1022. <p>
  1023. For example,
  1024. </p>
  1025. <pre class=verbatim>(remap-file-descriptors (current-output-port)
  1026. #f
  1027. (current-input-port))
  1028. </pre><p>
  1029. moves the current output port to file descriptor <tt>0</tt> and the
  1030. current input port to file descriptor <tt>2</tt>.</p>
  1031. <p>
  1032. </p>
  1033. <ul>
  1034. <li><p><tt>(dup<i> fd-port</i>)&nbsp;-&gt;&nbsp;<i>fd-port</i></tt><a name="node_idx_942"></a>
  1035. </p>
  1036. <li><p><tt>(dup-switching-mode<i> fd-port</i>)&nbsp;-&gt;&nbsp;<i>fd-port</i></tt><a name="node_idx_944"></a>
  1037. </p>
  1038. <li><p><tt>(dup2<i> fd-port file-descriptor</i>)&nbsp;-&gt;&nbsp;<i>fd-port</i></tt><a name="node_idx_946"></a>
  1039. </p>
  1040. </ul><p>
  1041. These change <i>fd-port</i>'s file descriptor and return a new port
  1042. that uses <i>ports</i>'s old file descriptor.
  1043. <tt>Dup</tt> uses the lowest unused file descriptor and <tt>dup2</tt> uses the
  1044. one provided.
  1045. <tt>Dup-switching-mode</tt> is the same as <tt>dup</tt> except that the returned
  1046. port is an input port if the argument was an output port and vice
  1047. versa.
  1048. If any existing port uses the file descriptor passed to <tt>dup2</tt>, that
  1049. port is closed.</p>
  1050. <p>
  1051. </p>
  1052. <ul>
  1053. <li><p><tt>(close-all-but<i> port <tt>...</tt></i>)</tt><a name="node_idx_948"></a>
  1054. </p>
  1055. </ul><p>
  1056. <tt>Close-all-but</tt> closes all file descriptors whose associated ports
  1057. are not passed to it as arguments.</p>
  1058. <p>
  1059. </p>
  1060. <p>
  1061. </p>
  1062. <p>
  1063. </p>
  1064. <p>
  1065. </p>
  1066. <ul>
  1067. <li><p><tt>(close-on-exec?<i> port</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_950"></a>
  1068. </p>
  1069. <li><p><tt>(set-close-on-exec?!<i> port boolean</i>)</tt><a name="node_idx_952"></a>
  1070. </p>
  1071. </ul><p>
  1072. <tt>Close-on-exec?</tt> returns true if <tt>port</tt> will be closed
  1073. when a new program is exec'ed.
  1074. <tt>Set-close-on-exec?!</tt> sets <tt>port</tt>'s close-on-exec flag.</p>
  1075. <p>
  1076. </p>
  1077. <p>
  1078. </p>
  1079. <ul>
  1080. <li><p><tt>(i/o-flags<i> port</i>)&nbsp;-&gt;&nbsp;<i>file-options</i></tt><a name="node_idx_954"></a>
  1081. </p>
  1082. <li><p><tt>(set-i/o-flags!<i> port file-options</i>)</tt><a name="node_idx_956"></a>
  1083. </p>
  1084. </ul><p>
  1085. These two procedures read and write various options for <tt>port</tt>.
  1086. The options that can be read are <tt>append</tt>, <tt>nonblocking</tt>,
  1087. <tt>read-only</tt>, <tt>write-only</tt>, and <tt>read/write</tt>.
  1088. Only the <tt>append</tt> and <tt>nonblocking</tt> can be written.</p>
  1089. <p>
  1090. </p>
  1091. <p>
  1092. </p>
  1093. <p>
  1094. </p>
  1095. <ul>
  1096. <li><p><tt>(port-is-a-terminal?<i> port</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_958"></a>
  1097. </p>
  1098. <li><p><tt>(port-terminal-name<i> port</i>)&nbsp;-&gt;&nbsp;<i>string</i></tt><a name="node_idx_960"></a>
  1099. </p>
  1100. </ul><p>
  1101. <tt>Port-is-a-terminal?</tt> returns true if <i>port</i> has an underlying
  1102. file descriptor that is associated with a terminal.
  1103. For such ports <tt>port-terminal-name</tt> returns the name of the
  1104. terminal, for all others it returns <tt>#f</tt>.</p>
  1105. <p>
  1106. </p>
  1107. <p>
  1108. </p>
  1109. <a name="node_sec_9.9"></a>
  1110. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_9.9">9.9&nbsp;&nbsp;Regular expressions</a></h2>
  1111. <p></p>
  1112. <p>
  1113. The procedures in this section provide access to POSIX regular expression
  1114. matching.
  1115. The regular expression syntax and semantics are far too complex to
  1116. be described here.
  1117. Due to limitations in the underlying facility, only Latin-1 strings
  1118. are guaranteed to work here -- on some platforms, only ASCII may
  1119. function correctly.
  1120. Moreover, because the C interface uses zero bytes for marking the ends of strings,
  1121. patterns and strings that contain zero bytes will not work
  1122. correctly. </p>
  1123. <p>
  1124. These procedures are in structures <tt>posix-regexps</tt> and <tt>posix</tt>.</p>
  1125. <p>
  1126. An abstract data type for creating POSIX regular expressions is
  1127. described in section&nbsp;<a href="manual-Z-H-7.html#node_sec_5.20">5.20</a>.</p>
  1128. <p>
  1129. </p>
  1130. <ul>
  1131. <li><p><tt>(make-regexp<i> string . regexp-options</i>)&nbsp;-&gt;&nbsp;<i>regexp</i></tt><a name="node_idx_962"></a>
  1132. </p>
  1133. <li><p><tt>(regexp-option <i>option-name</i>)&nbsp;-&gt;&nbsp;<i>regexp-option</i></tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(syntax)
  1134. </p>
  1135. </ul><p>
  1136. <tt>Make-regexp</tt> makes a new regular expression, using <i>string</i>
  1137. as the pattern.
  1138. The possible option names are:</p>
  1139. <p>
  1140. </p>
  1141. <div align=center><table><tr><td>
  1142. <table border=0><tr><td valign=top ><tt>extended</tt> </td><td valign=top >use the extended patterns </td></tr>
  1143. <tr><td valign=top ><tt>ignore-case</tt> </td><td valign=top >ignore case when matching </td></tr>
  1144. <tr><td valign=top ><tt>submatches</tt> </td><td valign=top >report submatches </td></tr>
  1145. <tr><td valign=top ><tt>newline</tt> </td><td valign=top >treat newlines specially
  1146. </td></tr></table>
  1147. </td></tr></table></div>
  1148. <p>
  1149. The regular expression is not compiled until it matched against a string,
  1150. so any errors in the pattern string will not be reported until that
  1151. point.</p>
  1152. <p>
  1153. </p>
  1154. <ul>
  1155. <li><p><tt>(regexp?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_964"></a>
  1156. </p>
  1157. </ul><p>
  1158. This is a predicate for regular expressions.</p>
  1159. <p>
  1160. </p>
  1161. <ul>
  1162. <li><p><tt>(regexp-match<i> regexp string start submatches? starts-line? ends-line?</i>)</tt><a name="node_idx_966"></a>
  1163. <br>
  1164. <tt> -&gt;&nbsp;<i>boolean or list of matches</i></tt>
  1165. </p>
  1166. <li><p><tt>(match?<i> x</i>)&nbsp;-&gt;&nbsp;<i>boolean</i></tt><a name="node_idx_968"></a>
  1167. </p>
  1168. <li><p><tt>(match-start<i> match</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_970"></a>
  1169. </p>
  1170. <li><p><tt>(match-end<i> match</i>)&nbsp;-&gt;&nbsp;<i>integer</i></tt><a name="node_idx_972"></a>
  1171. </p>
  1172. </ul><p>
  1173. <tt>Regexp-match</tt> matches the regular expression against the characters
  1174. in <i>string</i>, starting at position <i>start</i>.
  1175. If the string does not match the regular expression, <tt>regexp-match</tt>
  1176. returns <tt>#f</tt>.
  1177. If the string does match, then a list of match records is returned
  1178. if <i>submatches?</i> is true, or <tt>#t</tt> is returned if it is not.
  1179. Each match record contains the index of the character at the beginning
  1180. of the match and one more than the index of the character at the end.
  1181. The first match record gives the location of the substring that matched
  1182. <i>regexp</i>.
  1183. If the pattern in <i>regexp</i> contained submatches, then the results
  1184. of these are returned in order, with a match records reporting submatches
  1185. that succeeded and <tt>#f</tt> in place of those that did not.</p>
  1186. <p>
  1187. <i>Starts-line?</i> should be true if <i>string</i> starts at the beginning
  1188. of a line and <i>ends-line?</i> should be true if it ends one.</p>
  1189. <p>
  1190. </p>
  1191. <a name="node_sec_9.10"></a>
  1192. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_9.10">9.10&nbsp;&nbsp;C to Scheme correspondence</a></h2>
  1193. <p></p>
  1194. <p>
  1195. The following table lists the Scheme procedures that correspond to
  1196. particular C procedures.
  1197. Not all of the Scheme procedures listed are part of the POSIX interface.</p>
  1198. <p>
  1199. </p>
  1200. <table border=0><tr><td valign=top >C procedure </td><td valign=top >Scheme procedure(s) </td></tr>
  1201. <tr><td valign=top >C procedure </td><td valign=top >Scheme procedure(s) </td></tr>
  1202. <tr><td valign=top ><tt>access</tt></td><td valign=top ><tt>accessible?</tt></td></tr>
  1203. <tr><td valign=top ><tt>chdir</tt></td><td valign=top ><tt>set-working-directory!</tt></td></tr>
  1204. <tr><td valign=top ><tt>close</tt></td><td valign=top ><tt>close-input-port, close-output-port,</tt></td></tr>
  1205. <tr><td valign=top ></td><td valign=top ><tt> close-channel, close-socket</tt></td></tr>
  1206. <tr><td valign=top ><tt>closedir</tt></td><td valign=top ><tt>close-directory-stream</tt></td></tr>
  1207. <tr><td valign=top ><tt>creat</tt></td><td valign=top ><tt>open-file</tt></td></tr>
  1208. <tr><td valign=top ><tt>ctime</tt></td><td valign=top ><tt>time-&gt;string</tt></td></tr>
  1209. <tr><td valign=top ><tt>dup</tt></td><td valign=top ><tt>dup, dup-switching-mode</tt></td></tr>
  1210. <tr><td valign=top ><tt>dup2</tt></td><td valign=top ><tt>dup2</tt></td></tr>
  1211. <tr><td valign=top ><tt>exec[l|v][e|p|epsilon]</tt>
  1212. </td><td valign=top ><tt>exec, exec-with-environment,</tt> </td></tr>
  1213. <tr><td valign=top ></td><td valign=top ><tt> exec-file, exec-file-with-environment,</tt> </td></tr>
  1214. <tr><td valign=top ></td><td valign=top ><tt> exec-with-alias</tt></td></tr>
  1215. <tr><td valign=top ><tt>_exit</tt></td><td valign=top ><tt>exit</tt></td></tr>
  1216. <tr><td valign=top ><tt>fcntl</tt></td><td valign=top ><tt>io-flags, set-io-flags!,</tt></td></tr>
  1217. <tr><td valign=top ></td><td valign=top ><tt> close-on-exec, set-close-on-exec!</tt></td></tr>
  1218. <tr><td valign=top ><tt>fork</tt></td><td valign=top ><tt>fork, fork-and-forget</tt></td></tr>
  1219. <tr><td valign=top ><tt>fstat</tt></td><td valign=top ><tt>get-port-info</tt></td></tr>
  1220. <tr><td valign=top ><tt>getcwd</tt></td><td valign=top ><tt>working-directory</tt></td></tr>
  1221. <tr><td valign=top ><tt>getegid</tt></td><td valign=top ><tt>get-effective-group-id</tt></td></tr>
  1222. <tr><td valign=top ><tt>getenv</tt></td><td valign=top ><tt>lookup-environment-variable,</tt> </td></tr>
  1223. <tr><td valign=top ></td><td valign=top ><tt> environment-alist</tt></td></tr>
  1224. <tr><td valign=top ><tt>geteuid</tt></td><td valign=top ><tt>get-effective-user-id</tt></td></tr>
  1225. <tr><td valign=top ><tt>getgid</tt></td><td valign=top ><tt>get-group-id</tt></td></tr>
  1226. <tr><td valign=top ><tt>getgroups</tt></td><td valign=top ><tt>get-groups</tt></td></tr>
  1227. <tr><td valign=top ><tt>getlogin</tt></td><td valign=top ><tt>get-login-name</tt></td></tr>
  1228. <tr><td valign=top ><tt>getpid</tt></td><td valign=top ><tt>get-process-id</tt></td></tr>
  1229. <tr><td valign=top ><tt>getppid</tt></td><td valign=top ><tt>get-parent-process-id</tt></td></tr>
  1230. <tr><td valign=top ><tt>getuid</tt></td><td valign=top ><tt>get-user-id</tt></td></tr>
  1231. <tr><td valign=top ><tt>isatty</tt></td><td valign=top ><tt>port-is-a-terminal?</tt></td></tr>
  1232. <tr><td valign=top ><tt>link</tt></td><td valign=top ><tt>link</tt></td></tr>
  1233. <tr><td valign=top ><tt>lstat</tt></td><td valign=top ><tt>get-file/link-info</tt></td></tr>
  1234. <tr><td valign=top ><tt>mkdir</tt></td><td valign=top ><tt>make-directory</tt></td></tr>
  1235. <tr><td valign=top ><tt>mkfifo</tt></td><td valign=top ><tt>make-fifo</tt></td></tr>
  1236. <tr><td valign=top ><tt>open</tt></td><td valign=top ><tt>open-file</tt></td></tr>
  1237. <tr><td valign=top ><tt>opendir</tt></td><td valign=top ><tt>open-directory-stream</tt></td></tr>
  1238. <tr><td valign=top ><tt>pipe</tt></td><td valign=top ><tt>open-pipe</tt></td></tr>
  1239. <tr><td valign=top ><tt>read</tt></td><td valign=top ><tt>read-char, read-block</tt></td></tr>
  1240. <tr><td valign=top ><tt>readdir</tt></td><td valign=top ><tt>read-directory-stream</tt></td></tr>
  1241. <tr><td valign=top ><tt>rename</tt></td><td valign=top ><tt>rename</tt></td></tr>
  1242. <tr><td valign=top ><tt>rmdir</tt></td><td valign=top ><tt>remove-directory</tt></td></tr>
  1243. <tr><td valign=top ><tt>setgid</tt></td><td valign=top ><tt>set-group-id!</tt></td></tr>
  1244. <tr><td valign=top ><tt>setuid</tt></td><td valign=top ><tt>set-user-id!</tt></td></tr>
  1245. <tr><td valign=top ><tt>stat</tt></td><td valign=top ><tt>get-file-info</tt></td></tr>
  1246. <tr><td valign=top ><tt>time</tt></td><td valign=top ><tt>current-time</tt></td></tr>
  1247. <tr><td valign=top ><tt>ttyname</tt></td><td valign=top ><tt>port-terminal-name</tt></td></tr>
  1248. <tr><td valign=top ><tt>umask</tt></td><td valign=top ><tt>set-file-creation-mask!</tt></td></tr>
  1249. <tr><td valign=top ><tt>uname</tt></td><td valign=top ><tt>os-name, os-node-name,</tt> </td></tr>
  1250. <tr><td valign=top ></td><td valign=top ><tt> os-release-name, os-version-name,</tt> </td></tr>
  1251. <tr><td valign=top ></td><td valign=top ><tt> machine-name</tt></td></tr>
  1252. <tr><td valign=top ><tt>unlink</tt></td><td valign=top ><tt>unlink</tt></td></tr>
  1253. <tr><td valign=top ><tt>waitpid</tt></td><td valign=top ><tt>wait-for-child-process</tt></td></tr>
  1254. <tr><td valign=top ><tt>write</tt></td><td valign=top ><tt>write-char, write-block</tt></td></tr>
  1255. <tr><td valign=top ></td></tr></table><p>
  1256. </p>
  1257. <div align=right class=navigation><i>[Go to <span><a href="manual.html">first</a>, <a href="manual-Z-H-10.html">previous</a></span><span>, <a href="manual-Z-H-12.html">next</a></span> page<span>; &nbsp;&nbsp;</span><span><a href="manual-Z-H-2.html#node_toc_start">contents</a></span><span><span>; &nbsp;&nbsp;</span><a href="manual-Z-H-13.html#node_index_start">index</a></span>]</i></div>
  1258. <p></p>
  1259. </div>
  1260. </body>
  1261. </html>