/usr/share/doc/scheme48/html/manual-Z-H-10.html is in scheme48-doc 1.9-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 | <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
Generated from manual.tex by tex2page, v 20100828
(running on MzScheme 4.2.4, :unix),
(c) Dorai Sitaram,
http://evalwhen.com/tex2page/index.html
-->
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>
The Incomplete Scheme 48 Reference Manual for release 1.9
</title>
<link rel="stylesheet" type="text/css" href="manual-Z-S.css" title=default>
<meta name=robots content="index,follow">
</head>
<body>
<div id=slidecontent>
<div align=right class=navigation>[Go to <span><a href="manual.html">first</a>, <a href="manual-Z-H-9.html">previous</a></span><span>, <a href="manual-Z-H-11.html">next</a></span> page<span>; </span><span><a href="manual-Z-H-1.html#node_toc_start">contents</a></span><span><span>; </span><a href="manual-Z-H-11.html#node_index_start">index</a></span>]</div>
<p></p>
<a name="node_chap_9"></a>
<h1 class=chapter>
<div class=chapterheading><a href="manual-Z-H-1.html#node_toc_node_chap_9">Chapter 9</a></div><br>
<a href="manual-Z-H-1.html#node_toc_node_chap_9">Access to POSIX</a></h1>
<p>This chapter describes Scheme 48's interface to the POSIX C calls
[<a href="manual-Z-H-11.html#node_bib_1">1</a>].
Scheme versions of most of the functions in POSIX are provided.
Both the interface and implementation are new and are likely to
change in future releases.
Section <a href="#node_sec_9.12">9.12</a> lists which Scheme functions
call which C functions.</p>
<p>
Scheme 48's POSIX interface will likely change significantly in the
future.
The implementation is new and may have significant bugs.</p>
<p>
The POSIX bindings are available in several structures:</p>
<p>
</p>
<div align=center><table><tr><td>
<table border=0><tr><td valign=top ><tt>posix-processes</tt> </td><td valign=top >fork, exec, and friends </td></tr>
<tr><td valign=top ><tt>posix-process-data</tt> </td><td valign=top >information about processes </td></tr>
<tr><td valign=top ><tt>posix-files</tt> </td><td valign=top >files and directories </td></tr>
<tr><td valign=top ><tt>posix-i/o</tt> </td><td valign=top >operations on ports </td></tr>
<tr><td valign=top ><tt>posix-time</tt> </td><td valign=top >time functions </td></tr>
<tr><td valign=top ><tt>posix-users</tt> </td><td valign=top >users and groups </td></tr>
<tr><td valign=top ><tt>posix-regexps</tt> </td><td valign=top >regular expression matching </td></tr>
<tr><td valign=top ><tt>posix-syslog</tt> </td><td valign=top >POSIX logging facility </td></tr>
<tr><td valign=top ><tt>posix-errnos</tt> </td><td valign=top >POSIX error codes</td></tr>
<tr><td valign=top ><tt>posix</tt> </td><td valign=top >all of the above
</td></tr></table>
</td></tr></table></div>
<p>
Scheme 48's POSIX interface differs from
Scsh's [<a href="manual-Z-H-11.html#node_bib_11">11</a>, <a href="manual-Z-H-11.html#node_bib_12">12</a>] in several ways.
The interface here lacks Scsh's high-level constructs and utilities,
such as the process notation, <tt>awk</tt> procedure, and parsing
utilities.
Scheme 48 uses distinct types for some values that Scsh leaves
as symbols or unboxed integers; these include file types, file modes,
and user and group ids.
Many of the names and other interface details are different, as well.</p>
<p>
</p>
<a name="node_sec_9.1"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.1">9.1 Process primitives</a></h2>
<p>The procedures described in this section control the creation of processes
and the execution of programs.
They are in the structures <tt>posix-process</tt> and <tt>posix</tt>.</p>
<p>
</p>
<a name="node_sec_9.1.1"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.1.1">9.1.1 Process creation and termination</a></h3>
<p></p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(fork<i></i>) –> <i>process-id or <tt>#f</tt></i></tt><a name="node_idx_798"></a></p>
<li><p></p>
<p class=noindent><tt>(fork-and-forget<i> thunk</i>)</tt><a name="node_idx_800"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Fork</tt> creates a new child process and returns the child's process-id in
the parent and <tt>#f</tt> in the child.
<tt>Fork-and-forget</tt> calls <i>thunk</i> in a new process; no process-id
is returned.
<tt>Fork-and-forget</tt> uses an intermediate process to avoid creating
a zombie process.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(process-id?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_802"></a></p>
<li><p></p>
<p class=noindent><tt>(process-id=?<i> process-id0 process-id1</i>) –> <i>boolean</i></tt><a name="node_idx_804"></a></p>
<li><p></p>
<p class=noindent><tt>(process-id->integer<i> process-id</i>) –> <i>integer</i></tt><a name="node_idx_806"></a></p>
<li><p></p>
<p class=noindent><tt>(integer->process-id<i> integer</i>) –> <i>process-id</i></tt><a name="node_idx_808"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Process-id?</tt> is a predicate for process-ids,
<tt>process-id=?</tt> compares two to see if they are the same,
and <tt>process-id-uid</tt> returns the actual Unix id.
<tt>Process-id->integer</tt> and <tt>integer->process-id</tt>
convert process ids to and from integers.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(process-id-exit-status<i> process-id</i>) –> <i>integer or <tt>#f</tt></i></tt><a name="node_idx_810"></a></p>
<li><p></p>
<p class=noindent><tt>(process-id-terminating-signal<i> process-id</i>) –> <i>signal or <tt>#f</tt></i></tt><a name="node_idx_812"></a></p>
<li><p></p>
<p class=noindent><tt>(wait-for-child-process<i> process-id</i>)</tt><a name="node_idx_814"></a></p>
</ul><p>
</p>
<p class=noindent>If a process terminates normally
<tt>process-id-exit-status</tt> will return its exit status.
If the process is still running or was terminated by a signal then
<tt>process-id-exit-status</tt> will return <tt>#f</tt>.
Similarly, if a child process was terminated by a signal
<tt>process-id-terminating-signal</tt> will return that signal and
will return <tt>#f</tt> if the process is still running or terminated
normally.
<tt>Wait-for-child-process</tt> blocks until the child process terminates.
Scheme 48 may reap child processes before the user requests their
exit status, but it does not always do so.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(exit<i> status</i>)</tt><a name="node_idx_816"></a></p>
</ul><p>
</p>
<p class=noindent>Terminates the current process with the integer <i>status</i>
as its exit status.</p>
<p>
</p>
<a name="node_sec_9.1.2"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.1.2">9.1.2 <tt>Exec</tt></a></h3>
<p></p>
<ul>
<li><p></p>
<p class=noindent><tt>(exec<i> program-name arg0 <tt>...</tt></i>)</tt><a name="node_idx_818"></a></p>
<li><p></p>
<p class=noindent><tt>(exec-with-environment<i> program-name env arg0 <tt>...</tt></i>)</tt><a name="node_idx_820"></a></p>
<li><p></p>
<p class=noindent><tt>(exec-file<i> filename arg0 <tt>...</tt></i>)</tt><a name="node_idx_822"></a></p>
<li><p></p>
<p class=noindent><tt>(exec-file-with-environment<i> filename env arg0 <tt>...</tt></i>)</tt><a name="node_idx_824"></a></p>
<li><p></p>
<p class=noindent><tt>(exec-with-alias<i> name lookup? maybe-env arguments</i>)</tt><a name="node_idx_826"></a></p>
</ul><p>
</p>
<p class=noindent>All of these replace the current program with a new one.
They differ in how the new program is found, what its environment is,
and what arguments it is passed.
<tt>Exec</tt> and <tt>exec-with-environment</tt>
look up the new program in the search path,
while <tt>exec-file</tt> and <tt>exec-file-with-environment</tt>
execute a particular file.
The environment is either inherited from the current process
(<tt>exec</tt> and <tt>exec-file</tt>) or given as an argument
(<tt><tt>...</tt>-with-environment</tt>).
<i>Program-name</i> and <i>filename</i> and any <i>arg<sub><em>i</em></sub></i> should
be <i>os-string-thing</i> arguments (see section <a href="manual-Z-H-6.html#node_sec_5.15">5.15</a>.
<i>Env</i> should be a list of <i>os-string-thing</i> arguments of the form
<tt>"<i>name</i>=<i>value</i>"</tt>.
The first four procedures add their first argument, <i>program-name</i> or
<i>filename</i>, before the <i>arg0 <tt>...</tt></i> arguments.</p>
<p>
<tt>Exec-with-alias</tt> is an omnibus procedure that subsumes the other
four.
<i>Name</i> is looked up in the search path if <i>lookup?</i> is true
and is used as a filename otherwise.
<i>Maybe-env</i> is either a list of <i>os-string-thing</i>s for the environment of the
new program or <tt>#f</tt> in which case the new program inherits its
environment from the current one.
<i>Arguments</i> should be a list of <i>os-string-thing</i>s; unlike with the other four
procedures, <i>name</i> is not added to this list (hence <tt>-with-alias</tt>).</p>
<p>
</p>
<a name="node_sec_9.2"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.2">9.2 Signals</a></h2>
<p>There are two varieties of signals available, <em>named</em> and <em>anonymous</em>.
A named signal is one for which we have a symbolic name, such as <tt>kill</tt>
or <tt>pipe</tt>.
Anonymous signals, for which we only have the current operating system's
signal number, have no meaning in other operating systems.
Named signals preserve their meaning in image files.
Not all named signals are available from all OS's and
there may be multiple names for a single OS signal number.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(signal <i>signal-name</i>) –> <i>signal</i></tt> (syntax)
</p>
<li><p></p>
<p class=noindent><tt>(name->signal<i> symbol</i>) –> <i>signal or <tt>#f</tt></i></tt><a name="node_idx_828"></a></p>
<li><p></p>
<p class=noindent><tt>(integer->signal<i> integer</i>) –> <i>signal</i></tt><a name="node_idx_830"></a></p>
<li><p></p>
<p class=noindent><tt>(signal?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_832"></a></p>
<li><p></p>
<p class=noindent><tt>(signal-name<i> signal</i>) –> <i>symbol or <tt>#f</tt></i></tt><a name="node_idx_834"></a></p>
<li><p></p>
<p class=noindent><tt>(signal-os-number<i> signal</i>) –> <i>integer</i></tt><a name="node_idx_836"></a></p>
<li><p></p>
<p class=noindent><tt>(signal=?<i> signal0 signal1</i>) –> <i>boolean</i></tt><a name="node_idx_838"></a></p>
</ul><p>
</p>
<p class=noindent>The syntax <tt>signal</tt> returns a (named) signal associated with
<i>signal-name</i>.
<tt>Name->signal</tt> returns a (named) signal or <tt>#f</tt> if the
the signal <i>name</i> is not supported by the operating system.
The signal returned by <tt>integer->signal</tt> is a named signal if
<i>integer</i> corresponds to a named signal in the current operating
system; otherwise it returns an anonymous signal.
<tt>Signal-name</tt> returns a symbol if <i>signal</i> is named and
<tt>#f</tt> if it is anonymous.
<tt>Signal=?</tt> returns <tt>#t</tt> if <i>signal0</i> and <i>signal1</i>
have the same operating system number and <tt>#f</tt> if they do not.</p>
<p>
</p>
<a name="node_sec_9.2.1"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.2.1">9.2.1 POSIX signals</a></h3>
<p>The following lists the names of the POSIX signals.
</p>
<div align=center><table><tr><td>
<table border=0><tr><td valign=top ><tt>abrt</tt> </td><td valign=top >abort - abnormal termination (as by abort()) </td></tr>
<tr><td valign=top ><tt>alrm</tt> </td><td valign=top >alarm - timeout signal (as by alarm()) </td></tr>
<tr><td valign=top ><tt>fpe </tt> </td><td valign=top >floating point exception </td></tr>
<tr><td valign=top ><tt>hup </tt> </td><td valign=top >hangup - hangup on controlling terminal or death of
controlling process </td></tr>
<tr><td valign=top ><tt>ill </tt> </td><td valign=top >illegal instruction </td></tr>
<tr><td valign=top ><tt>int </tt> </td><td valign=top >interrupt - interaction attention </td></tr>
<tr><td valign=top ><tt>kill</tt> </td><td valign=top >kill - termination signal, cannot be caught or ignored </td></tr>
<tr><td valign=top ><tt>pipe</tt> </td><td valign=top >pipe - write on a pipe with no readers </td></tr>
<tr><td valign=top ><tt>quit</tt> </td><td valign=top >quit - interaction termination </td></tr>
<tr><td valign=top ><tt>segv</tt> </td><td valign=top >segmentation violation - invalid memory reference </td></tr>
<tr><td valign=top ><tt>term</tt> </td><td valign=top >termination - termination signal </td></tr>
<tr><td valign=top ><tt>usr1</tt> </td><td valign=top >user1 - for use by applications </td></tr>
<tr><td valign=top ><tt>usr2</tt> </td><td valign=top >user2 - for use by applications </td></tr>
<tr><td valign=top ><tt>chld</tt> </td><td valign=top >child - child process stopped or terminated </td></tr>
<tr><td valign=top ><tt>cont</tt> </td><td valign=top >continue - continue if stopped </td></tr>
<tr><td valign=top ><tt>stop</tt> </td><td valign=top >stop - cannot be caught or ignored </td></tr>
<tr><td valign=top ><tt>tstp</tt> </td><td valign=top >interactive stop </td></tr>
<tr><td valign=top ><tt>ttin</tt> </td><td valign=top >read from control terminal attempted by background process </td></tr>
<tr><td valign=top ><tt>ttou</tt> </td><td valign=top >write to control terminal attempted by background process </td></tr>
<tr><td valign=top ><tt>bus </tt> </td><td valign=top >bus error - access to undefined portion of memory </td></tr>
<tr><td valign=top ></td></tr></table>
</td></tr></table></div>
<p>
</p>
<a name="node_sec_9.2.2"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.2.2">9.2.2 Other signals</a></h3>
<p>The following lists the names of the non-POSIX signals that the system is
currently aware of.
</p>
<div align=center><table><tr><td>
<table border=0><tr><td valign=top ><tt>trap </tt> </td><td valign=top >trace or breakpoint trap </td></tr>
<tr><td valign=top ><tt>iot </tt> </td><td valign=top >IOT trap - a synonym for ABRT </td></tr>
<tr><td valign=top ><tt>emt </tt> </td><td valign=top ></td></tr>
<tr><td valign=top ><tt>sys </tt> </td><td valign=top >bad argument to routine (SVID) </td></tr>
<tr><td valign=top ><tt>stkflt</tt> </td><td valign=top >stack fault on coprocessor </td></tr>
<tr><td valign=top ><tt>urg </tt> </td><td valign=top >urgent condition on socket (4.2 BSD) </td></tr>
<tr><td valign=top ><tt>io </tt> </td><td valign=top >I/O now possible (4.2 BSD) </td></tr>
<tr><td valign=top ><tt>poll </tt> </td><td valign=top >A synonym for SIGIO (System V) </td></tr>
<tr><td valign=top ><tt>cld </tt> </td><td valign=top >A synonym for SIGCHLD </td></tr>
<tr><td valign=top ><tt>xcpu </tt> </td><td valign=top >CPU time limit exceeded (4.2 BSD) </td></tr>
<tr><td valign=top ><tt>xfsz </tt> </td><td valign=top >File size limit exceeded (4.2 BSD) </td></tr>
<tr><td valign=top ><tt>vtalrm</tt> </td><td valign=top >Virtual alarm clock (4.2 BSD) </td></tr>
<tr><td valign=top ><tt>prof </tt> </td><td valign=top >Profile alarm clock </td></tr>
<tr><td valign=top ><tt>pwr </tt> </td><td valign=top >Power failure (System V) </td></tr>
<tr><td valign=top ><tt>info </tt> </td><td valign=top >A synonym for SIGPWR </td></tr>
<tr><td valign=top ><tt>lost </tt> </td><td valign=top >File lock lost </td></tr>
<tr><td valign=top ><tt>winch </tt> </td><td valign=top >Window resize signal (4.3 BSD, Sun) </td></tr>
<tr><td valign=top ><tt>unused</tt> </td><td valign=top >Unused signal </td></tr>
<tr><td valign=top ></td></tr></table></td></tr></table></div>
<p>
</p>
<a name="node_sec_9.2.3"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.2.3">9.2.3 Sending signals</a></h3>
<p></p>
<ul>
<li><p></p>
<p class=noindent><tt>(signal-process<i> process-id signal</i>)</tt><a name="node_idx_840"></a></p>
</ul><p>
</p>
<p class=noindent>Send <i>signal</i> to the process corresponding to <i>process-id</i>.</p>
<p>
</p>
<a name="node_sec_9.2.4"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.2.4">9.2.4 Receiving signals</a></h3>
<p>Signals received by the Scheme process can be obtained via one or more
signal-queues.
Each signal queue has a list of monitored signals and a queue of
received signals that have yet to be read from the signal-queue.
When the Scheme process receives a signal that signal is added to the
received-signal queues of all signal-queues which are currently monitoring
that particular signal.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(make-signal-queue<i> signals</i>) –> <i>signal-queue</i></tt><a name="node_idx_842"></a></p>
<li><p></p>
<p class=noindent><tt>(signal-queue?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_844"></a></p>
<li><p></p>
<p class=noindent><tt>(signal-queue-monitored-signals<i> signal-queue</i>) –> <i>list of signals</i></tt><a name="node_idx_846"></a></p>
<li><p></p>
<p class=noindent><tt>(dequeue-signal!<i> signal-queue</i>) –> <i>signal</i></tt><a name="node_idx_848"></a></p>
<li><p></p>
<p class=noindent><tt>(maybe-dequeue-signal!<i> signal-queue</i>) –> <i>signal or <tt>#f</tt></i></tt><a name="node_idx_850"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Make-signal-queue</tt> returns a new signal-queue that will monitor
the signals in the list <i>signals</i>.
<tt>Signal-queue?</tt> is a predicate for signal queues.
<tt>Signal-queue-monitored-signals</tt> returns a list of the signals
currently monitored by <i>signal-queue</i>.
<tt>Dequeue-signal!</tt> and <tt>maybe-dequeue-signal</tt> both return
the next received-but-unread signal from <i>signal-queue</i>.
If <i>signal-queue</i>'s queue of signals is empty <tt>dequeue-signal!</tt>
blocks until an appropriate signal is received.
<tt>Maybe-dequeue-signal!</tt> does not block; it returns <tt>#f</tt> instead.</p>
<p>
There is a bug in the current system that causes an erroneous deadlock
error if threads are blocked waiting for signals and no other threads
are available to run.
A work around is to create a thread that sleeps for a long time, which
prevents any deadlock errors (including real ones):
</p>
<pre class=verbatim>> ,open threads
> (spawn (lambda ()
; Sleep for a year
(sleep (* 1000 60 60 24 365))))
</pre><p></p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(add-signal-queue-signal!<i> signal-queue signal</i>)</tt><a name="node_idx_852"></a></p>
<li><p></p>
<p class=noindent><tt>(remove-signal-queue-signal!<i> signal-queue signal</i>)</tt><a name="node_idx_854"></a></p>
</ul><p>
</p>
<p class=noindent>These two procedures can be used to add or remove signals from a
signal-queue's list of monitored signals.
When a signal is removed from a signal-queue's list of monitored signals
any occurances of the signal are removed from that signal-queue's pending
signals.
In other words, <tt>dequeue-signal!</tt> and <tt>maybe-dequeue-signal!</tt>
will only return signals that are currently on the signal-queue's list
of signals.</p>
<p>
</p>
<a name="node_sec_9.3"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.3">9.3 Process environment</a></h2>
<p>These are in structures <tt>posix-process-data</tt> and <tt>posix</tt>.</p>
<p>
</p>
<a name="node_sec_9.3.1"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.3.1">9.3.1 Process identification</a></h3>
<p></p>
<ul>
<li><p></p>
<p class=noindent><tt>(get-process-id<i></i>) –> <i> process-id</i></tt><a name="node_idx_856"></a></p>
<li><p></p>
<p class=noindent><tt>(get-parent-process-id<i></i>) –> <i> process-id</i></tt><a name="node_idx_858"></a></p>
</ul><p>
</p>
<p class=noindent>These return the process ids of the current process and its parent.
See section <a href="#node_sec_9.1.1">9.1.1</a> for operations on process ids.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(get-user-id<i></i>) –> <i> user-id</i></tt><a name="node_idx_860"></a></p>
<li><p></p>
<p class=noindent><tt>(get-effective-user-id<i></i>) –> <i> user-id</i></tt><a name="node_idx_862"></a></p>
<li><p></p>
<p class=noindent><tt>(set-user-id!<i> user-id</i>)</tt><a name="node_idx_864"></a></p>
<li><p></p>
<p class=noindent><tt>(set-effective-user-id!<i> user-id</i>)</tt><a name="node_idx_866"></a></p>
</ul><p></p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(get-group-id<i></i>) –> <i> group-id</i></tt><a name="node_idx_868"></a></p>
<li><p></p>
<p class=noindent><tt>(get-effective-group-id<i></i>) –> <i> group-id</i></tt><a name="node_idx_870"></a></p>
<li><p></p>
<p class=noindent><tt>(set-group-id!<i> group-id</i>)</tt><a name="node_idx_872"></a></p>
<li><p></p>
<p class=noindent><tt>(set-effective-group-id!<i> group-id</i>)</tt><a name="node_idx_874"></a></p>
</ul><p>
</p>
<p class=noindent>Every process has both the original and effective user id and group id.
The effective values may be set, but the original ones can only be set
if the process has appropriate privelages.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(get-groups<i></i>) –> <i> group-ids</i></tt><a name="node_idx_876"></a></p>
<li><p></p>
<p class=noindent><tt>(get-login-name<i></i>) –> <i> os-string</i></tt><a name="node_idx_878"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Get-groups</tt> returns a list of the supplementary groups of the
current process.
<tt>Get-login-name</tt> returns a user name for the current process.</p>
<p>
</p>
<p>
</p>
<p>
</p>
<a name="node_sec_9.3.2"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.3.2">9.3.2 Environment variables</a></h3>
<p></p>
<ul>
<li><p></p>
<p class=noindent><tt>(lookup-environment-variable<i> os-string-thing</i>) –> <i>os-string or <tt>#f</tt></i></tt><a name="node_idx_880"></a></p>
<li><p></p>
<p class=noindent><tt>(set-environment-variable!<i> name value</i>)</tt>
<a name="node_idx_882"></a></p>
<li><p></p>
<p class=noindent><tt>(environment-alist<i></i>) –> <i>alist</i></tt><a name="node_idx_884"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Lookup-environment-variable</tt> looks up its argument in the
environment list and returns the corresponding value or <tt>#f</tt>
if there is none.
<tt>Set-environment-variable!</tt> sets the value of <tt>name</tt> in the
environment list to <tt>value</tt>. If <tt>name</tt> is not already an environment
variable, it's created. If it already exists, its value is overwritten with
<tt>value</tt>. Both arguments must be os-string-things.
<tt>Environment-alist</tt> returns the entire environment as a list of
<tt>(<i>name-os-string</i> . <i>value-os-string</i>)</tt> pairs.</p>
<p>
</p>
<a name="node_sec_9.4"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.4">9.4 Users and groups</a></h2>
<p><i>User-id</i>s and <i>group-id</i>s are boxed integers representing
Unix users and groups.
The procedures in this section are in structures <tt>posix-users</tt> and
<tt>posix</tt>.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(user-id?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_886"></a></p>
<li><p></p>
<p class=noindent><tt>(user-id=?<i> user-id0 user-id1</i>) –> <i>boolean</i></tt><a name="node_idx_888"></a></p>
<li><p></p>
<p class=noindent><tt>(user-id->integer<i> user-id</i>) –> <i>integer</i></tt><a name="node_idx_890"></a></p>
<li><p></p>
<p class=noindent><tt>(integer->user-id<i> integer</i>) –> <i>user-id</i></tt><a name="node_idx_892"></a></p>
</ul><p></p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(group-id?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_894"></a></p>
<li><p></p>
<p class=noindent><tt>(group-id=?<i> group-id0 group-id1</i>) –> <i>boolean</i></tt><a name="node_idx_896"></a></p>
<li><p></p>
<p class=noindent><tt>(group-id->integer<i> group-id</i>) –> <i>integer</i></tt><a name="node_idx_898"></a></p>
<li><p></p>
<p class=noindent><tt>(integer->group-id<i> integer</i>) –> <i>group-id</i></tt><a name="node_idx_900"></a></p>
</ul><p>
</p>
<p class=noindent>User-ids and group-ids have their own
own predicates and comparison, boxing, and unboxing functions.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(user-id->user-info<i> user-id</i>) –> <i>user-info</i></tt><a name="node_idx_902"></a></p>
<li><p></p>
<p class=noindent><tt>(name->user-info<i> os-string</i>) –> <i>user-info</i></tt><a name="node_idx_904"></a></p>
</ul><p>
</p>
<p class=noindent>These return the user info for a user identified by user-id or name.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(user-info?<i> x</i>) –> <i> boolean</i></tt><a name="node_idx_906"></a></p>
<li><p></p>
<p class=noindent><tt>(user-info-name<i> user-info</i>) –> <i> os-string</i></tt><a name="node_idx_908"></a></p>
<li><p></p>
<p class=noindent><tt>(user-info-id<i> user-info</i>) –> <i> user-id</i></tt><a name="node_idx_910"></a></p>
<li><p></p>
<p class=noindent><tt>(user-info-group<i> user-info</i>) –> <i> group-id</i></tt><a name="node_idx_912"></a></p>
<li><p></p>
<p class=noindent><tt>(user-info-home-directory<i> user-info</i>) –> <i> os-string</i></tt><a name="node_idx_914"></a></p>
<li><p></p>
<p class=noindent><tt>(user-info-shell<i> user-info</i>) –> <i> os-string</i></tt><a name="node_idx_916"></a></p>
</ul><p>
</p>
<p class=noindent>A <tt>user-info</tt> contains information about a user.
Available are the user's name, id, group, home directory, and shell.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(group-id->group-info<i> group-id</i>) –> <i>group-info</i></tt><a name="node_idx_918"></a></p>
<li><p></p>
<p class=noindent><tt>(name->group-info<i> os-string</i>) –> <i>group-info</i></tt><a name="node_idx_920"></a></p>
</ul><p>
</p>
<p class=noindent>These return the group info for a group identified by group-id or name.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(group-info?<i> x</i>) –> <i> boolean</i></tt><a name="node_idx_922"></a></p>
<li><p></p>
<p class=noindent><tt>(group-info-name<i> group-info</i>) –> <i> os-string</i></tt><a name="node_idx_924"></a></p>
<li><p></p>
<p class=noindent><tt>(group-info-id<i> group-info</i>) –> <i> group-id</i></tt><a name="node_idx_926"></a></p>
<li><p></p>
<p class=noindent><tt>(group-info-members<i> group-info</i>) –> <i> user-ids</i></tt><a name="node_idx_928"></a></p>
</ul><p>
</p>
<p class=noindent>A <tt>group-info</tt> contains information about a group.
Available are the group's name, id, and a list of members.</p>
<p>
</p>
<a name="node_sec_9.5"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.5">9.5 OS and machine identification</a></h2>
<p>These procedures return strings that are supposed to identify the current
OS and machine.
The POSIX standard does not indicate the format of the strings.
The procedures are in structures <tt>posix-platform-names</tt> and <tt>posix</tt>.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(os-name<i></i>) –> <i>string</i></tt><a name="node_idx_930"></a></p>
<li><p></p>
<p class=noindent><tt>(os-node-name<i></i>) –> <i>string</i></tt><a name="node_idx_932"></a></p>
<li><p></p>
<p class=noindent><tt>(os-release-name<i></i>) –> <i>string</i></tt><a name="node_idx_934"></a></p>
<li><p></p>
<p class=noindent><tt>(os-version-name<i></i>) –> <i>string</i></tt><a name="node_idx_936"></a></p>
<li><p></p>
<p class=noindent><tt>(machine-name<i></i>) –> <i>string</i></tt><a name="node_idx_938"></a></p>
</ul><p></p>
<p>
</p>
<p>
</p>
<a name="node_sec_9.6"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.6">9.6 Files and directories</a></h2>
<p>These procedures are in structures <tt>posix-files</tt> and <tt>posix</tt>.</p>
<p>
</p>
<a name="node_sec_9.6.1"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.6.1">9.6.1 Directory streams</a></h3>
<p>Directory streams are like input ports, with each read operation
returning the next name in the directory.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(open-directory-stream<i> name</i>) –> <i>directory</i></tt><a name="node_idx_940"></a></p>
<li><p></p>
<p class=noindent><tt>(directory-stream?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_942"></a></p>
<li><p></p>
<p class=noindent><tt>(read-directory-stream<i> directory</i>) –> <i>name or <tt>#f</tt></i></tt><a name="node_idx_944"></a></p>
<li><p></p>
<p class=noindent><tt>(close-directory-stream<i> directory</i>)</tt><a name="node_idx_946"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Open-directory-stream</tt> opens a new directory stream.
<tt>Directory-stream?</tt> is a predicate that recognizes directory streams.
<tt>Read-directory-stream</tt> returns the next name in the directory or
<tt>#f</tt> if all names have been read.
<tt>Close-directory-stream</tt> closes a directory stream.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(list-directory<i> name</i>) –> <i>list of os-strings</i></tt><a name="node_idx_948"></a></p>
</ul><p>
</p>
<p class=noindent>This is the obvious utility; it returns a list of the names in directory
<i>name</i>.</p>
<p>
</p>
<a name="node_sec_9.6.2"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.6.2">9.6.2 Working directory</a></h3>
<p></p>
<ul>
<li><p></p>
<p class=noindent><tt>(working-directory<i></i>) –> <i>os-string</i></tt><a name="node_idx_950"></a></p>
<li><p></p>
<p class=noindent><tt>(set-working-directory!<i> os-string-thing</i>)</tt><a name="node_idx_952"></a></p>
</ul><p>
</p>
<p class=noindent>These return and set the working directory.</p>
<p>
</p>
<a name="node_sec_9.6.3"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.6.3">9.6.3 File creation and removal</a></h3>
<p></p>
<ul>
<li><p></p>
<p class=noindent><tt>(open-file<i> path file-options</i>) –> <i>port</i></tt><a name="node_idx_954"></a></p>
<li><p></p>
<p class=noindent><tt>(open-file<i> path file-options file-mode</i>) –> <i>port</i></tt><a name="node_idx_956"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Open-file</tt> opens a port to the file named by <i>path</i>, which
must be a <i>os-string-thing</i> argument.
The <i>file-options</i> argument determines various aspects of the
returned port.
The optional <i>file-mode</i> argument is used only if the file to be opened
does not already exist.
The returned port is an input port if <i>file-options</i> includes
<tt>read-only</tt>; otherwise it returns an output port.
<tt>Dup-switching-mode</tt> can be used to open an input port for
output ports opened with the <tt>read/write</tt> option.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(file-options <i>file-option-name</i> <tt>...</tt>) –> <i>file-options</i></tt> (syntax)
</p>
<li><p></p>
<p class=noindent><tt>(file-options-on?<i> file-options file-options</i>) –> <i>boolean</i></tt><a name="node_idx_958"></a></p>
<li><p></p>
<p class=noindent><tt>(file-options-union<i> file-options file-options</i>) –> <i>file-options</i></tt><a name="node_idx_960"></a></p>
</ul><p>
</p>
<p class=noindent>The syntax <tt>file-options</tt> returns a file-option with the
indicated options set.
<tt>File-options-on?</tt> returns true if its first argument includes all of
the options listed in the second argument. <tt>File-options-union</tt>
returns a file-options argument containing exactly all of the options
listed in either argument.
The following file options may be used with <tt>open-file</tt>.</p>
<p>
</p>
<div align=center><table><tr><td>
<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
is required with this option </td></tr>
<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>
are both set and the file already exists </td></tr>
<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
causes the terminal to not become the controlling terminal of the process</td></tr>
<tr><td valign=top ></td><td valign=top ><tt>truncate</tt> </td><td valign=top >file is truncated </td></tr>
<tr><td valign=top ></td><td valign=top ><tt>append</tt> </td><td valign=top >writes are appended to existing contents </td></tr>
<tr><td valign=top ></td><td valign=top ><tt>nonblocking</tt> </td><td valign=top >read and write operations do not block </td></tr>
<tr><td valign=top ></td><td valign=top ><tt>read-only</tt> </td><td valign=top >port may not be written </td></tr>
<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>
<tr><td valign=top ></td><td valign=top ><tt>write-only</tt> </td><td valign=top >port may not be read
</td></tr></table>
</td></tr></table></div>
<p class=noindent>Only one of the last three options may be used. If
<tt>read-write</tt> is specified, an output port is returned.</p>
<p>
For example
</p>
<pre class=verbatim>(open-file "some-file.txt"
(file-options create write-only)
(file-mode read owner-write))
</pre><p>
returns an output port that writes to a newly-created file that can be
read by anyone and written only by the owner.
Once the file exists,
</p>
<pre class=verbatim>(open-file "some-file.txt"
(file-options append write-only))
</pre><p>
will open an output port that appends to the file.</p>
<p>
The <tt>append</tt> and <tt>nonblocking</tt> options and the read/write nature of
the port can be read using <tt>i/o-flags</tt>.
The <tt>append</tt> and <tt>nonblocking</tt> options can be set
using <tt>set-i/o-flags!</tt>.</p>
<p>
To keep port operations from blocking the Scheme 48 process, output
ports are set to be nonblocking at the time of creation (input ports
are managed using <tt>select()</tt>).
You can use <tt>set-i/o-flags!</tt> to make an output port blocking, for
example just before a fork, but care should be exercised.
The Scheme 48 runtime code may get confused if an I/O operation blocks.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(set-file-creation-mask!<i> file-mode</i>)</tt><a name="node_idx_962"></a></p>
</ul><p>
</p>
<p class=noindent>Sets the file creation mask to be <i>file-mode</i>.
Bits set in <i>file-mode</i> are cleared in the modes of any files or
directories created by the current process.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(link<i> existing new</i>)</tt><a name="node_idx_964"></a></p>
</ul><p>
</p>
<p class=noindent>Both <i>existing</i> and <i>new</i> must be <i>os-string-thing</i> arguments.
<tt>Link</tt> makes path <i>new</i> be a new link to the file
pointed to by path <i>existing</i>.
The two paths must be in the same file system.</p>
<p>
</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(make-directory<i> path file-mode</i>)</tt><a name="node_idx_966"></a></p>
<li><p></p>
<p class=noindent><tt>(make-fifo<i> path file-mode</i>)</tt><a name="node_idx_968"></a></p>
</ul><p>
</p>
<p class=noindent>These two procedures make new directories and fifo files. In both
cases, <i>path</i> must be a <i>os-string-thing</i> argument.</p>
<p>
</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(unlink<i> path</i>)</tt><a name="node_idx_970"></a></p>
<li><p></p>
<p class=noindent><tt>(remove-directory<i> path</i>)</tt><a name="node_idx_972"></a></p>
<li><p></p>
<p class=noindent><tt>(rename<i> old-path new-path</i>)</tt><a name="node_idx_974"></a></p>
</ul><p>
</p>
<p class=noindent><i>Path</i>, <i>old-path</i> and <i>new-path</i> must all be
<i>os-string-thing</i> arguments.
<tt>Unlink</tt> removes the link indicated by <i>path</i>.
<tt>Remove-directory</tt> removes the indicated (empty) directory.
<tt>Rename</tt> moves the file pointed to by <i>old-path</i> to the
location pointed to by <i>new-path</i> (the two paths must be in
the same file system).
Any other links to the file remain unchanged.</p>
<p>
</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(accessible?<i> path access-mode . more-modes</i>) –> <i>boolean</i></tt><a name="node_idx_976"></a></p>
<li><p></p>
<p class=noindent><tt>(access-mode <i>mode-name</i>) –> <i>access-mode</i></tt> (syntax)
</p>
</ul><p>
</p>
<p class=noindent><tt>Accessible?</tt> returns true if <i>path</i> (which must be a
<i>os-string-thing</i> argument) is a file that
can be accessed in the listed mode.
If more than one mode is specified <tt>accessible?</tt> returns true
if all of the specified modes are permitted.
The <i>mode-name</i>s are: <tt>read</tt>, <tt>write</tt>, <tt>execute</tt>,
<tt>exists</tt>.</p>
<p>
</p>
<a name="node_sec_9.6.4"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.6.4">9.6.4 File information</a></h3>
<p></p>
<ul>
<li><p></p>
<p class=noindent><tt>(get-file-info<i> path</i>) –> <i>file-info</i></tt><a name="node_idx_978"></a></p>
<li><p></p>
<p class=noindent><tt>(get-file/link-info<i> name</i>) –> <i>file-info</i></tt><a name="node_idx_980"></a></p>
<li><p></p>
<p class=noindent><tt>(get-port-info<i> fd-port</i>) –> <i>file-info</i></tt><a name="node_idx_982"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Get-file-info</tt> and <tt>get-file/link-info</tt> both return
a file info record for the file named by <i>path</i>, which must be a
<i>os-string-thing</i> argument.
<tt>Get-file-info</tt> follows symbolic links while <tt>get-file/link-info</tt>
does not.
<tt>Get-port-info</tt> returns a file info record for the file
which <i>port</i> reads from or writes to.
An error is raised if <i>fd-port</i> does not read from or write to a
file descriptor.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(file-info?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_984"></a></p>
<li><p></p>
<p class=noindent><tt>(file-info-name<i> file-info</i>) –> <i>os-string</i></tt><a name="node_idx_986"></a></p>
</ul><p>
</p>
<p class=noindent><tt>File-info?</tt> is a predicate for file-info records.
<tt>File-info-name</tt> is the name which was used to get <tt>file-info</tt>,
either as passed to <tt>get-file-info</tt> or <tt>get-file/link-info</tt>,
or used to open the port passed to <tt>get-port-info</tt>.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(file-info-type<i> file-info</i>) –> <i>file-type</i></tt><a name="node_idx_988"></a></p>
<li><p></p>
<p class=noindent><tt>(file-type?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_990"></a></p>
<li><p></p>
<p class=noindent><tt>(file-type-name<i> file-type</i>) –> <i>symbol</i></tt><a name="node_idx_992"></a></p>
<li><p></p>
<p class=noindent><tt>(file-type <i>type</i>) –> <i>file-type</i></tt> (syntax)
</p>
</ul><p>
</p>
<p class=noindent><tt>File-info-type</tt> returns the type of the file, as a file-type object
File types may be compared using <tt>eq?</tt>.
The valid file types are:</p>
<p>
</p>
<div align=center><table><tr><td>
<table border=0><tr><td valign=top ><tt>regular</tt> </td></tr>
<tr><td valign=top ><tt>directory</tt> </td></tr>
<tr><td valign=top ><tt>character-device</tt> </td></tr>
<tr><td valign=top ><tt>block-device</tt> </td></tr>
<tr><td valign=top ><tt>fifo</tt> </td></tr>
<tr><td valign=top ><tt>symbolic-link</tt> </td></tr>
<tr><td valign=top ><tt>socket</tt> </td></tr>
<tr><td valign=top ><tt>other</tt>
</td></tr></table>
</td></tr></table></div>
<p>
</p>
<p class=noindent><tt>Symbolic-link</tt> and <tt>socket</tt> are not required by POSIX.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(file-info-device<i> file-info</i>) –> <i>integer</i></tt><a name="node_idx_994"></a></p>
<li><p></p>
<p class=noindent><tt>(file-info-inode<i> file-info</i>) –> <i>integer</i></tt><a name="node_idx_996"></a></p>
</ul><p>
</p>
<p class=noindent>The device and inode numbers uniquely determine a file.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(file-info-link-count<i> file-info</i>) –> <i>integer</i></tt><a name="node_idx_998"></a></p>
<li><p></p>
<p class=noindent><tt>(file-info-size<i> file-info</i>) –> <i>integer</i></tt><a name="node_idx_1000"></a></p>
</ul><p>
</p>
<p class=noindent>These return the number of links to a file and the file size in bytes.
The size is only meaningful for regular files.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(file-info-owner<i> file-info</i>) –> <i>user-id</i></tt><a name="node_idx_1002"></a></p>
<li><p></p>
<p class=noindent><tt>(file-info-group<i> file-info</i>) –> <i>group-id</i></tt><a name="node_idx_1004"></a></p>
<li><p></p>
<p class=noindent><tt>(file-info-mode<i> file-info</i>) –> <i>file-mode</i></tt><a name="node_idx_1006"></a></p>
</ul><p>
</p>
<p class=noindent>These return the owner, group, and access mode of a file.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(file-info-last-access<i> file-info</i>) –> <i>time</i></tt><a name="node_idx_1008"></a></p>
<li><p></p>
<p class=noindent><tt>(file-info-last-modification<i> file-info</i>) –> <i>time</i></tt><a name="node_idx_1010"></a></p>
<li><p></p>
<p class=noindent><tt>(file-info-last-status-change<i> file-info</i>) –> <i>time</i></tt><a name="node_idx_1012"></a></p>
</ul><p>
</p>
<p class=noindent>These return the time the file was last read, modified, or had its
status modified.</p>
<p>
</p>
<a name="node_sec_9.6.5"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.6.5">9.6.5 File modes</a></h3>
<p>A file mode is a boxed integer representing a file protection mask.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(file-mode permission-name <tt>...</tt>) –> <i>file-mode</i></tt> (syntax)
</p>
<li><p></p>
<p class=noindent><tt>(file-mode?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_1014"></a></p>
<li><p></p>
<p class=noindent><tt>(file-mode+<i> file-mode <tt>...</tt></i>) –> <i>file-mode</i></tt><a name="node_idx_1016"></a></p>
<li><p></p>
<p class=noindent><tt>(file-mode-<i> file-mode0 file-mode1</i>) –> <i>file-mode</i></tt><a name="node_idx_1018"></a></p>
</ul><p>
</p>
<p class=noindent><tt>File-mode</tt> is syntax for creating file modes.
The mode-names are listed below.
<tt>File-mode?</tt> is a predicate for file modes.
<tt>File-mode+</tt> returns a mode that contains all of permissions of
its arguments.
<tt>File-mode-</tt> returns a mode that has all of the permissions of
<i>file-mode0</i> that are not in <i>file-mode1</i>.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(file-mode=?<i> file-mode0 file-mode1</i>) –> <i>boolean</i></tt><a name="node_idx_1020"></a></p>
<li><p></p>
<p class=noindent><tt>(file-mode<=?<i> file-mode0 file-mode1</i>) –> <i>boolean</i></tt><a name="node_idx_1022"></a></p>
<li><p></p>
<p class=noindent><tt>(file-mode>=?<i> file-mode0 file-mode1</i>) –> <i>boolean</i></tt><a name="node_idx_1024"></a></p>
</ul><p>
</p>
<p class=noindent><tt>File-mode=?</tt> returns true if the two modes are exactly the same.
<tt>File-mode<=?</tt> returns true if <i>file-mode0</i> has a subset
of the permissions of <i>file-mode1</i>.
<tt>File-mode>=?</tt> is <tt>file-mode<=?</tt> with the arguments reversed.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(file-mode->integer<i> file-mode</i>) –> <i>integer</i></tt><a name="node_idx_1026"></a></p>
<li><p></p>
<p class=noindent><tt>(integer->file-mode<i> integer</i>) –> <i>file-mode</i></tt><a name="node_idx_1028"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Integer->file-mode</tt> and <tt>file-mode->integer</tt> translate file modes
to and from the classic Unix file mode masks.
These may not be the masks used by the underlying OS.</p>
<p>
</p>
<div align=center><table><tr><td>
<table border=0><tr><td valign=top >Permission name </td><td valign=top >Bit mask </td></tr>
<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>
<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>
<tr><td valign=top ><tt>owner-read</tt> </td><td valign=top ><tt>#o0400</tt> </td><td valign=top >read by owner </td></tr>
<tr><td valign=top ><tt>owner-write</tt> </td><td valign=top ><tt>#o0200</tt> </td><td valign=top >write by owner </td></tr>
<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>
<tr><td valign=top ><tt>group-read</tt> </td><td valign=top ><tt>#o0040</tt> </td><td valign=top >read by group </td></tr>
<tr><td valign=top ><tt>group-write</tt> </td><td valign=top ><tt>#o0020</tt> </td><td valign=top >write by group </td></tr>
<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>
<tr><td valign=top ><tt>other-read</tt> </td><td valign=top ><tt>#o0004</tt> </td><td valign=top >read by others </td></tr>
<tr><td valign=top ><tt>other-write</tt> </td><td valign=top ><tt>#o0002</tt> </td><td valign=top >write by others </td></tr>
<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>
<tr><td valign=top ></td></tr></table>
</td></tr></table></div>
<p>
</p>
<div align=center><table><tr><td>
<table border=0><tr><td valign=top colspan=3>Names for sets of permissions </td></tr>
<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>
<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>
<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>
<tr><td valign=top ><tt>read</tt> </td><td valign=top ><tt>#o0444</tt> </td><td valign=top >read by anyone </td></tr>
<tr><td valign=top ><tt>write</tt> </td><td valign=top ><tt>#o0222</tt> </td><td valign=top >write by anyone </td></tr>
<tr><td valign=top ><tt>exec</tt> </td><td valign=top ><tt>#o0111</tt> </td><td valign=top >execute by anyone </td></tr>
<tr><td valign=top ><tt>all</tt> </td><td valign=top ><tt>#o0777</tt> </td><td valign=top >anything by anyone
</td></tr></table>
</td></tr></table></div>
<p>
</p>
<a name="node_sec_9.6.6"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.6.6">9.6.6 Symbolic links</a></h3>
<p></p>
<ul>
<li><p></p>
<p class=noindent><tt>(create-symbolic-link<i> path1 path2</i>)</tt><a name="node_idx_1030"></a></p>
</ul><p>
This creates a symbolic link at <i>path2</i> that contains <i>path1</i>.
<i>Path1</i> and <i>path2</i> must be <i>os-string-thing</i> arguments.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(read-symbolic-link<i> path</i>) –> <i> os-string</i></tt><a name="node_idx_1032"></a></p>
</ul><p>
This returns contents of the symbolic link at <i>path</i>.
<i>Path</i> must be an <i>os-string-thing</i> argument.</p>
<p>
</p>
<a name="node_sec_9.7"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.7">9.7 Time and Date</a></h2>
<p>These procedures are in structures <tt>posix-time</tt> and <tt>posix</tt>.</p>
<p>
</p>
<a name="node_sec_9.7.1"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.7.1">9.7.1 Time</a></h3>
<p></p>
<ul>
<li><p></p>
<p class=noindent><tt>(make-time<i> integer</i>) –> <i>time</i></tt><a name="node_idx_1034"></a></p>
<li><p></p>
<p class=noindent><tt>(current-time<i></i>) –> <i>time</i></tt><a name="node_idx_1036"></a></p>
<li><p></p>
<p class=noindent><tt>(time?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_1038"></a></p>
<li><p></p>
<p class=noindent><tt>(time-seconds<i> time</i>) –> <i>integer</i></tt><a name="node_idx_1040"></a></p>
</ul><p>
</p>
<p class=noindent>A <tt>time</tt> record contains an integer that represents time as
the number of second since the Unix epoch (00:00:00 GMT, January 1, 1970).
<tt>Make-time</tt> and <tt>current-time</tt> return <tt>time</tt>s, with
<tt>make-time</tt>'s using its argument while <tt>current-time</tt>'s has
the current time.
<tt>Time?</tt> is a predicate that recognizes <tt>time</tt>s and
<tt>time-seconds</tt> returns the number of seconds <i>time</i> represents.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(time=?<i> time time</i>) –> <i>boolean</i></tt><a name="node_idx_1042"></a></p>
<li><p></p>
<p class=noindent><tt>(time<?<i> time time</i>) –> <i>boolean</i></tt><a name="node_idx_1044"></a></p>
<li><p></p>
<p class=noindent><tt>(time<=?<i> time time</i>) –> <i>boolean</i></tt><a name="node_idx_1046"></a></p>
<li><p></p>
<p class=noindent><tt>(time>?<i> time time</i>) –> <i>boolean</i></tt><a name="node_idx_1048"></a></p>
<li><p></p>
<p class=noindent><tt>(time>=?<i> time time</i>) –> <i>boolean</i></tt><a name="node_idx_1050"></a></p>
</ul><p>
</p>
<p class=noindent>These perform various comparison operations on the <tt>time</tt>s.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(time->string<i> time</i>) –> <i>string</i></tt><a name="node_idx_1052"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Time->string</tt> returns a string representation of <i>time</i> in the
locale's version of the following form.
</p>
<pre class=verbatim>"Wed Jun 30 21:49:08 1993
"
</pre><p></p>
<p>
</p>
<a name="node_sec_9.7.2"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.7.2">9.7.2 Date</a></h3>
<p>A date is a time specification relative to a specific but implicit
time zone, broken out into the familar
year-month-day-hour-minute-second format.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(make-date<i> second minute hour month-day month year week-day year-day dst</i>) –> <i>date</i></tt><a name="node_idx_1054"></a></p>
<li><p></p>
<p class=noindent><tt>(date?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_1056"></a></p>
<li><p></p>
<p class=noindent><tt>(date-second<i> date</i>) –> <i>second</i></tt><a name="node_idx_1058"></a></p>
<li><p></p>
<p class=noindent><tt>(date-minute<i> date</i>) –> <i>minute</i></tt><a name="node_idx_1060"></a></p>
<li><p></p>
<p class=noindent><tt>(date-hour<i> date</i>) –> <i>hour</i></tt><a name="node_idx_1062"></a></p>
<li><p></p>
<p class=noindent><tt>(date-month-day<i> date</i>) –> <i>month-day</i></tt><a name="node_idx_1064"></a></p>
<li><p></p>
<p class=noindent><tt>(date-month<i> date</i>) –> <i>month</i></tt><a name="node_idx_1066"></a></p>
<li><p></p>
<p class=noindent><tt>(date-year<i> date</i>) –> <i>year</i></tt><a name="node_idx_1068"></a></p>
<li><p></p>
<p class=noindent><tt>(date-week-day<i> date</i>) –> <i>week-day</i></tt><a name="node_idx_1070"></a></p>
<li><p></p>
<p class=noindent><tt>(date-year-day<i> date</i>) –> <i>year-day</i></tt><a name="node_idx_1072"></a></p>
<li><p></p>
<p class=noindent><tt>(date-date-dst<i> date</i>) –> <i>dst</i></tt><a name="node_idx_1074"></a></p>
</ul><p>
These are the constructor, predicate and corresponding accessors for
date objects. The meaning of the various field types are as follows:</p>
<p>
</p>
<div align=center><table><tr><td>
<table border=0><tr><td valign=top ><i>seconds</i> </td><td valign=top >seconds </td><td valign=top >(0–60) </td></tr>
<tr><td valign=top ><i>minutes</i> </td><td valign=top >minutes </td><td valign=top >(0–59) </td></tr>
<tr><td valign=top ><i>hour</i> </td><td valign=top >hours </td><td valign=top >(0–23) </td></tr>
<tr><td valign=top ><i>month-day</i> </td><td valign=top >day of month </td><td valign=top >(1–31) </td></tr>
<tr><td valign=top ><i>mon</i> </td><td valign=top >month of year </td><td valign=top >(0–11) </td></tr>
<tr><td valign=top ><i>year</i> </td><td valign=top >year </td><td valign=top >since 1900</td></tr>
<tr><td valign=top ><i>week-day</i> </td><td valign=top >day of week </td><td valign=top >(Sunday = 0) </td></tr>
<tr><td valign=top ><i>year-day</i> </td><td valign=top >day of year </td><td valign=top >(0–365) </td></tr>
<tr><td valign=top ><i>dst</i> </td><td valign=top >is summer time in effect? </td><td valign=top ><tt>#t</tt>, <tt>#f</tt> or unspecific
</td></tr></table>
</td></tr></table></div>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(date->string<i> date</i>) –> <i>string</i></tt><a name="node_idx_1076"></a></p>
</ul><p>
returns a string representation of <i>date</i> in the
locale's version of the following form:
</p>
<pre class=verbatim>"Wed Jun 30 21:49:08 1993
"
</pre><p></p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(time->utc-date<i> time</i>) –> <i>date</i></tt><a name="node_idx_1078"></a></p>
<li><p></p>
<p class=noindent><tt>(time->local-date<i> time</i>) –> <i>date</i></tt><a name="node_idx_1080"></a></p>
</ul><p>
These convert a time object into a date object; the first does this
relative to the UTC time zone, the second relative to the current
timezone setting.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(date->time<i> date</i>) –> <i>time</i></tt><a name="node_idx_1082"></a></p>
</ul><p>
This converts a date object into a time object relative to the current
timezone setting.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(format-date<i> string date</i>) –> <i>string</i></tt><a name="node_idx_1084"></a></p>
</ul><p>
This formats a date into a string, according to the format
specification in the first argument. The format specification is
according to the specification of the C <tt>strftime</tt> function:</p>
<p>
</p>
<p class=noindent></p>
lp0.9
<tt>%a</tt> & is replaced by the locale's abbreviated weekday name.<br>
<tt>%A</tt> & is replaced by the locale's full weekday name.<br>
<tt>%b</tt> & is replaced by the locale's abbreviated month name.<br>
<tt>%B</tt> & is replaced by the locale's full month name.<br>
<tt>%c</tt> & is replaced by the locale's appropriate date and time representation.<br>
<tt>%C</tt> & is replaced by the year divided by 100 and truncated to an integer, as a decimal
number (00–99).<br>
<tt>%d</tt> & is replaced by the day of the month as a decimal number (01–31).<br>
<tt>%D</tt> & is equivalent to “<code class=verbatim>%m/%d/%y</code>”.<br>
<tt>%e</tt> & is replaced by the day of the month as a decimal number (1–31); a single digit
is preceded by a space.<br>
<tt>%F</tt> & is equivalent to “<code class=verbatim>%Y‑%m‑%d</code>” (the ISO 8601 date format).<br>
<tt>%g</tt> & is replaced by the last 2 digits of the week-based year (see below) as a decimal
number (00–99).<br>
<tt>%G</tt> & is replaced by the week-based year (see below) as a decimal number (e.g.,
1997).<br>
<tt>%h</tt> & is equivalent to “<code class=verbatim>%b</code>”.<br>
<tt>%H</tt> & is replaced by the hour (24-hour clock) as a decimal number (00–23).<br>
<tt>%I</tt> & is replaced by the hour (12-hour clock) as a decimal number (01–12).<br>
<tt>%j</tt> & is replaced by the day of the year as a decimal number (001–366).<br>
<tt>%m</tt> & is replaced by the month as a decimal number (01–12).<br>
<tt>%M</tt> & is replaced by the minute as a decimal number (00–59).<br>
<tt>%n</tt> & is replaced by a new-line character.<br>
<tt>%p</tt> & is replaced by the locale's equivalent of the AM/PM designations associated
with a 12-hour clock.<br>
<tt>%r</tt> & is replaced by the locale's 12-hour clock time.<br>
<tt>%R</tt> & is equivalent to “<code class=verbatim>%H:%M</code>”.<br>
<tt>%S</tt> & is replaced by the second as a decimal number (00–60).<br>
<tt>%t</tt> & is replaced by a horizontal-tab character.<br>
<tt>%T</tt> & is equivalent to “<code class=verbatim>%H:%M:%S</code>” (the ISO 8601 time format).<br>
<tt>%u</tt> & is replaced by the ISO 8601 weekday as a decimal number (1–7), where
Monday is 1.<br>
<tt>%U</tt> & is replaced by the week number of the year (the first Sunday as the first day of
week 1) as a decimal number (00–53).<br>
<tt>%V</tt> & is replaced by the ISO 8601 week number (see below) as a decimal number
(01–53).<br>
<tt>%w</tt> & is replaced by the weekday as a decimal number (0–6), where Sunday is 0.<br>
<tt>%W</tt> & is replaced by the week number of the year (the first Monday as the first day of
week 1) as a decimal number (00–53).<br>
<tt>%x</tt> & is replaced by the locale's appropriate date representation.<br>
<tt>%X</tt> & is replaced by the locale's appropriate time representation.<br>
<tt>%y</tt> & is replaced by the last 2 digits of the year as a decimal number (00–99).<br>
<tt>%Y</tt> & is replaced by the year as a decimal number (e.g., 1997).<br>
<tt>%z</tt> & is replaced by the offset from UTC in the ISO 8601 format “<code class=verbatim>‑0430</code>” (meaning
4 hours 30 minutes behind UTC, west of Greenwich), or by no characters if no
time zone is determinable.<br>
<tt>%Z</tt> & is replaced by the locale's time zone name or abbreviation, or by no characters if
no time zone is determinable.<br>
<tt>%%</tt> & is replaced by <code class=verbatim>%</code>.
<p>
</p>
<a name="node_sec_9.8"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.8">9.8 I/O</a></h2>
<p>These procedures are in structures <tt>posix-i/o</tt> and <tt>posix</tt>.</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(open-pipe<i></i>) –> <i>input-port + output-port</i></tt><a name="node_idx_1086"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Open-pipe</tt> creates a new pipe and returns the two ends as an
input port and an output port.</p>
<p>
</p>
<p>
A <em>file descriptor</em> port (or <i>fd-port</i>)
is a port that reads to or writes from an OS file descriptor.
Fd-ports are returned by <tt>open-input-file</tt>, <tt>open-output-file</tt>,
<tt>open-file</tt>, <tt>open-pipe</tt>, and other procedures.
</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(fd-port?<i> port</i>) –> <i>boolean</i></tt><a name="node_idx_1088"></a></p>
<li><p></p>
<p class=noindent><tt>(port->fd<i> port</i>) –> <i>integer or <tt>#f</tt></i></tt><a name="node_idx_1090"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Fd-port?</tt> returns true if its argument is an fd-port.
<tt>Port->fd</tt> returns the file descriptor associated with
or <tt>#f</tt> if <i>port</i> is not an fd-port.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(remap-file-descriptors<i> fd-spec <tt>...</tt></i>)</tt><a name="node_idx_1092"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Remap-file-descriptors</tt> reassigns file descriptors to ports.
The <i>fd-specs</i> indicate which port is to be mapped to each
file descriptor: the first gets file descriptor <tt>0</tt>, the second gets
<tt>1</tt>, and so forth.
A <i>fd-spec</i> is either a port that reads from or writes to
a file descriptor,
or <tt>#f</tt>, with <tt>#f</tt> indicating that the corresponding file
descriptor is not used.
Any open ports not listed are marked `close-on-exec'.
The same port may be moved to multiple new file descriptors.</p>
<p>
For example,
</p>
<pre class=verbatim>(remap-file-descriptors (current-output-port)
#f
(current-input-port))
</pre><p>
moves the current output port to file descriptor <tt>0</tt> and the
current input port to file descriptor <tt>2</tt>.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(dup<i> fd-port</i>) –> <i>fd-port</i></tt><a name="node_idx_1094"></a></p>
<li><p></p>
<p class=noindent><tt>(dup-switching-mode<i> fd-port</i>) –> <i>fd-port</i></tt><a name="node_idx_1096"></a></p>
<li><p></p>
<p class=noindent><tt>(dup2<i> fd-port file-descriptor</i>) –> <i>fd-port</i></tt><a name="node_idx_1098"></a></p>
</ul><p>
</p>
<p class=noindent>These change <i>fd-port</i>'s file descriptor and return a new port
that uses <i>ports</i>'s old file descriptor.
<tt>Dup</tt> uses the lowest unused file descriptor and <tt>dup2</tt> uses the
one provided.
<tt>Dup-switching-mode</tt> is the same as <tt>dup</tt> except that the returned
port is an input port if the argument was an output port and vice
versa.
If any existing port uses the file descriptor passed to <tt>dup2</tt>, that
port is closed.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(close-all-but<i> port <tt>...</tt></i>)</tt><a name="node_idx_1100"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Close-all-but</tt> closes all file descriptors whose associated ports
are not passed to it as arguments.</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(close-on-exec?<i> port</i>) –> <i>boolean</i></tt><a name="node_idx_1102"></a></p>
<li><p></p>
<p class=noindent><tt>(set-close-on-exec?!<i> port boolean</i>)</tt><a name="node_idx_1104"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Close-on-exec?</tt> returns true if <tt>port</tt> will be closed
when a new program is exec'ed.
<tt>Set-close-on-exec?!</tt> sets <tt>port</tt>'s close-on-exec flag.</p>
<p>
</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(i/o-flags<i> port</i>) –> <i>file-options</i></tt><a name="node_idx_1106"></a></p>
<li><p></p>
<p class=noindent><tt>(set-i/o-flags!<i> port file-options</i>)</tt><a name="node_idx_1108"></a></p>
</ul><p>
</p>
<p class=noindent>These two procedures read and write various options for <tt>port</tt>.
The options that can be read are <tt>append</tt>, <tt>nonblocking</tt>,
<tt>read-only</tt>, <tt>write-only</tt>, and <tt>read/write</tt>.
Only the <tt>append</tt> and <tt>nonblocking</tt> can be written.</p>
<p>
</p>
<p>
</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(port-is-a-terminal?<i> port</i>) –> <i>boolean</i></tt><a name="node_idx_1110"></a></p>
<li><p></p>
<p class=noindent><tt>(port-terminal-name<i> port</i>) –> <i>string</i></tt><a name="node_idx_1112"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Port-is-a-terminal?</tt> returns true if <i>port</i> has an underlying
file descriptor that is associated with a terminal.
For such ports <tt>port-terminal-name</tt> returns the name of the
terminal, for all others it returns <tt>#f</tt>.</p>
<p>
</p>
<p>
</p>
<a name="node_sec_9.9"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.9">9.9 Regular expressions</a></h2>
<p></p>
<p>
The procedures in this section provide access to POSIX regular expression
matching.
The regular expression syntax and semantics are far too complex to
be described here.
Due to limitations in the underlying facility, only Latin-1 strings
are guaranteed to work here—on some platforms, only ASCII may
function correctly.
Moreover, because the C interface uses zero bytes for marking the ends of strings,
patterns and strings that contain zero bytes will not work
correctly.</p>
<p>
These procedures are in structures <tt>posix-regexps</tt> and <tt>posix</tt>.</p>
<p>
An abstract data type for creating POSIX regular expressions is
described in section <a href="manual-Z-H-6.html#node_sec_5.21">5.21</a>.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(make-regexp<i> string . regexp-options</i>) –> <i>regexp</i></tt><a name="node_idx_1114"></a></p>
<li><p></p>
<p class=noindent><tt>(regexp-option <i>option-name</i>) –> <i>regexp-option</i></tt> (syntax)
</p>
</ul><p>
</p>
<p class=noindent><tt>Make-regexp</tt> makes a new regular expression, using <i>string</i>
as the pattern.
The possible option names are:</p>
<p>
</p>
<div align=center><table><tr><td>
<table border=0><tr><td valign=top ><tt>extended</tt> </td><td valign=top >use the extended patterns </td></tr>
<tr><td valign=top ><tt>ignore-case</tt> </td><td valign=top >ignore case when matching </td></tr>
<tr><td valign=top ><tt>submatches</tt> </td><td valign=top >report submatches </td></tr>
<tr><td valign=top ><tt>newline</tt> </td><td valign=top >treat newlines specially
</td></tr></table>
</td></tr></table></div>
<p>
The regular expression is not compiled until it matched against a string,
so any errors in the pattern string will not be reported until that
point.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(regexp?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_1116"></a></p>
</ul><p>
</p>
<p class=noindent>This is a predicate for regular expressions.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(regexp-match<i> regexp string start submatches? starts-line? ends-line?</i>)</tt><a name="node_idx_1118"></a><br>
</p>
<p class=noindent><tt> –> <i>boolean or list of matches</i></tt>
</p>
<li><p></p>
<p class=noindent><tt>(match?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_1120"></a></p>
<li><p></p>
<p class=noindent><tt>(match-start<i> match</i>) –> <i>integer</i></tt><a name="node_idx_1122"></a></p>
<li><p></p>
<p class=noindent><tt>(match-end<i> match</i>) –> <i>integer</i></tt><a name="node_idx_1124"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Regexp-match</tt> matches the regular expression against the characters
in <i>string</i>, starting at position <i>start</i>.
If the string does not match the regular expression, <tt>regexp-match</tt>
returns <tt>#f</tt>.
If the string does match, then a list of match records is returned
if <i>submatches?</i> is true, or <tt>#t</tt> is returned if it is not.
Each match record contains the index of the character at the beginning
of the match and one more than the index of the character at the end.
The first match record gives the location of the substring that matched
<i>regexp</i>.
If the pattern in <i>regexp</i> contained submatches, then the results
of these are returned in order, with a match records reporting submatches
that succeeded and <tt>#f</tt> in place of those that did not.</p>
<p>
<i>Starts-line?</i> should be true if <i>string</i> starts at the beginning
of a line and <i>ends-line?</i> should be true if it ends one.</p>
<p>
</p>
<a name="node_sec_9.10"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.10">9.10 Syslog facility</a></h2>
<p></p>
<p>
The procedures in this section provide access to the POSIX syslog
facility. The functionality is in a structure called
<tt>posix-syslog</tt>. The Scheme 48 interface to the
syslog facility differs significantly from that of the Unix library
functionality in order to support multiple simultaneous connections to
the syslog facility.</p>
<p>
Log messages carry a variety of parameters beside the text of the
message itself, namely a set of options controlling the output format
and destination, the facility identifying the class of programs the
message is coming from, an identifier specifying the concrete program,
and the level identifying the importance of the message. Moreover, a
log mask can prevent messages at certain levels to be actually sent to
the syslog daemon.</p>
<p>
</p>
<a name="node_sec_Temp_24"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_Temp_24">Log options</a></h3>
<p>A log option specifies details of the I/O behavior of the syslog
facility. A syslog option is an element of a finite type (see
Section <a href="manual-Z-H-6.html#node_sec_5.10">5.10</a>) constructed by the
<tt>syslog-option</tt> macro. The syslog facility works with sets of
options which are represented as enum sets (see
Section <a href="manual-Z-H-6.html#node_sec_5.11">5.11</a>).</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(syslog-option <i>option-name</i>) –> <i>option</i></tt> (syntax)
</p>
<li><p></p>
<p class=noindent><tt>(syslog-option?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_1126"></a></p>
<li><p></p>
<p class=noindent><tt>(make-syslog-options<i> list</i>) –> <i>options</i></tt><a name="node_idx_1128"></a></p>
<li><p></p>
<p class=noindent><tt>(syslog-options <i>option-name</i> <tt>...</tt>) –> <i>options</i></tt> (syntax)
</p>
<li><p></p>
<p class=noindent><tt>(syslog-options?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_1130"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Syslog-option</tt> constructs a log option from the name of an
option. (The possible names are listed below.) <tt>Syslog-option?</tt>
is a predicate for log options. Options are comparable using
<tt>eq?</tt>. <tt>Make-syslog-options</tt> constructs a set of options
from a list of options. <tt>Syslog-options</tt> is a macro which
expands into an expression returning a set of options from names.
<tt>Syslog-options?</tt> is a predicate for sets of options.</p>
<p>
Here is a list of possible names of syslog options:</p>
<p>
</p>
<dl><dt></dt><dd>
</dd><dt><b><tt>console</tt></b></dt><dd>
If syslog cannot pass the message to syslogd it will attempt to
write the message to the console.<p>
</p>
</dd><dt><b><tt>delay</tt></b></dt><dd>
Delay opening the connection to syslogd immediately until the first
message is logged.<p>
</p>
</dd><dt><b><tt>no-delay</tt></b></dt><dd>
Open the connection to syslogd immediately. Normally
the open is delayed until the first message is logged.
Useful for programs that need to manage the order in which
file descriptors are allocated.<p>
</p>
<p class=noindent><b>NOTA BENE:</b>
The <tt>delay</tt> and <tt>no-delay</tt> options are included for
completeness, but do not have the expected effect in the present
Scheme interface: Because the Scheme interface has to multiplex
multiple simultaneous connections to the syslog facility over a
single one, open and close operations on that facility happen at
unpredictable times.</p>
<p>
</p>
</dd><dt><b><tt>log-pid</tt></b></dt><dd>
Log the process id with each message: useful for identifying
instantiations of daemons.<p>
</p>
</dd><dt><b><tt>no-wait</tt></b></dt><dd>
Do not wait for child processes.
</dd></dl><p></p>
<p>
</p>
<a name="node_sec_Temp_25"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_Temp_25">Log facilities</a></h3>
<p>A log facility identifies the originator of a log message from a
finite set known to the system. Each originator is identified by a
name:</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(syslog-facility <i>facility-name</i>) –> <i>facility</i></tt> (syntax)
</p>
<li><p></p>
<p class=noindent><tt>(syslog-facility?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_1132"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Syslog-facility</tt> is macro that expands into an expression
returning a facility for a given name. <tt>Syslog-facility?</tt> is a
predicate for facilities. Facilities are comparable via <tt>eq?</tt>.</p>
<p>
Here is a list of possible names of syslog facilities:</p>
<p>
</p>
<dl><dt></dt><dd>
</dd><dt><b><tt>authorization</tt></b></dt><dd>
The authorization system: login, su, getty, etc.<p>
</p>
</dd><dt><b><tt>cron</tt></b></dt><dd>
The cron daemon.<p>
</p>
</dd><dt><b><tt>daemon</tt></b></dt><dd>
System daemons, such as routed, that are not provided for explicitly
by other facilities.<p>
</p>
</dd><dt><b><tt>kernel</tt></b></dt><dd>
Messages generated by the kernel.<p>
</p>
</dd><dt><b><tt>lpr</tt></b></dt><dd>
The line printer spooling system: lpr, lpc, lpd, etc.<p>
</p>
</dd><dt><b><tt>mail</tt></b></dt><dd>
The mail system.<p>
</p>
</dd><dt><b><tt>news</tt></b></dt><dd>
The network news system.<p>
</p>
</dd><dt><b><tt>user</tt></b></dt><dd>
Messages generated by random user processes.<p>
</p>
</dd><dt><b><tt>uucp</tt></b></dt><dd>
The uucp system.<p>
</p>
</dd><dt><b><tt>local0</tt> <tt>local1</tt> <tt>local2</tt> <tt>local3</tt> <tt>local4</tt> <tt>local5</tt> <tt>local6</tt> <tt>local7</tt></b></dt><dd>
Reserved for local use.
</dd></dl><p></p>
<p>
</p>
<a name="node_sec_Temp_26"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_Temp_26">Log levels</a></h3>
<p>A log level identifies the importance of a message from a fixed set
of possible levels.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(syslog-level <i>level-name</i>) –> <i>level</i></tt> (syntax)
</p>
<li><p></p>
<p class=noindent><tt>(syslog-level?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_1134"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Syslog-level</tt> is macro that expands into an expression returning
a facility for a given name. <tt>Syslog-level?</tt> is a predicate for
facilities. Levels are comparable via <tt>eq?</tt>.</p>
<p>
Here is a list of possible names of syslog levels:</p>
<p>
</p>
<dl><dt></dt><dd>
</dd><dt><b><tt>emergency</tt></b></dt><dd>
A panic condition. This is normally broadcast to all users.<p>
</p>
</dd><dt><b><tt>alert</tt></b></dt><dd>
A condition that should be corrected immediately, such as a
corrupted system database.<p>
</p>
</dd><dt><b><tt>critical</tt></b></dt><dd>
Critical conditions, e.g., hard device errors.<p>
</p>
</dd><dt><b><tt>error</tt></b></dt><dd>
Errors.<p>
</p>
</dd><dt><b><tt>warning</tt></b></dt><dd>
Warning messages.<p>
</p>
</dd><dt><b><tt>notice</tt></b></dt><dd>
Conditions that are not error conditions, but should possibly be
handled specially.<p>
</p>
</dd><dt><b><tt>info</tt></b></dt><dd>
Informational messages.<p>
</p>
</dd><dt><b><tt>debug</tt></b></dt><dd>
Messages that contain information normally of use only when
debugging a program.
</dd></dl><p></p>
<p>
</p>
<a name="node_sec_Temp_27"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_Temp_27">Log masks</a></h3>
<p>A log masks can mask out log messages at a set of levels. A log
mask is an enum set of log levels.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(make-syslog-mask<i> list</i>) –> <i>mask</i></tt><a name="node_idx_1136"></a></p>
<li><p></p>
<p class=noindent><tt>(syslog-mask <i>level-name</i> <tt>...</tt>) –> <i>mask</i></tt> (syntax)
</p>
<li><p></p>
<p class=noindent><tt>syslog-mask-all</tt> ( mask)<a name="node_idx_1138"></a></p>
<li><p></p>
<p class=noindent><tt>(syslog-mask-upto<i> level</i>) –> <i>mask</i></tt><a name="node_idx_1140"></a></p>
<li><p></p>
<p class=noindent><tt>(syslog-mask?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_1142"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Make-syslog-mask</tt> constructs a mask from a list of levels.
<tt>Syslog-mask</tt> is a macro which constructs a mask from names of
levels. <tt>Syslog-mask-all</tt> is a predefined log mask containing
all levels. <tt>Syslog-mask-upto</tt> returns a mask consisting of all
levels up to and including a certain level, starting with
<tt>emergency</tt>.</p>
<p>
</p>
<a name="node_sec_Temp_28"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_Temp_28">Logging</a></h3>
<p>Scheme 48 dynamically maintains implicit connections to the syslog
facility specifying a current identifier, current options, a current
facility and a current log mask. Every thread
maintains it own implicit connection to syslog. Note that the
connection is not implicitly preserved across a <tt>spawn</tt>.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(with-syslog-destination<i> string options facility mask thunk</i>) –> <i>value</i></tt><a name="node_idx_1144"></a></p>
</ul><p>
</p>
<p class=noindent><tt>With-syslog-destination</tt> dynamically binds parameters of the
implicit connection to the syslog facility and runs <i>thunk</i>
within those parameter bindings, returning what <i>thunk</i>
returns. Each of the parameters may be <tt>#f</tt> in which case the
previous values will be used.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(syslog<i> level message</i>)</tt><a name="node_idx_1146"></a></p>
<li><p></p>
<p class=noindent><tt>(syslog<i> level message string</i>)</tt><a name="node_idx_1148"></a></p>
<li><p></p>
<p class=noindent><tt>(syslog<i> level message string options</i>)</tt><a name="node_idx_1150"></a></p>
<li><p></p>
<p class=noindent><tt>(syslog<i> level message string options syslog-facility</i>)</tt><a name="node_idx_1152"></a></p>
<li><p></p>
<p class=noindent><tt>(syslog<i> level message channel</i>)</tt><a name="node_idx_1154"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Syslog</tt> actually logs a message. Each of the parameters of the
implicit connection (except for the log mask) can be explicitly
specified as well for the current call to <tt>syslog</tt>, overriding
the parameters of the channel. The parameters revert to their
original values after the call.</p>
<p>
The final form specifies the destination of the log message as a
channel; see the next section.</p>
<p>
</p>
<a name="node_sec_Temp_29"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_Temp_29">Syslog channels</a></h3>
<p>These procedures allow direct manipulation of syslog channels, the
objects that represent connections to the syslog facility. Note that
it is not necessary to explicitly open a syslog channel to do logging.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(open-syslog-channel<i>string options facility mask</i>) –> <i>channel</i></tt><a name="node_idx_1156"></a></p>
<li><p></p>
<p class=noindent><tt>(close-syslog-channel<i>channel</i>)</tt><a name="node_idx_1158"></a></p>
<li><p></p>
<p class=noindent><tt>(with-syslog-destination<i> channel thunk</i>) –> <i>value</i></tt><a name="node_idx_1160"></a></p>
</ul><p>
</p>
<p class=noindent><tt>Open-syslog-channel</tt> and <tt>close-syslog-channel</tt> create and
destroy a connection to the syslog facility, respectively. The
specified form of calling <tt>syslog</tt> logs to the specified channel.</p>
<p>
<tt>With-syslog-channel</tt> dynamically binds parameters of the
implicit connection to the syslog facility to those specified in
<i>channel</i> and runs <i>thunk</i> within those parameter bindings,
returning what <i>thunk</i> returns.</p>
<p>
</p>
<a name="node_sec_9.11"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.11">9.11 Error codes</a></h2>
<p>POSIX functions report the nature of an error via <i>system error
numbers</i>—OS-specific integers that encode a variety of different
error situations. At the Scheme level, error numbers are represented
as <i>errnos</i>, objects that specify a name for the error
sitation. Errnos are definted in the structures <tt>posix-errnos</tt>
and <tt>posix</tt>.</p>
<p>
Currently, the system reports such error situations by raising
exceptions with condition type <tt>&os-error</tt>. The
<tt>&os-error</tt> condition type has a field <tt>code</tt> that contains
the system error number.</p>
<p>
There are two varieties of errnos available, <em>named</em> and <em>anonymous</em>.
A named errno is one for which we have a symbolic name, such as <tt>fault</tt>
or <tt>intr</tt>.
Anonymous errnos, for which we only have the current operating system's
errno number, have no meaning in other operating systems.
Named errnos preserve their meaning in image files.
Not all named errnos are available from all OS's and
there may be multiple names for a single OS errno number.</p>
<p>
</p>
<ul>
<li><p></p>
<p class=noindent><tt>(errno <i>errno-name</i>) –> <i>errno</i></tt> (syntax)
</p>
<li><p></p>
<p class=noindent><tt>(name->errno<i> symbol</i>) –> <i>errno or <tt>#f</tt></i></tt><a name="node_idx_1162"></a></p>
<li><p></p>
<p class=noindent><tt>(integer->errno<i> integer</i>) –> <i>errno</i></tt><a name="node_idx_1164"></a></p>
<li><p></p>
<p class=noindent><tt>(errno?<i> x</i>) –> <i>boolean</i></tt><a name="node_idx_1166"></a></p>
<li><p></p>
<p class=noindent><tt>(errno-name<i> errno</i>) –> <i>symbol or <tt>#f</tt></i></tt><a name="node_idx_1168"></a></p>
<li><p></p>
<p class=noindent><tt>(errno-os-number<i> errno</i>) –> <i>integer</i></tt><a name="node_idx_1170"></a></p>
<li><p></p>
<p class=noindent><tt>(errno=?<i> errno0 errno1</i>) –> <i>boolean</i></tt><a name="node_idx_1172"></a></p>
</ul><p>
</p>
<p class=noindent>The syntax <tt>errno</tt> returns a (named) errno associated with
<i>errno-name</i>.
<tt>Name->errno</tt> returns a (named) errno or <tt>#f</tt> if the
the errno <i>name</i> is not supported by the operating system.
The errno returned by <tt>integer->errno</tt> is a named errno if
<i>integer</i> corresponds to a named errno in the current operating
system; otherwise it returns an anonymous errno.
<tt>Errno-name</tt> returns a symbol if <i>errno</i> is named and
<tt>#f</tt> if it is anonymous.
<tt>Errno=?</tt> returns <tt>#t</tt> if <i>errno0</i> and <i>errno1</i>
have the same operating system number and <tt>#f</tt> if they do not.</p>
<p>
</p>
<a name="node_sec_9.11.1"></a>
<h3 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.11.1">9.11.1 POSIX errnos</a></h3>
<p>The following lists the names of the POSIX errnos.
</p>
<div align=center><table><tr><td>
@<tt></tt>lp0.6
toobig Argument list too long.<br>
acces Permission denied.<br>
addrinuse Address in use.<br>
addrnotavail Address not available.<br>
afnosupport Address family not supported.<br>
again Resource unavailable, try again.<br>
already Connection already in progress.<br>
badf Bad file descriptor.<br>
badmsg Bad message.<br>
busy Device or resource busy.<br>
canceled Operation canceled.<br>
child No child processes.<br>
connaborted Connection aborted.<br>
connrefused Connection refused.<br>
connreset Connection reset.<br>
deadlk Resource deadlock would occur.<br>
destaddrreq Destination address required.<br>
dom Mathematics argument out of domain of function.<br>
dquot Reserved.<br>
exist File exists.<br>
fault Bad address.<br>
fbig File too large.<br>
hostunreach Host is unreachable.<br>
idrm Identifier removed.<br>
ilseq Illegal byte sequence.<br>
inprogress Operation in progress.<br>
intr Interrupted function.<br>
inval Invalid argument.<br>
io I/O error.<br>
isconn Socket is connected.<br>
isdir Is a directory.<br>
loop Too many levels of symbolic links.<br>
mfile Too many open files.<br>
mlink Too many links.<br>
msgsize Message too large.<br>
multihop Reserved.<br>
nametoolong Filename too long.<br>
netdown Network is down.<br>
netreset Connection aborted by network.<br>
netunreach Network unreachable.<br>
nfile Too many files open in system.<br>
nobufs No buffer space available.<br>
nodata No message is available on the STREAM head read queue. <br>
nodev No such device.<br>
noent No such file or directory.<br>
noexec Executable file format error.<br>
nolck No locks available.<br>
nolink Reserved.<br>
nomem Not enough space.<br>
nomsg No message of the desired type.<br>
noprotoopt Protocol not available.<br>
nospc No space left on device.<br>
nosr No STREAM resources. <br>
nostr Not a STREAM. <br>
nosys Function not supported.<br>
notconn The socket is not connected.<br>
notdir Not a directory.<br>
notempty Directory not empty.<br>
notsock Not a socket.<br>
notsup Not supported.<br>
notty Inappropriate I/O control operation.<br>
nxio No such device or address.<br>
opnotsupp Operation not supported on socket.<br>
overflow Value too large to be stored in data type.<br>
perm Operation not permitted.<br>
pipe Broken pipe.<br>
proto Protocol error.<br>
protonosupport Protocol not supported.<br>
prototype Protocol wrong type for socket.<br>
range Result too large.<br>
rofs Read-only file system.<br>
spipe Invalid seek.<br>
srch No such process.<br>
stale Reserved.<br>
time Stream ioctl() timeout. <br>
timedout Connection timed out.<br>
txtbsy Text file busy.<br>
wouldblock Operation would block.<br>
xdev Cross-device link.<br>
</td></tr></table></div>
<p>
</p>
<a name="node_sec_9.12"></a>
<h2 class=section><a href="manual-Z-H-1.html#node_toc_node_sec_9.12">9.12 C to Scheme correspondence</a></h2>
<p></p>
<p>
The following table lists the Scheme procedures that correspond to
particular C procedures.
Not all of the Scheme procedures listed are part of the POSIX interface.</p>
<p>
</p>
<table border=0><tr><td valign=top >C procedure </td><td valign=top >Scheme procedure(s) </td></tr>
<tr><td valign=top >C procedure </td><td valign=top >Scheme procedure(s) </td></tr>
<tr><td valign=top ><tt>access</tt></td><td valign=top ><tt>accessible?</tt></td></tr>
<tr><td valign=top ><tt>asctime</tt></td><td valign=top ><tt>date->string</tt></td></tr>
<tr><td valign=top ><tt>chdir</tt></td><td valign=top ><tt>set-working-directory!</tt></td></tr>
<tr><td valign=top ><tt>close</tt></td><td valign=top ><tt>close-input-port, close-output-port,</tt></td></tr>
<tr><td valign=top ></td><td valign=top ><tt> close-channel, close-socket</tt></td></tr>
<tr><td valign=top ><tt>closedir</tt></td><td valign=top ><tt>close-directory-stream</tt></td></tr>
<tr><td valign=top ><tt>creat</tt></td><td valign=top ><tt>open-file</tt></td></tr>
<tr><td valign=top ><tt>ctime</tt></td><td valign=top ><tt>time->string</tt></td></tr>
<tr><td valign=top ><tt>dup</tt></td><td valign=top ><tt>dup, dup-switching-mode</tt></td></tr>
<tr><td valign=top ><tt>dup2</tt></td><td valign=top ><tt>dup2</tt></td></tr>
<tr><td valign=top ><tt>exec[l|v][e|p|ε]</tt>
</td><td valign=top ><tt>exec, exec-with-environment,</tt> </td></tr>
<tr><td valign=top ></td><td valign=top ><tt> exec-file, exec-file-with-environment,</tt> </td></tr>
<tr><td valign=top ></td><td valign=top ><tt> exec-with-alias</tt></td></tr>
<tr><td valign=top ><tt>_exit</tt></td><td valign=top ><tt>exit</tt></td></tr>
<tr><td valign=top ><tt>fcntl</tt></td><td valign=top ><tt>io-flags, set-io-flags!,</tt></td></tr>
<tr><td valign=top ></td><td valign=top ><tt> close-on-exec, set-close-on-exec!</tt></td></tr>
<tr><td valign=top ><tt>fork</tt></td><td valign=top ><tt>fork, fork-and-forget</tt></td></tr>
<tr><td valign=top ><tt>fstat</tt></td><td valign=top ><tt>get-port-info</tt></td></tr>
<tr><td valign=top ><tt>getcwd</tt></td><td valign=top ><tt>working-directory</tt></td></tr>
<tr><td valign=top ><tt>getegid</tt></td><td valign=top ><tt>get-effective-group-id</tt></td></tr>
<tr><td valign=top ><tt>getenv</tt></td><td valign=top ><tt>lookup-environment-variable,</tt> </td></tr>
<tr><td valign=top ></td><td valign=top ><tt> environment-alist</tt></td></tr>
<tr><td valign=top ><tt>geteuid</tt></td><td valign=top ><tt>get-effective-user-id</tt></td></tr>
<tr><td valign=top ><tt>getgid</tt></td><td valign=top ><tt>get-group-id</tt></td></tr>
<tr><td valign=top ><tt>getgroups</tt></td><td valign=top ><tt>get-groups</tt></td></tr>
<tr><td valign=top ><tt>getlogin</tt></td><td valign=top ><tt>get-login-name</tt></td></tr>
<tr><td valign=top ><tt>getpid</tt></td><td valign=top ><tt>get-process-id</tt></td></tr>
<tr><td valign=top ><tt>getppid</tt></td><td valign=top ><tt>get-parent-process-id</tt></td></tr>
<tr><td valign=top ><tt>getuid</tt></td><td valign=top ><tt>get-user-id</tt></td></tr>
<tr><td valign=top ><tt>gmtime</tt></td><td valign=top ><tt>time->local-date</tt></td></tr>
<tr><td valign=top ><tt>isatty</tt></td><td valign=top ><tt>port-is-a-terminal?</tt></td></tr>
<tr><td valign=top ><tt>link</tt></td><td valign=top ><tt>link</tt></td></tr>
<tr><td valign=top ><tt>localtime</tt></td><td valign=top ><tt>time->utc-date</tt></td></tr>
<tr><td valign=top ><tt>lstat</tt></td><td valign=top ><tt>get-file/link-info</tt></td></tr>
<tr><td valign=top ><tt>mkdir</tt></td><td valign=top ><tt>make-directory</tt></td></tr>
<tr><td valign=top ><tt>mkfifo</tt></td><td valign=top ><tt>make-fifo</tt></td></tr>
<tr><td valign=top ><tt>mktime</tt></td><td valign=top ><tt>date->time</tt></td></tr>
<tr><td valign=top ><tt>open</tt></td><td valign=top ><tt>open-file</tt></td></tr>
<tr><td valign=top ><tt>opendir</tt></td><td valign=top ><tt>open-directory-stream</tt></td></tr>
<tr><td valign=top ><tt>pipe</tt></td><td valign=top ><tt>open-pipe</tt></td></tr>
<tr><td valign=top ><tt>read</tt></td><td valign=top ><tt>read-char, read-block</tt></td></tr>
<tr><td valign=top ><tt>readdir</tt></td><td valign=top ><tt>read-directory-stream</tt></td></tr>
<tr><td valign=top ><tt>readlink</tt></td><td valign=top ><tt>read-symbolic-link</tt></td></tr>
<tr><td valign=top ><tt>rename</tt></td><td valign=top ><tt>rename</tt></td></tr>
<tr><td valign=top ><tt>rmdir</tt></td><td valign=top ><tt>remove-directory</tt></td></tr>
<tr><td valign=top ><tt>setgid</tt></td><td valign=top ><tt>set-group-id!</tt></td></tr>
<tr><td valign=top ><tt>setegid</tt></td><td valign=top ><tt>set-effective-group-id!</tt></td></tr>
<tr><td valign=top ><tt>setuid</tt></td><td valign=top ><tt>set-user-id!</tt></td></tr>
<tr><td valign=top ><tt>seteuid</tt></td><td valign=top ><tt>set-effective-user-id!</tt></td></tr>
<tr><td valign=top ><tt>stat</tt></td><td valign=top ><tt>get-file-info</tt></td></tr>
<tr><td valign=top ><tt>strftime</tt></td><td valign=top ><tt>format-date</tt></td></tr>
<tr><td valign=top ><tt>symlink</tt></td><td valign=top ><tt>create-symbolic-link</tt></td></tr>
<tr><td valign=top ><tt>syslog</tt></td><td valign=top ><tt>syslog</tt></td></tr>
<tr><td valign=top ><tt>time</tt></td><td valign=top ><tt>current-time</tt></td></tr>
<tr><td valign=top ><tt>ttyname</tt></td><td valign=top ><tt>port-terminal-name</tt></td></tr>
<tr><td valign=top ><tt>umask</tt></td><td valign=top ><tt>set-file-creation-mask!</tt></td></tr>
<tr><td valign=top ><tt>uname</tt></td><td valign=top ><tt>os-name, os-node-name,</tt> </td></tr>
<tr><td valign=top ></td><td valign=top ><tt> os-release-name, os-version-name,</tt> </td></tr>
<tr><td valign=top ></td><td valign=top ><tt> machine-name</tt></td></tr>
<tr><td valign=top ><tt>unlink</tt></td><td valign=top ><tt>unlink</tt></td></tr>
<tr><td valign=top ><tt>waitpid</tt></td><td valign=top ><tt>wait-for-child-process</tt></td></tr>
<tr><td valign=top ><tt>write</tt></td><td valign=top ><tt>write-char, write-block</tt></td></tr>
<tr><td valign=top ></td></tr></table><p>
</p>
<p>
</p>
<p>
</p>
<div class=smallskip></div>
<p style="margin-top: 0pt; margin-bottom: 0pt">
<div align=right class=navigation>[Go to <span><a href="manual.html">first</a>, <a href="manual-Z-H-9.html">previous</a></span><span>, <a href="manual-Z-H-11.html">next</a></span> page<span>; </span><span><a href="manual-Z-H-1.html#node_toc_start">contents</a></span><span><span>; </span><a href="manual-Z-H-11.html#node_index_start">index</a></span>]</div>
</p>
<p></p>
</div>
</body>
</html>
|