diff --git a/doc/scsh-manual/.gitignore b/doc/scsh-manual/.gitignore new file mode 100644 index 0000000..e63d696 --- /dev/null +++ b/doc/scsh-manual/.gitignore @@ -0,0 +1,4 @@ +*.aux *.log +*.idx *.ilg *.ind *.dvi +.,* +*.toc diff --git a/doc/scsh-manual/Makefile b/doc/scsh-manual/Makefile new file mode 100644 index 0000000..dafaa3c --- /dev/null +++ b/doc/scsh-manual/Makefile @@ -0,0 +1,37 @@ +.SUFFIXES: .idx .ind .tex .dvi .ps $(.SUFFIXES) + +TEX= front.tex intro.tex procnotation.tex syscalls.tex network.tex \ + strings.tex awk.tex miscprocs.tex running.tex todo.tex + + +man.dvi: $(TEX) man.ind +man.ind: man.idx + +.dvi.ps: + dvips -o $@ $< + +.tex.dvi: + latex $< + rm $*.log + +.idx.ind: + makeindex $< + +clean: + -rm *.log + +INSTALL_DATA= install -c -m 644 + +tar: + tar cf - *.tex sty | gzip > man.tar.gz + + +install: man.ps + @echo WARNING: + @echo WARNING: this depends on /u/su/scsh/scsh + @echo WARNING: pointing to the current release + @echo WARNING: + $(INSTALL_DATA) cheat.txt /u/su/scsh/scsh/doc/ + $(INSTALL_DATA) man.ps /u/su/scsh/scsh/doc/scsh-manual.ps + $(INSTALL_DATA) $(TEX) /u/su/scsh/scsh/doc/scsh-manual/ + $(INSTALL_DATA) sty/* /u/su/scsh/scsh/doc/scsh-manual/sty/ diff --git a/doc/scsh-manual/THANKS b/doc/scsh-manual/THANKS new file mode 100644 index 0000000..8769f0d --- /dev/null +++ b/doc/scsh-manual/THANKS @@ -0,0 +1,26 @@ +Michel.Schinz@studi.epfl.ch + Documentation error in STRING-OUTPUT-PORT-OUTPUT. + Reported 12/19. + +Victor Zandy + character-gobbling in (record-reader) caused by 'trim / 'peek + default misunderstanding in delimited readers. Fixed 4/5/96 + +Michael Becker + reap-policy = early can still lose if you loop and fork. + fork now reaps & retries if it loses and the policy is early reap. + This is a kludge until I have sigchld handlers. + Fixed 4/5/96 + +Tod Olson + Reported painfully slow delimited-reader I/O in November. + +Michel.Schinz@studi.epfl.ch + Reported some picky little typos in the manual. + +Shriram + Doc bugs in defrec.scm + +euler@lavielle.COM (Lutz Euler) 2/24/97 + Manual bugs and a bug in stdio->stdports. + diff --git a/doc/scsh-manual/ack.txt b/doc/scsh-manual/ack.txt new file mode 100644 index 0000000..a4cf870 --- /dev/null +++ b/doc/scsh-manual/ack.txt @@ -0,0 +1,32 @@ +Acknowledgements + +Who should I thank? My so-called "colleagues," who laugh at me behind my +back, all the while becoming famous on *my* work? My worthless graduate +students, whose computer skills appear to be limited to downloading bitmaps +off of netnews? My parents, who are still waiting for me to quit "fooling +around with computers," go to med school, and become a radiologist? My +department chairman, a manager who gives one new insight into and sympathy for +disgruntled postal workers? + +My God, no one could blame me--no one!--if I went off the edge and just lost +it completely one day. I couldn't get through the day as it is without the +Prozac and Jack Daniels I keep on the shelf, behind my Tops-20 JSYS manuals. +I start getting the shakes real bad around 10am, right before my advisor +meetings. A 10 oz. Jack 'n Zac helps me get through the meetings without one +of my students winding up with his severed head in a bowling-ball bag. They +look at me funny; they think I twitch a lot. I'm not twitching. I'm +controlling my impulse to snag my 9mm Sig-Sauer out from my day-pack and make +a few strong points about the quality of undergraduate education in Amerika. + +If I thought anyone cared, if I thought anyone would even be reading this, I'd +probably make an effort to keep up appearances until the last possible +moment. But no one does, and no one will. So I can pretty much say exactly +what I think. + +Oh, yes, the *acknowledgements.* I think not. I did it. I did it all, +by myself. + +Olin Shivers +Cambridge +September 4, 1994 + diff --git a/doc/scsh-manual/man.ps b/doc/scsh-manual/man.ps new file mode 100644 index 0000000..c3138b4 --- /dev/null +++ b/doc/scsh-manual/man.ps @@ -0,0 +1,9812 @@ +%!PS-Adobe-2.0 +%%Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software +%%Title: man.dvi +%%Pages: 167 +%%PageOrder: Ascend +%%BoundingBox: 0 0 612 792 +%%DocumentFonts: Palatino-Bold Palatino-Roman Palatino-Italic +%%EndComments +%DVIPSCommandLine: dvips -o man.ps man.dvi +%DVIPSParameters: dpi=600, compressed, comments removed +%DVIPSSource: TeX output 1997.04.08:1742 +%%BeginProcSet: texc.pro +/TeXDict 250 dict def TeXDict begin /N{def}def /B{bind def}N /S{exch}N +/X{S N}B /TR{translate}N /isls false N /vsize 11 72 mul N /hsize 8.5 72 +mul N /landplus90{false}def /@rigin{isls{[0 landplus90{1 -1}{-1 1} +ifelse 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale +isls{landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div +hsize mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul +TR[matrix currentmatrix{dup dup round sub abs 0.00001 lt{round}if} +forall round exch round exch]setmatrix}N /@landscape{/isls true N}B +/@manualfeed{statusdict /manualfeed true put}B /@copies{/#copies X}B +/FMat[1 0 0 -1 0 0]N /FBB[0 0 0 0]N /nn 0 N /IE 0 N /ctr 0 N /df-tail{ +/nn 8 dict N nn begin /FontType 3 N /FontMatrix fntrx N /FontBBox FBB N +string /base X array /BitMaps X /BuildChar{CharBuilder}N /Encoding IE N +end dup{/foo setfont}2 array copy cvx N load 0 nn put /ctr 0 N[}B /df{ +/sf 1 N /fntrx FMat N df-tail}B /dfs{div /sf X /fntrx[sf 0 0 sf neg 0 0] +N df-tail}B /E{pop nn dup definefont setfont}B /ch-width{ch-data dup +length 5 sub get}B /ch-height{ch-data dup length 4 sub get}B /ch-xoff{ +128 ch-data dup length 3 sub get sub}B /ch-yoff{ch-data dup length 2 sub +get 127 sub}B /ch-dx{ch-data dup length 1 sub get}B /ch-image{ch-data +dup type /stringtype ne{ctr get /ctr ctr 1 add N}if}B /id 0 N /rw 0 N +/rc 0 N /gp 0 N /cp 0 N /G 0 N /sf 0 N /CharBuilder{save 3 1 roll S dup +/base get 2 index get S /BitMaps get S get /ch-data X pop /ctr 0 N ch-dx +0 ch-xoff ch-yoff ch-height sub ch-xoff ch-width add ch-yoff +setcachedevice ch-width ch-height true[1 0 0 -1 -.1 ch-xoff sub ch-yoff +.1 sub]/id ch-image N /rw ch-width 7 add 8 idiv string N /rc 0 N /gp 0 N +/cp 0 N{rc 0 ne{rc 1 sub /rc X rw}{G}ifelse}imagemask restore}B /G{{id +gp get /gp gp 1 add N dup 18 mod S 18 idiv pl S get exec}loop}B /adv{cp +add /cp X}B /chg{rw cp id gp 4 index getinterval putinterval dup gp add +/gp X adv}B /nd{/cp 0 N rw exit}B /lsh{rw cp 2 copy get dup 0 eq{pop 1}{ +dup 255 eq{pop 254}{dup dup add 255 and S 1 and or}ifelse}ifelse put 1 +adv}B /rsh{rw cp 2 copy get dup 0 eq{pop 128}{dup 255 eq{pop 127}{dup 2 +idiv S 128 and or}ifelse}ifelse put 1 adv}B /clr{rw cp 2 index string +putinterval adv}B /set{rw cp fillstr 0 4 index getinterval putinterval +adv}B /fillstr 18 string 0 1 17{2 copy 255 put pop}for N /pl[{adv 1 chg} +{adv 1 chg nd}{1 add chg}{1 add chg nd}{adv lsh}{adv lsh nd}{adv rsh}{ +adv rsh nd}{1 add adv}{/rc X nd}{1 add set}{1 add clr}{adv 2 chg}{adv 2 +chg nd}{pop nd}]dup{bind pop}forall N /D{/cc X dup type /stringtype ne{] +}if nn /base get cc ctr put nn /BitMaps get S ctr S sf 1 ne{dup dup +length 1 sub dup 2 index S get sf div put}if put /ctr ctr 1 add N}B /I{ +cc 1 add D}B /bop{userdict /bop-hook known{bop-hook}if /SI save N @rigin +0 0 moveto /V matrix currentmatrix dup 1 get dup mul exch 0 get dup mul +add .99 lt{/QV}{/RV}ifelse load def pop pop}N /eop{SI restore userdict +/eop-hook known{eop-hook}if showpage}N /@start{userdict /start-hook +known{start-hook}if pop /VResolution X /Resolution X 1000 div /DVImag X +/IE 256 array N 0 1 255{IE S 1 string dup 0 3 index put cvn put}for +65781.76 div /vsize X 65781.76 div /hsize X}N /p{show}N /RMat[1 0 0 -1 0 +0]N /BDot 260 string N /rulex 0 N /ruley 0 N /v{/ruley X /rulex X V}B /V +{}B /RV statusdict begin /product where{pop product dup length 7 ge{0 7 +getinterval dup(Display)eq exch 0 4 getinterval(NeXT)eq or}{pop false} +ifelse}{false}ifelse end{{gsave TR -.1 .1 TR 1 1 scale rulex ruley false +RMat{BDot}imagemask grestore}}{{gsave TR -.1 .1 TR rulex ruley scale 1 1 +false RMat{BDot}imagemask grestore}}ifelse B /QV{gsave newpath transform +round exch round exch itransform moveto rulex 0 rlineto 0 ruley neg +rlineto rulex neg 0 rlineto fill grestore}B /a{moveto}B /delta 0 N /tail +{dup /delta X 0 rmoveto}B /M{S p delta add tail}B /b{S p tail}B /c{-4 M} +B /d{-3 M}B /e{-2 M}B /f{-1 M}B /g{0 M}B /h{1 M}B /i{2 M}B /j{3 M}B /k{ +4 M}B /w{0 rmoveto}B /l{p -4 w}B /m{p -3 w}B /n{p -2 w}B /o{p -1 w}B /q{ +p 1 w}B /r{p 2 w}B /s{p 3 w}B /t{p 4 w}B /x{0 S rmoveto}B /y{3 2 roll p +a}B /bos{/SS save N}B /eos{SS restore}B end +%%EndProcSet +%%BeginFont: Palatino-Bold +% @psencodingfile{ +% author = "P. MacKay, Alan Jeffrey, S. Rahtz, K. Berry, B. Horn", +% version = "0.2", +% date = "7 September 94", +% filename = "8r.enc", +% email = "kb@cs.umb.edu", +% address = "135 Center Hill Rd. // Plymouth, MA 02360", +% codetable = "ISO/ASCII", +% checksum = "xx", +% docstring = "Encoding for TrueType or Type 1 fonts to be used with TeX." +% } +% +% Idea is to have all the characters normally included in Type 1 fonts +% available for typesetting. This is effectively the characters in Adobe +% Standard Encoding + ISO Latin 1 + extra characters from Lucida. +% +% Character code assignments were made as follows: +% +% (1) the Windows ANSI characters are in their Windows ANSI positions, +% because Windows users cannot easily reencode the fonts, and it makes +% no difference on other systems. The only Windows ANSI characters not +% available are those that make no sense for typesetting -- rubout +% (127 decimal), nobreakspace (160), softhyphen (173). +% +% (2) The caron and dotlessi characters are in the positions used by +% Y&Y for their modified ATM encoding. +% +% (3) Remaining characters are assigned arbitrarily to the first few +% positions. +% +% (4) (Y&Y) Lucida Bright includes some extra text characters; in the +% hopes that other PostScript fonts, perhaps created for public +% consumption, will include them, they are included starting at 0x10. +% +% (5) Remaining positions left undefined are for use in (hopefully) +% upward-compatible revisions, if someday more characters are generally +% available in the Type 1 fonts. +% +% Ligatures are omitted, since this encoding is intended for use at the +% driver end. Including ligatures and kerns would make the TFM files +% much larger, to no particular purpose. If someone actually wants to +% typeset in this encoding, they can pick a different name, and regenerate +% the fonts. + +/TeXBase1Encoding [ +% 0x00 (encoded characters from Adobe Standard not in Windows 3.1) + /breve /dotaccent /fi /fl + /fraction /hungarumlaut /Lslash /lslash + /ogonek /ring /tilde /minus + % These are the only two remaining unencoded characters, so may as + % well include them. + /Zcaron /zcaron /.notdef /.notdef +% 0x10 (TeX characters from, e.g., Lucida Bright) + /dotlessj /ff /ffi /ffl /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% 0x20 (ASCII begins) + /space /exclam /quotedbl /numbersign + /dollar /percent /ampersand /quotesingle + /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% 0x30 + /zero /one /two /three /four /five /six /seven + /eight /nine /colon /semicolon /less /equal /greater /question +% 0x40 + /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O +% 0x50 + /P /Q /R /S /T /U /V /W + /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +% 0x60 + /grave /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o +% 0x70 + /p /q /r /s /t /u /v /w + /x /y /z /braceleft /bar /braceright /asciitilde + /.notdef % rubout; ASCII ends +% 0x80 + /.notdef /.notdef /quotesinglbase /florin + /quotedblbase /ellipsis /dagger /daggerdbl + /circumflex /perthousand /Scaron /guilsinglleft + /OE + /caron % Y&Y + /.notdef + /.notdef +% 0x90 + /.notdef /quoteleft /quoteright /quotedblleft + /quotedblright /bullet /endash /emdash + /tildeaccent /trademark /scaron /guilsinglright + /oe + /dotlessi % Y&Y + /.notdef + /Ydieresis +% 0xA0 + /.notdef % nobreakspace + /exclamdown /cent /sterling + /currency /yen /brokenbar /section + /dieresis /copyright /ordfeminine /guillemotleft + /logicalnot + /hyphen % Y&Y (also at 45); Windows' softhyphen + /registered + /macron +% 0xD0 + /degree /plusminus /twosuperior /threesuperior + /acute /mu /paragraph /periodcentered + /cedilla /onesuperior /ordmasculine /guillemotright + /onequarter /onehalf /threequarters /questiondown +% 0xC0 + /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla + /Egrave /Eacute /Ecircumflex /Edieresis + /Igrave /Iacute /Icircumflex /Idieresis +% 0xD0 + /Eth /Ntilde /Ograve /Oacute + /Ocircumflex /Otilde /Odieresis /multiply + /Oslash /Ugrave /Uacute /Ucircumflex + /Udieresis /Yacute /Thorn /germandbls +% 0xE0 + /agrave /aacute /acircumflex /atilde + /adieresis /aring /ae /ccedilla + /egrave /eacute /ecircumflex /edieresis + /igrave /iacute /icircumflex /idieresis +% 0xF0 + /eth /ntilde /ograve /oacute + /ocircumflex /otilde /odieresis /divide + /oslash /ugrave /uacute /ucircumflex + /udieresis /yacute /thorn /ydieresis +] def +%%EndFont +%%BeginProcSet: texps.pro +TeXDict begin /rf{findfont dup length 1 add dict begin{1 index /FID ne 2 +index /UniqueID ne and{def}{pop pop}ifelse}forall[1 index 0 6 -1 roll +exec 0 exch 5 -1 roll VResolution Resolution div mul neg 0 0]/Metrics +exch def dict begin Encoding{exch dup type /integertype ne{pop pop 1 sub +dup 0 le{pop}{[}ifelse}{FontMatrix 0 get div Metrics 0 get div def} +ifelse}forall Metrics /Metrics currentdict end def[2 index currentdict +end definefont 3 -1 roll makefont /setfont load]cvx def}def +/ObliqueSlant{dup sin S cos div neg}B /SlantFont{4 index mul add}def +/ExtendFont{3 -1 roll mul exch}def /ReEncodeFont{/Encoding exch def}def +end +%%EndProcSet +TeXDict begin 40258431 52099146 1000 600 600 (man.dvi) +@start /Fa 190[45 65[{TeXBase1Encoding ReEncodeFont}1 +58.333334 /Palatino-Roman rf /Fb 1 42 df<17F0A283177C173C173E83A2717E71 +7E717E007FB87EB97E846C17FFCBEA1F80F00FE0F003F0F001FE9538007F80F11FF0A2F1 +7F80953801FE00F003F0F00FE0F01F80007FB9C7FCB912FC606C5FCAEA03E04D5A4D5A4D +C8FCA2173E173C177C5F5FA2442A7CA74D>41 D E /Fc 1 62 df<007FB812C0B912E0A2 +6C17C0CCFCAC007FB812C0B912E0A26C17C033147C9C3C>61 D E +/Fd 1 16 df15 D E +/Fe 1 22 df<137CEB7F80EB1FE0130F6D7EA26D7EA36D7EA36D7EA28080A26E7EA36E7E +A281140FA26E7EA381140F141FEC3DFC1479ECF8FEEB01F0EB03E0903807C07FEB0F80EB +1F00013EEB3F80137E4914C04848131F485A4848EB0FE0EA1FC0123F4848EB07F048C7FC +4815F848140348EC01FC48140026357CB32D>21 D E /Ff 2 99 +df<131FEBFF8C3801E0DE3803807E3807007C48133C121E123E003C5B127CA3485BA215 +401560903801E0C012781303393807E180391C1CF300380FF87F3807E03C1B177E9522> +97 DI E /Fg 167[40 4[31 3[47 5[20 73[{ +TeXBase1Encoding ReEncodeFont}4 59.999974 /Palatino-Roman +rf /Fh 85 126 df<123C127E12FFAF127EAE123C1200A7123C127E12FFA4127E123C08 +2F71AE27>33 D<00101320007C13F838FE01FCAAEAFC00007C13F8A900381370161778AE +27>I<90383C03C090387E07E0A7EBFE0F01FC13C0A2003FB512FC4814FEB7FCA36C14FE +3901F81F80AC007FB512FEB7FCA36C14FE6C14FC3903F03F00A200075BEBE07EA73803C0 +3C202E7DAD27>II<131FEB7FC0497E +5A80EA03F1EBE1F8EA07E013C0A513C15C9039C3F1FF80D9E3E113C03803E7E3EBEFC101 +FF1480913881F800EC01F0EA01FEEBFC0301F85B00031307D807FC5B120F381FFE0FD83F +BE5BEB3F1FD87E1F90C7FC149F38FC0FBF14FE1307ECFC020103EB0F80EB01F8A238FE03 +FC387E07FE397F1FFF9F6CB61200149F6CEB0FFE390FFC03FC3903F000F822307EAE27> +38 D40 D<127012F812FE7E6C7E6C7EEA0FE06C7E1203 +7F6C7E1200137EA27FA2EB1F80A3EB0FC0A4EB07E0ACEB0FC0A4EB1F80A3EB3F00A2137E +A25B1201485A5B1207485AEA3FC0485A48C7FC5A12F81270133A7AB327>I<130F497EA6 +0078EB81E000FEEB87F000FF138FEBDFBF6CB512E06C14C0000F1400000313FCC613F0A2 +000313FC000F13FF003F14C04814E039FFDFBFF0EB1F8F00FE13870078EB81E00000EB80 +00A66DC7FC1C207BA627>II<120FEA3FC013E0EA7FF0A213F8A2123FA2120F120113F01203EA07E0 +121FEA7FC0EAFF8013005A12700D14738927>I<007FB512F8B612FCA46C14F81E067C99 +27>I<121EEA7F80A2EAFFC0A4EA7F80A2EA1E000A0A728927>I<1538157C15FCA2140115 +F8140315F0140715E0140F15C0141F1580143F1500A25C147E14FE5C13015C13035C1307 +5C130F5CA2131F5C133F91C7FC5B137E13FE5B12015B12035BA212075B120F5B121F5B12 +3F90C8FC5A127E12FE5AA25A12781E3A7CB327>II<130E131FA2 +5B5BA25B5A5A127FB5FCA213BFEA7E3F1200B3AA003FB512805A15C01580A21A2F79AE27 +>IIII<001FB512E04814F0A315E090C8FCACEB1FF0EBFFFC14FF158015C09038F03FE09038 +C00FF0EB0007003EEB03F8001C1301C7FC15FC1400A3127C12FEA2140115F84813036C14 +F0007F130F9038801FE0393FE07FC06CB512806C14006C5B000113F838007FC01E2F7CAD +27>I<14FF010713C0011F13F04913F890B5FC48EB81FC3803FE0113F8EA07F0EA0FE090 +38C000F8001F1400485A90C8FCA25A127EEB0FF838FE3FFE48B51280B612C015E09038F8 +0FF09038E007F890388001FC90C7FC15FE48147E157F153FA3127EA3127F6C147F157E6C +6C13FE9038C001FC120F9038F007F83907F81FF06CB512E06C14C06C148090383FFE00EB +0FF820307DAE27>I<1278B612FE15FFA315FE39FC0001FCEC03F8EC07F0007814E0C712 +0FEC1FC01580143FEC7F00147E14FE5C13015C13035C13075CA2495AA3495AA3133F91C7 +FCA55B137EA9133C20307DAE27>III<121EEA7F80A2EAFFC0A4EA7F +80A2EA1E00C7FCAC121EEA7F80A2EAFFC0A4EA7F80A2EA1E000A20729F27>I<120FEA3F +C0A2EA7FE0A4EA3FC0A2EA0F00C7FCAC120FEA3F8013C0127F13E0A3123FA2120F120713 +C0120FA2EA3F80EA7F005A5A12F812700B2A739F27>I<007FB512FEB7FCA4003F14FEC9 +FCA6003FB512FEB7FCA46C14FE20127D9F27>61 D<1230127812FE7E13C06C7EEA3FF8EA +0FFC6C7E3801FF806C7FEB3FF06D7EEB0FFEEB03FF6D13C09038007FE0EC3FF8EC0FFC14 +07A2140FEC3FF8EC7FE0903801FFC0491300EB0FFEEB1FF8495AEBFFC0485BD807FEC7FC +485AEA3FF8EA7FE0485A90C8FC5A127812301E287CAA27>IIII<007FB5FCB612C08115F87E3907E003FCEC00FE157E157F81A6157EA25D1403 +EC0FF890B55A15C015F081819038E000FE157FED3F80151FA2ED0FC0A6151F1680153FED +7F004A5A007FB55AB65A5D15E06C1480222E7FAD27>I<903803F80E90381FFE1F90383F +FFBF90B6FC5A3803FE0F3807F803497E48487E485A49137FA248C7123FA25A127E151E15 +0012FE5AAA7E127EA2151E007F143F7EA26C7E157F6D137E6C6C13FE3907F001FCEBF803 +3903FE0FF86CB512F06C14E0013F13C06D1300EB03F820307DAE27>I<387FFFFC14FFB6 +12C06C80813907E00FF81407EC01FC6E7EA2157E157F811680151FA316C0150FABED1F80 +A3153F1600A25D15FEA24A5A4A5A140F007FB55A5DB65A6C91C7FC14FC222E7FAD27>I< +007FB61280B712C0A37E3907E0000FA6ED078092C7FCA4EC07804A7EA390B5FCA5EBE00F +A36E5A91C8FCA4ED03C0ED07E0A7007FB6FCB7FCA36C15C0232E7FAD27>I<007FB61280 +B712C0A37E3907E0000FA6ED078092C7FCA4EC07804A7EA390B5FCA5EBE00FA36E5A91C8 +FCAC387FFF80B57EA36C5B222E7EAD27>I<903807F03890381FFC7C90387FFFFC90B5FC +5A3803FC1F3807F00F380FE007EBC003001F13011380123F90C7FCA2127EA2157892C7FC +5AA8EC1FFF4A1380A3007E6D1300EC00FCA36C1301A21380121FEBC003120FEBE0073807 +F00F3803FC1F6CB5FC7EEB7FFE90381FFC78D907F0C7FC21307DAE27>I<3A7FFE07FFE0 +B54813F0A36C486C13E03A07E0007E00AF90B512FEA59038E0007EB03A7FFE07FFE0B548 +13F0A36C486C13E0242E7FAD27>I<007FB512E0B612F0A36C14E039001F8000B3B2007F +B512E0B612F0A36C14E01C2E7BAD27>I<3A7FFC07FF8016C0486C5A6C487E16803A07C0 +01F80014035D4A5A4A5A141F5D4AC7FC147E14FE5CEBC1F8EBC3F013C75CEBCFF0EBDFF8 +13FF8013FEEBFC7E143EEBF83F497E01E07F140F01C07F1407811403816E7EA26E7E157C +157E3A7FFC01FFC016E0486C5A6C487E16C0232E7FAD27>75 D<387FFFC080B5FC7E5CD8 +03F0C8FCB3AAED0780ED0FC0A7007FB6FCA2B7FC7E1680222E7FAD27>II<3A7FF003FFE0486C4813F0A213FC007F6D13E000 +079038003E0013DEA313CFA3148013C714C0A213C314E0A213C114F0A3EBC0F8A3147814 +7CA2143C143EA2141E141F140FA3EC07BEA3EC03FEEA7FFCEAFFFE1401A26C486C5A242E +7FAD27>II<007FB5FCB612E081816C803907E003FEEC00FF81ED3F80 +151F16C0150FA6151F1680153FED7F005DEC03FE90B55A5D5D5D92C7FC01E0C8FCADEA7F +FEB5FCA36C5A222E7FAD27>I<387FFFF0B512FE6E7E816C803907E01FF014076E7E1401 +811400A514015D14034A5A141F90B55A5D5DA281EBE01F6E7E14076E7EA816F0EDF1F8A4 +397FFE01FBB5EBFFF08016E06C48EB7FC0C8EA1F00252F7FAD27>82 +D<90387FC0E03901FFF1F0000713FF5A5AEA3FE0EB801F387F000F007E130712FE5A1403 +A3EC01E06C90C7FC127E127FEA3FC013F86CB47E6C13F86C13FE6CEBFF80C614C0010F13 +E0010013F0140FEC07F81403140115FC1400127812FCA46CEB01F8A26C130390388007F0 +9038F01FE090B5FC15C0150000F85B38701FF81E307CAE27>I<007FB61280B712C0A439 +FC03F00FA60078EC0780000091C7FCB3AB90B512C04880A36C5C222E7EAD27>I<3A7FFE +01FFF8B54813FCA36C486C13F83A07E0001F80B3AB6D133F00031500A26D5B0001147E6D +13FE6C6C485A90387F87F814FF6D5B010F13C06D5BD901FEC7FC262F80AD27>I<3A7FFC +03FFE06D5A00FF15F0007F15E0497E3A07E0007E00A46C6C5BA4EBF80100015CA46C6C48 +5AA490387E07E0A56D485AA4011F5B149FA3010F90C7FCA5EB07FEA46D5AA26D5A242F7F +AD27>II<393FFC1FFE387FFE3F815D +383FFC1F3903F00FE001F85B1201EBFC1F00005CEBFE3F017E90C7FCEB7F7FEB3F7E14FE +6D5AA26D5AA26D5AA21303130780130F80131F80EB3F7E147F497E017E7F141F01FC7F14 +0FD801F87F14071203496C7E120701E07F3A7FFC0FFF8000FF15C06D5A497E007F158022 +2E7EAD27>I<3A7FFC03FFE06D5A00FF15F0007F15E0497E3A07F000FE0000035CEBF801 +00015CA2EBFC0300005CEBFE07017E5BA26D485AA290381F9F80A3010F90C7FCA2EB07FE +A26D5AA26D5AAF90381FFF80497FA36D5B242E7FAD27>I<387FFFF0B512F8A314F000FC +C7FCB3B3ACB512F014F8A36C13F0153A71B327>91 D<127812F87EA27E127E127F7E7F12 +1F7F120F7F12077F1203A27F12017F12007F137E137F7F80131F80130FA2801307801303 +80130180130080147E147F80A21580141F15C0140F15E0140715F0140315F8140115FC14 +00A2157C15381E3A7CB327>I<387FFFF0B512F8A37EEA0001B3B3ACEA7FFFB5FCA36C13 +F0153A7EB327>I<131C137E3801FF80000713E0001F13F84813FC38FFE7FF13C3130000 +FC133F0078131E180B79AD27>I<13E0EA01F01207120F13E0EA1FC0EA3F00A2127E127C +12FC5AA4B4FC138013C0127FA2123F1380EA0F000C1773B227>96 +D<3803FFC0000F13F04813FC4813FF811380EC1FC0381F000F000480C71207A2EB0FFF13 +7F0003B5FC120F5A383FFC07EA7FC0130012FE5AA46C130F007F131FEBC0FF6CB612806C +15C07E000313F1C69038807F8022207C9F27>IIIIII<153F90391F +C0FF80D97FF313C048B612E05A4814EF390FF07F873A1FC01FC3C0EDC000EB800F48486C +7EA66C6C485AEBC01FA2390FF07F8090B5C7FC5C485BEB7FF0EB1FC090C9FCA27F6CB5FC +15E015F84814FE4880EB8001007EC7EA3F80007C140F00FC15C0481407A46C140F007C15 +80007F143F6C6CEB7F009038F807FF6CB55A000714F86C5CC614C0D90FFCC7FC23337EA0 +27>II<130F497E497E +A46D5A6DC7FC90C8FCA7383FFF80487FA37EEA000FB3A4007FB512F0B6FC15F815F07E1D +2F7BAE27>I +107 D<387FFF80B57EA37EEA000FB3B2007FB512F8B612FCA36C14F81E2E7CAD27>I<39 +7F07C01F3AFF9FF07FC09039FFF9FFE091B57E7E3A0FFC7FF1F89038F03FC001E0138001 +C01300A3EB803EB03A7FF0FFC3FF486C01E3138001F913E701F813E36C4801C313002920 +819F27>I<387FE07F39FFF1FFC001F713F090B5FC6C80000313C1EC01FCEBFE005B5BA2 +5BB03A7FFF83FFE0B500C713F0A36C018313E024207F9F27>II<387FE0FFD8FFF313C090B512F0816C800003EB81FE +49C67E49EB3F8049131F16C049130FA216E01507A6150F16C07F151F6DEB3F80157F6DEB +FF009038FF83FEECFFFC5D5D01F313C0D9F0FEC7FC91C8FCAC387FFF80B57EA36C5B2331 +7F9F27>I<90380FF03C90383FFE7E90B5FC000314FE5A380FFC1F381FE007EBC003383F +800148C7FC127EA200FE147E5AA67E007E14FEA2007F1301EA3F80EBC003381FE007380F +F81F6CB5FC7E6C147E38007FFCEB0FF090C7FCAC91381FFFF8A24A13FC6E13F8A226317E +9F27>I<397FFC03FC39FFFE0FFF023F13804A13C0007F90B5FC39007FFE1F14F89138F0 +0F809138E002004AC7FC5CA291C8FCA2137EAD007FB57EB67EA36C5C22207E9F27>I<90 +38FFF3800007EBFFC0121F5A5AEB803F38FC000F5AA2EC07806C90C7FCEA7F8013FC383F +FFF06C13FC000713FF00011480D8000F13C09038003FE014070078EB03F000FC1301A27E +14036CEB07E0EBE01F90B512C01580150000FB13FC38707FF01C207B9F27>I<133C137E +A8007FB512F0B612F8A36C14F0D8007EC7FCAE1518157EA415FE6D13FC1483ECFFF86D13 +F06D13E0010313C0010013001F297EA827>I<397FE01FF8486C487EA3007F131F000313 +00B21401A21403EBFC0F6CB612E016F07EEB3FFE90390FF87FE024207F9F27>I<3A7FFC +0FFF80486C4813C0A36C486C13803A07C000F800EBE00100035CA2EBF00300015CA2EBF8 +0700005CA390387C0F80A36D48C7FCA3EB3F3FEB1F3EA214FE6D5AA36D5AA26D5A22207E +9F27>I<3A7FFE07FFE000FF15F06D5A497E007F15E03A0F80001F00A36D5B0007143EA4 +14F0EBC1F83903E3FC7CA4EBE79EA200011478A301F713F8A2EBFF0F6C5CA3EBFE079038 +7C03E024207F9F27>I<393FFC1FFF486C5A168016006C487E3901F807E06C6C485A4A5A +017E90C7FC6D5AEB1F7E5C6D5A13076D5A5C80497E130F497E143EEB3E3FEB7E1F90387C +0F8001F87F00016D7E3803F0033A7FFE1FFF80A2B54813C06C486C1380A222207E9F27> +I<3A7FFC0FFF80486C4813C0A36C486C13803A07E000F800000313015D13F00001130301 +F85B1200A26D485A137CA290387E0F80133EA2011F90C7FC5CA2130F149E14BE130714FC +1303A25C1301A25CA213035CA213075C1208EA3E0F007F5B131FD87E7FC8FCEA7FFE6C5A +5B6C5AEA07C022317E9F27>I<001FB512FE4814FFA490380001FEEC03FCEC07F8EC0FF0 +001EEB1FE0C7EA3FC0EC7F80ECFF00495A495A495AEB1FE0495A495A49C7FC485A484813 +1E4848133F485A485A485A485AB7FCA46C14FE20207E9F27>II<127812FCB3B3B3 +A21278063A70B327>II E /Fi 134[37 2[37 42 25 29 29 +1[37 33 42 58 1[33 1[21 37 37 21 29 37 30 1[33 7[50 5[42 +19[37 16[19 46[{TeXBase1Encoding ReEncodeFont}23 75.000000 +/Palatino-Italic rf /Fj 21 122 df<007FB51280B612C0A46C14801A067C9623>45 +D47 D<1230127812FE7E7FEA7FE06C7EEA0F +F8EA07FE6C7EC613C06D7E6D7EEB0FFC6D7E903801FF806D13C0147FA214FF4913809038 +07FE00495AEB3FF0495A495A000390C7FC485AEA0FF8EA3FF0485AEAFF8090C8FC5A1278 +12301A247CA523>62 D<3803FF80000F13E04813F8487F80EB80FFEC3F80381F001FC7FC +140F14FF137F0003B5FC120F5A387FF00F130012FCA25A141F7E6C133F387F81FF90B512 +FC6C14FE7E000713C73901FE01FC1F1D7D9C23>97 DI100 DI<147F903801FFC0010713E05B5BEB3FCF140F90383E07C091C7FCA4007FB51280B612 +C0A36C1480D8003EC7FCB3383FFFFE487FA36C5B1B297EA823>I<133813FEA5133890C7 +FCA6EA7FFC487EA3127FEA003EB3387FFFFEB6FCA36C13FE182A7AA923>105 +D107 DI<397E1F01F039FF7FC7FC9038FFEFFE14FF6C80390FE1FE1FEB +C1FC01C07FEB80F8A2EB00F0AE3A7FE3FE3FE026FFF3FF13F0A3267FE3FE13E0241D819C +23>I<38FF81FCEBC7FF01DF138090B512C0A23907FE0FE0EBF807EBF00313E0A313C0AD +39FFFE1FFF5CA380201D7F9C23>I<133F3801FFE0487F487F487F381FC0FE383F807F38 +3E001F007E1480007C130F00FC14C0481307A66C130FA2007C1480007E131F6CEB3F006D +5A381FE1FE6CB45A6C5B6C5B6C5BD8003FC7FC1A1D7C9C23>I<38FF81FCEBC7FF01DF13 +C090B512E015F03907FE0FF8EBF8039038F001FCEBE000A249137EA2153EA5157E7F15FC +7F14019038F803F89038FE0FF090B5FC15E001DF138001CF1300EBC3F801C0C7FCAAEAFF +FEA51F2C7F9C23>I<397FF00FE039FFF87FF8ECFFFC13FB6CB5FCC613F8ECC078EC8000 +91C7FC5BA25BA35BAA387FFFFCB57EA36C5B1E1D7E9C23>114 D<3801FF9C000F13FE5A +127FA2EAFF0000FC137E48133EA26C131C6C1300EA7FF0383FFF80000F13E06C13F83800 +7FFCEB01FEEB007F0070133F00F8131F7E143F7E38FF80FFEBFFFE14FC14F814F0007013 +80181D7B9C23>I<137013F8A7007FB51280B612C0A36C1480D800F8C7FCACEC01C0EC03 +E0A3EBFC07140F9038FE1FC0EB7FFF158090383FFE00EB0FFCEB07F01B257EA423>I<39 +FF807FC001C013E0A400071303B01407140FEBE03F90B6FC7EA2C613F3EB3FC1201D7F9C +23>I<39FFF03FFCA5390F8007C000071480A2EBC00F00031400A26D5A0001131EA2EBF0 +3E0000133CA2EBF87CEB7878A2EB7CF8EB3CF0A2133F6D5AA36D5A6D5A1E1D7E9C23>I< +39FFF03FFCA539078007C0158013C00003130F1500EA01E05CEBF01E1200A26D5A1378A2 +6D5AA3EB1E7014F0130EEB0FE0A213075CA35CA2130F91C7FCA2EA3E1FEA7F1E133EEA7C +FC127F5B6C5A6C5AEA0F801E2C7E9C23>121 D E /Fk 104[75 2[37 +37 25[42 39 62 42 45 24 32 30 42 45 41 43 66 22 42 17 +22 43 42 25 36 46 33 41 37 6[50 50 50 75 54 58 46 39 +50 1[45 59 62 71 46 2[25 62 57 42 46 58 53 46 58 1[33 +3[19 19 1[37 3[37 37 2[37 45 19 25 19 45 1[25 25 21 35[45 +45 2[{TeXBase1Encoding ReEncodeFont}68 75.000000 /Palatino-Roman +rf /Fl 140[32 30 1[45 41 1[66 1[42 5[36 3[37 14[50 2[59 +20[19 58[{.167 SlantFont TeXBase1Encoding ReEncodeFont}11 +75.000000 /Palatino-Roman rf /Fm 1 4 df<1338A50060130C00F8133E00FC137E00 +FE13FE383FBBF83807FFC000011300EA007C48B4FC000713C0383FBBF838FE38FE00FC13 +7E00F8133E0060130C00001300A517197B9A22>3 D E /Fn 7 94 +df<12C07E12707E7E7E120F6C7E6C7EA26C7E6C7EA21378A2137C133C133E131EA2131F +7FA21480A3EB07C0A6EB03E0B2EB07C0A6EB0F80A31400A25B131EA2133E133C137C1378 +A25BA2485A485AA2485A48C7FC120E5A5A5A5A5A13527CBD20>41 +D<15301578B3A6007FB812F8B912FCA26C17F8C80078C8FCB3A6153036367BAF41>43 +D48 DI<007FB812F8B912FCA3CCFCAEB912FCA36C17F836167B9F41>61 +D91 D93 D E /Fo 5 111 df97 DI<133EEA07FEA2EA007CA213FCA25BA21201A25BA2120314FCEBE3FF9038EF07 +80D807FC13C0EBF00313E0A2EA0FC014071380A2121FEC0F801300A248EB1F00A2003E14 +06143E127EEC7C0C127C151800FCEB3C30157048EB1FE00070EB0F801F297CA727>104 +D<130E131F5BA2133E131C90C7FCA7EA03E0487EEA0C78EA187C1230A212605B12C0A2EA +01F0A3485AA2485AA2EBC180EA0F81A2381F0300A213066C5A131CEA07F06C5A11287DA6 +17>I<3907801FC0390FE07FF03918F0E0F83930F1807CEBFB00D860FE133C5B5B00C114 +7C5B1201A248485BA34A5AEA07C01660EC03E0A23A0F8007C0C0A2EDC180913803C300D8 +1F0013C7EC01FE000EEB00F8231B7D9929>110 D E /Fp 167[35 +4[28 3[42 5[18 73[{TeXBase1Encoding ReEncodeFont}4 53.333281 +/Palatino-Roman rf /Fq 4 53 df<13E01201120712FF12F91201B3A7487EB512C0A2 +12217AA01E>49 DI<13FF000313C0380F03E0 +381C00F014F8003E13FC147CA2001E13FC120CC712F8A2EB01F0EB03E0EB0FC03801FF00 +A2380003E0EB00F01478147C143E143F1230127812FCA2143E48137E0060137C003813F8 +381E03F0380FFFC00001130018227DA01E>I<14E01301A213031307A2130D131D133913 +31136113E113C1EA01811203EA07011206120C121C12181230127012E0B6FCA2380001E0 +A6EB03F0EB3FFFA218227DA11E>I E /Fr 9 115 df<007FB612FEA2B8FCA36C15FEA228 +077BA133>45 D99 DIII<14E0EB03F8A2497EA36D5AA2EB00E091C8FCAA383FFFF8 +487FA47EEA0001B3AD007FB612C0B712E016F0A216E06C15C0243E78BD33>105 +D<4AB4FC263FFC0713C0267FFE1F13F000FF017F7F91B5FC6CB67E6CEC07FEC6EBF801EC +F0004A7F4A7F5CA291C7FCA35BB3A43B3FFFF80FFFFC486D4813FEB56C4813FFA26C496C +13FE6C496C13FC302C7FAB33>110 DI114 D E /Fs 14 121 df<153815FC14011407EC0FF8EC1FE0 +EC7FC0ECFF00495A495A495A495A5C495A495A49C7FC137E13FE485A5B12035B485AA248 +5AA2121F5B123F90C8FCA35A127EA312FE5AAB127C127EA3123E123FA26C7EA26C7E7F6C +7E120313FC12016C7E137C131C1E426DB92C>40 D<14E0497E80806D7E147FEC3F80141F +EC0FC0A2EC07E0A2EC03F0A3EC01F8A61400A31401A7140315F0A3140715E0A2140F15C0 +141F1580A2EC3F005C147E14FE5C1301495A495AA2495A495A495A49C7FC13FEEA03FC48 +5A485AEA3FE0485A48C8FC5A12F812701D427AB92C>I46 D<903807FFFE497FA36D5BD9007FC7FC147E +A214FEA25CA21301A25CA21303A25CA21307A25CA2130FA25CA2131FA25CA2133FA291C8 +FCA25B161E017E143FA201FE147F167E5BA2000115FE16FC007FB6FCA2B7FC6C15F8A228 +337EB22C>76 D97 D99 D<147F903803FFC0010F13F0013F13F84913FCEBFFC13801FE004848 +137E485AD80FE013FE15FC485A383F800190380007F848133F90B512F015E01580B5EAFE +0014F000FCC8FCA6127E151C007F143E6C6C13FEEBC00F6CB5FC6C14FC6C14F0000114C0 +39007FFE001F2475A32C>101 D104 +D +109 D<3901F007F03907F81FFC390FFC7FFE486CB5FC48B6128090383FFE1F14F8007E13 +F014E0EB7FC012FE00FC1380140049133FC6481400A348485B157EA24913FE0003ECFC18 +167EEBF00115F8000715FE020313FC01E013F015F1000F15F8EDF3F001C013FF6E13E016 +C0496C13806CC7EA3E0027247AA32C>I<14FE903807FF80011F13E04913F090B5FC48EB +83F83903FE01FCEBF800485A4848137E485AA2485A90C7FC5A127EA215FE12FE4814FCA2 +140115F81403EC07F0A2EC0FE0007EEB1FC0EC3F80007F13FFD83F8313006CB45A14F86C +5B000313C0C648C7FC1F2476A32C>I115 DI<90391FC01F809039FFF07FE0489038 +F9FFF8000790B5FC4815FCD81FF013F03A3FC07FE07E9039803FC0FED87F001381007E14 +8300FE140348EC01FC16F891387F00F0C71400147EA214FEA25CA201011418001E157E00 +3F5B127F018314FE00FF15FC01031301D8FE07EB03F839FC0FFC073A7E1FFE1FF0007FB6 +12E06C15C0023F1300390FFC1FFE3903F007F027247AA32C>120 +D E /Ft 107[33 33 25[37 34 55 38 40 22 28 26 1[40 36 +39 59 19 37 1[19 39 37 22 32 41 29 37 33 8[44 66 48 52 +41 35 44 1[40 52 55 63 2[22 22 55 1[37 1[51 47 41 52 +1[29 3[17 17 1[33 33 2[33 33 1[33 2[17 22 17 2[22 22 +18 36[40 2[{TeXBase1Encoding ReEncodeFont}59 66.666667 +/Palatino-Roman rf /Fu 12 107 df<007FB81280B912C0A26C17803204799641>0 +D14 D +I<007FB812F8B912FCA26C17F8CCFCAD007FB812F8B912FCA26C17F8CCFCAD007FB812F8 +B912FCA26C17F836267BA741>17 D20 D<181EA4181F84A285180785727EA272 +7E727E85197E85F11F80F10FC0F107F0007FBA12FCBCFCA26C19FCCCEA07F0F10FC0F11F +80F13F00197E61614E5A4E5AA24E5A61180F96C7FCA260181EA4482C7BAA53>33 +D<1430A31478A314FCA2497EA2497E497FA2497F90381F7BE090383E79F09038FC78FCD8 +01F8137ED807F0EB3F80D83FE0EB1FF0D8FF80EB07FCD8FE00130100F8EC007C00C0150C +C71400B3B3AD1430264A7EB92A>I<173CA2173E171E171F717E170784717E717E717E84 +007FB87EBAFC8585CBEA03E0F001F8F000FE193FF11FE0F107F8F101FFA2F107F8F11FE0 +F13F0019FEF001F8F003E0BA5A6196C7FC6C5FCB5A604D5A4D5A4D5A60170F4DC8FC171E +173E173CA2482E7BAB53>41 D<91381FFFFE91B6FC1303010F14FED91FF0C7FCEB7F8001 +FEC8FCEA01F8485A485A485A5B48C9FCA2123EA25AA2127812F8A25AA2B712FE16FFA216 +FE00F0C9FCA27EA21278127CA27EA27EA26C7E7F6C7E6C7E6C7EEA00FEEB7F80EB1FF06D +B512FE010314FF1300021F13FE283279AD37>50 D +102 D<12FCEAFFC0EA07F0EA01FCEA007E7F80131F80130FB3A7801307806D7E6D7EEB00 +7EEC1FF0EC07F8EC1FF0EC7E00495A495A495A5C130F5CB3A7131F5C133F91C7FC137E48 +5AEA07F0EAFFC000FCC8FC1D537ABD2A>I<126012F0B3B3B3B3A91260045377BD17>106 +D E /Fv 8 117 df<140EB3A2B812E0A3C7000EC8FCB3A22B2B7DA333>43 +D<13381378EA01F8121F12FE12E01200B3AB487EB512F8A215267BA521>49 +D<13FF000313E0380E03F0381800F848137C48137E00787F12FC6CEB1F80A4127CC7FC15 +005C143E147E147C5C495A495A5C495A010EC7FC5B5B903870018013E0EA018039030003 +0012065A001FB5FC5A485BB5FCA219267DA521>I<13FF000313E0380F01F8381C007C00 +30137E003C133E007E133FA4123CC7123E147E147C5C495AEB07E03801FF8091C7FC3800 +01E06D7E147C80143F801580A21238127C12FEA21500485B0078133E00705B6C5B381F01 +F03807FFC0C690C7FC19277DA521>I<1438A2147814F81301A2130313071306130C131C +131813301370136013C012011380EA03005A120E120C121C5A12305A12E0B612E0A2C7EA +F800A7497E90383FFFE0A21B277EA621>I<0018130C001F137CEBFFF85C5C1480D819FC +C7FC0018C8FCA7137F3819FFE0381F81F0381E0078001C7F0018133EC7FC80A21580A212 +30127C12FCA3150012F00060133E127000305B001C5B380F03E03803FFC0C648C7FC1927 +7DA521>I104 D<13C0A41201A3120312 +07120F121FB512E0A23807C000AC1430A73803E060A23801F0C03800FF80EB3F0014257F +A31A>116 D E /Fw 134[55 50 83 55 61 33 44 39 61 61 55 +61 89 33 61 1[33 61 55 39 50 61 44 61 50 11[78 66 61 +72 1[61 83 83 100 61 2[39 83 1[55 61 83 72 66 78 7[50 +50 50 50 50 50 50 50 50 50 29 25 33 42[61 2[{ +TeXBase1Encoding ReEncodeFont}55 100.000003 /Palatino-Bold +rf /Fx 139[57 1[67 1[105 7[105 2[86 3[86 29[124 9[86 +86 86 86 86 86 86 86 86 86 48[{TeXBase1Encoding ReEncodeFont}17 +172.833377 /Palatino-Bold rf /Fy 94 127 df<121C127FEAFF80B1EA7F00AF123E +C7FCA8121C127FA2EAFF80A3EA7F00A2121C09346FB32C>33 D<003C131E007F137F4814 +80A66C1400A6007E7FA6003E133EA3003C131E001C131C191977B32C>I<010F133C9038 +1F807EA8013F13FE4A5AA4007FB612F0B712F8A4003F15F03A007E01F800A5EBFE0301FC +5BA6003FB612F0B712F8A46C15F03A01F807E000A30003130F01F05BA86C486C5A25337D +B22C>IIIII<143814FC13011303EB07F8EB0FF0EB1FC0EB3F80EB7F0013FE485A485A5B12075B12 +0F5B485AA2123F90C7FCA25A127EA312FE5AAC7E127EA3127F7EA27F121FA26C7E7F1207 +7F12037F6C7E6C7E137FEB3F80EB1FC0EB0FF0EB07F8EB03FC130113001438164272B92C +>I<127012FC7E7E6C7E6C7EEA0FE06C7E6C7E6C7E6C7E137F7F1480131F14C0130FEB07 +E0A214F01303A214F81301A314FC1300AC130114F8A3130314F0A2130714E0A2EB0FC013 +1F1480133F14005B13FE485A485A485A485AEA3FC0485A48C7FC5A5A1270164279B92C> +II<147814FCAF007F +B612F0B712F8A46C15F0C700FCC7FCAF147825267DAB2C>II<007FB6FCB71280A46C150021067B9B2C>I<121FEA3F80EA7FC0EAFF +E0A5EA7FC0EA3F80EA1F000B0B708A2C>I<1507ED0F80151FA2153F16005D157E15FE5D +14015D14035DA214075D140F5D141F5D143F92C7FC5C147E14FE5CA213015C13035C1307 +5C130F5C131F5CA2133F91C8FC5B137E13FE5B12015B12035B12075BA2120F5B121F5B12 +3F90C9FC5A127E12FE5AA25A127821417BB92C>II<1307497EA2131FA2133F137F13FF5A1207127FB5FC13DF139FEA7C1F1200 +B3AE007FB512E0B612F0A36C14E01C3477B32C>IIII<000FB512FE4880A35D0180C8FCADEB83FE90389FFF8090B512E0 +15F8819038FE03FE9038F000FF01C07F49EB3F8090C7121F6C15C0C8120FA2ED07E0A412 +3C127EB4FC150F16C0A248141F007EEC3F80007FEC7F006C6C5B6D485A391FF80FFC6CB5 +5A6C5C000114C06C6C90C7FCEB0FF823347CB22C>II<1278B712C016E0A316C000FCC7EA3F80ED7F0015FE00785CC712 +014A5A4A5A5D140F5D4A5A143F92C7FC5C147E14FE5C13015CA2495AA213075CA3495AA4 +495AA5133F91C8FCAA131E23357CB32C>III<121FEA3F +80EA7FC0EAFFE0A5EA7FC0EA3F80EA1F00C7FCAE121FEA3F80EA7FC0EAFFE0A5EA7FC0EA +3F80EA1F000B2470A32C>II<1507ED1F80153F15FF14034A1300EC1FFC4A5AEC +FFE0491380010790C7FCEB0FFCEB3FF8EB7FE048485A4890C8FCEA0FFEEA1FF8EA7FF0EA +FFC05BA27FEA7FF0EA1FF8EA0FFEEA03FF6C13C06C6C7EEB3FF8EB0FFC6DB4FC01017F6D +13E0EC3FF86E7EEC07FF6E13801400153F151FED0700212A7BAD2C>I<003FB612E04815 +F0B712F8A36C15F0CAFCA8007FB612F0B712F8A36C15F06C15E025147DA22C>I<127012 +FC7E6C7E13E06C7EEA1FFC6C7E3803FF80C67FEB7FF0EB1FF8EB0FFEEB03FF6D13C06D6C +7EEC3FF8EC0FFC6EB4FC0201138080A25C02071300EC0FFCEC3FF8EC7FE049485A4990C7 +FCEB0FFEEB1FF8EB7FF0EBFFC000035BD80FFEC8FC485AEA7FF0485A138048C9FC5A1270 +212A7BAD2C>I +II<14FE497EA4497FA214EFA2130781A214C7A2010F7FA314C390 +381F83F0A590383F01F8A490387E00FCA549137E90B512FEA34880A29038F8003FA34848 +EB1F80A4000715C049130FD87FFEEBFFFC6D5AB514FE6C15FC497E27347EB32C>I<007F +B512E015F8B612FE6C8016C03903F0003FED0FE0ED07F01503A2ED01F8A6ED03F0A21507 +ED0FE0ED1FC0EDFF8090B612005D5D15FF16C09039F0001FE0ED07F0ED03F81501ED00FC +A216FE167EA616FE16FC1501ED03F8150FED3FF0007FB612E016C0B712806CECFE0015F0 +27337FB22C>I<02FF13700107EBE0F84913F9013F13FD4913FFEBFF813901FE007F4848 +131FD807F0130F1507485A491303485A150148C7FCA25A007EEC00F01600A212FE5AAB7E +127EA3007F15F06CEC01F8A26C7EA26C6C13036D14F06C6C130716E0D803FC131F6C6CEB +3FC03A00FF81FF806DB512006D5B010F5B6D13F00100138025357DB32C>I<007FB5FCB6 +12C015F0816C803907E003FEEC00FFED7F80153FED1FC0ED0FE0A2150716F0150316F815 +01A4ED00FCACED01F8A3150316F0A2150716E0150FED1FC0153FED7F80EDFF00EC03FE00 +7FB55AB65A5D15C06C91C7FC26337EB22C>I<007FB612F0B712F8A37E3903F00001A7ED +00F01600A4EC01E04A7EA490B5FCA5EBF003A46E5A91C8FCA5163C167EA8007FB612FEB7 +FCA36C15FC27337EB22C>I<007FB612F8B712FCA37ED803F0C7FCA716781600A515F04A +7EA490B5FCA5EBF001A46E5A92C7FCAD387FFFE0B5FC805C7E26337EB22C>I<903901FC +038090390FFF87C04913EF017F13FF90B6FC4813073803FC01497E4848137F4848133F49 +131F121F5B003F140F90C7FCA2127EED078092C7FCA212FE5AA8913803FFF84A13FCA27E +007E6D13F89138000FC0A36C141FA27F121F6D133F120F6D137F6C7E6C6C13FF6D5A3801 +FF076C90B5FC6D13EF011F13CF6DEB0780D901FCC7FC26357DB32C>II<007FB512F8B612FCA36C14F839000FC000B3B3A5007FB5 +12F8B612FCA36C14F81E3379B22C>I<0107B512804914C0A36D148090390003F000B3AF +1218127EA2B4FCA24A5A48130F007F131F9038C07FC06CB55A6C91C7FC6C5B000313F838 +007FC022347BB22C>II<38 +7FFFE0B57EA36C5BD803F0C8FCB3AE16F0ED01F8A8007FB6FCB7FCA36C15F025337DB22C +>IIII<007FB512C0B612F88115FF6C15802603F00013C0153FED0FE0ED +07F0A2150316F81501A6150316F01507A2ED0FE0ED3FC015FF90B61280160015FC5D15C0 +01F0C8FCB0387FFF80B57EA36C5B25337EB22C>II<387FFFFCB67E15E015F8 +6C803907E007FE1401EC007F6F7E151FA26F7EA64B5AA2153F4BC7FCEC01FE140790B55A +5D15E081819038E007FCEC01FE1400157F81A8160FEE1F80A5D87FFEEB1FBFB5ECFF0081 +5E6C486D5AC8EA01F029347EB22C>I<90381FF80790B5EA0F804814CF000714FF5A381F +F01F383FC003497E48C7FC007E147F00FE143F5A151FA46CEC0F00007E91C7FC127F7FEA +3FE0EA1FFCEBFFC06C13FC0003EBFFC06C14F06C6C7F01077F9038007FFEEC07FF020013 +80153FED1FC0A2ED0FE0A20078140712FCA56CEC0FC0A26CEC1F806D133F01E0EB7F0090 +38FE01FF90B55A5D00F914F0D8F83F13C0D8700790C7FC23357CB32C>I<007FB612FCB7 +12FEA43AFC007E007EA70078153CC71400B3AF90383FFFFCA2497F6D5BA227337EB22C> +I<3B7FFF803FFFC0B56C4813E0A36C496C13C03B03F00001F800B3AF6D130300015DA26D +130700005D6D130F017F495A6D6C485AECE0FF6DB5C7FC6D5B010313F86D5B9038003F80 +2B3480B22C>I +II<3A3FFF +03FFE0484913F0148714076C6D13E03A01F800FE007F0000495A13FE017E5BEB7F03013F +5B1487011F5B14CF010F5B14FF6D5BA26D90C7FCA26D5AA26D5AA2497EA2497EA2497F81 +EB0FCF81EB1FC7EC87F0EB3F83EC03F8EB7F01017E7FEBFE00497F0001147E49137F0003 +80491480151FD87FFEEBFFFC6D5AB514FE6C15FC497E27337EB22C>II<003FB612C04815E0A4 +007EC7EA1FC0ED3F80A2ED7F00157E15FE4A5A003C5CC712034A5AA24A5A4A5AA24A5A4A +C7FCA214FE495AA2495A495AA2495A495AA2495A49C8FCA213FE485AA24848EB03C049EB +07E01207485A5B121F485AA248C7FCB7FCA46C15C023337CB22C>I<387FFFFCB512FEA3 +14FC00FCC7FCB3B3B3B512FC14FEA36C13FC17416FB92C>I<127812F87EA27E127E127F +7E7F121F7F120F7F1207A27F12037F12017F12007F137E137F7F80131FA280130F801307 +801303801301801300A280147E147F8081141F81140F811407811403A281140181140081 +157E157F811680151FA2150FED070021417BB92C>I<387FFFFCB512FEA37EC7127EB3B3 +B3387FFFFEB5FCA36C13FC17417DB92C>I<130EEB3F80EBFFE0000313F8000F13FE487F +D87FF113C0D8FFE013E0EB803F38FE000F007CEB07C00030EB01801B0C78B22C>I<007F +B6FCB71280A46C150021067B7D2C>I<137013F812011203EA07F0EA0FE0EA1FC01380EA +3F00123E127E127CA212FC5AA4EAFF8013C013E0A2127FA2123FEA1FC0EA0F800D1B71B8 +2C>I<3801FFF0000713FE001F6D7E15E048809038C01FF81407EC01FC381F80000006C7 +7EC8127EA3ECFFFE131F90B5FC1203120F48EB807E383FF800EA7FC090C7FC12FE5AA47E +007F14FEEB8003383FE01F6CB612FC6C15FE6C14BF0001EBFE1F3A003FF007FC27247CA3 +2C>II<903803FFE0011F13F8017F13FE48B5FC48804848C6FCEA0FF0485A49137E +4848131890C9FC5A127EA25AA8127EA2127F6C140F6DEB1F806C7E6D133F6C6CEB7F0039 +07FE03FF6CB55A6C5C6C6C5B011F13E0010390C7FC21247AA32C>IIII +II< +1307EB1FC0A2497EA36D5AA20107C7FC90C8FCA7387FFFC080B5FC7EA2EA0007B3A8007F +B512FCB612FEA36C14FC1F3479B32C>I<140EEC3F80A2EC7FC0A3EC3F80A2EC0E0091C7 +FCA748B512804814C0A37EC7120FB3B3A2141F003C1480007E133FB414005CEB01FEEBFF +FC6C5B5C001F5B000790C7FC1A467CB32C>II<387FFFE0B57EA37EEA0003B3B3A5007F +B61280B712C0A36C158022337BB22C>I<3A7F83F007E09039CFFC1FF83AFFDFFE3FFCD8 +7FFF13FF91B57E3A07FE1FFC3E01FCEBF83F496C487E01F013E001E013C0A301C01380B3 +3B7FFC3FF87FF0027F13FFD8FFFE6D13F8D87FFC4913F0023F137F2D2481A32C>I<397F +F01FE039FFF87FFC9038F9FFFE01FB7F6CB6FC00019038F03F80ECC01F02807FEC000F5B +5BA25BB3267FFFE0B5FCB500F11480A36C01E0140029247FA32C>II<397FF01FE0 +39FFF8FFF801FB13FE90B6FC6C158000019038F07FC09138801FE091380007F049EB03F8 +5BED01FC491300A216FE167EA816FE6D14FCA2ED01F86D13036DEB07F0150F9138801FE0 +9138E07FC091B51280160001FB5B01F813F8EC3FC091C8FCAD387FFFE0B57EA36C5B2736 +7FA32C>I<903903FC078090391FFF0FC0017F13CF48B512EF4814FF3807FE07380FF001 +48487E49137F4848133F90C7FC48141F127E150F5AA87E007E141FA26C143F7F6C6C137F +6D13FF380FF0033807FC0F6CB6FC6C14EF6C6C138F6D130FEB07F890C7FCAD0203B5FC4A +1480A36E140029367DA32C>II<90387FF8700003B512F8120F5A5A387FC00F387E00034813015AA36CEB +00F0007F140013F0383FFFC06C13FE6CEBFF80000314E0C66C13F8010113FCEB0007EC00 +FE0078147F00FC143F151F7EA26C143F6D133E6D13FE9038F007FC90B5FC15F815E000F8 +148039701FFC0020247AA32C>I<131E133FA9007FB6FCB71280A36C1500D8003FC8FCB1 +ED03C0ED07E0A5EC800F011FEB1FC0ECE07F6DB51280160001035B6D13F89038003FE023 +2E7EAD2C>I<3A7FF003FF80486C487FA3007F7F0001EB000FB3A3151FA2153F6D137F39 +00FE03FF90B7FC6D15807F6D13CF902603FE07130029247FA32C>I<3A7FFF01FFFCB514 +FE148314016C15FC3A03E0000F80A26D131F00011500A26D5B0000143EA26D137E017C13 +7CA2017E13FC013E5BA2EB3F01011F5BA21483010F5BA214C701075BA214EF01035BA214 +FF6D90C7FCA26D5A147C27247EA32C>II<3A3FFF03FFF048018713F8A36C010313F03A00FC007E005D90387E01F8013F5BEB1F +83EC87E090380FCFC0903807EF80EB03FF6D90C7FC5C6D5A147C14FE130180903803EF80 +903807CFC0EB0FC7EC83E090381F01F0013F7FEB7E00017C137C49137E0001803A7FFF01 +FFFC1483B514FE6C15FC140127247EA32C>I<3A7FFF01FFFCB5008113FE148314816C01 +0113FC3A03E0000F806C7E151F6D140012005D6D133E137C017E137E013E137CA2013F13 +FC6D5BA2EB0F815DA2EB07C1ECC3E0A2EB03E3ECE7C0130114F75DEB00FFA292C7FC80A2 +143EA2147E147CA214FC5CA2EA0C01003F5BEA7F83EB87E0EA7E0F495A387FFF806C90C8 +FC6C5A6C5AEA07E027367EA32C>I<003FB612E04815F0A4007EC7EA1FE0ED3FC0ED7F80 +EDFF004A5A003C495AC7485A4A5A4A5A4A5A4A5A4AC7FCEB01FC495AEB0FF0495A495A49 +5A49C8FC4848EB01E04848EB03F0485A485A485A485A485AB7FCA46C15E024247DA32C> +I<15FF02071380141F147F91B512004913C04AC7FCEB03F85CB31307EB1FE013FF007F5B +B55A49C8FC6D7E6C7FC67F131FEB07F01303B380EB01FEECFFC06D13FF6E1380141F1407 +0200130021417BB92C>I<127812FCB3B3B3A9127806416DB92C>II< +01F81370D803FE13F8380FFF0148138748EBCFF0397F9FFFE0D8FF0F13C0D8FC07138039 +F803FE00387000F81D0A79B22C>I E /Fz 14 121 df<133F14C0EB07F06D7E801301A2 +6D7EA3147FA36E7EA36E7EA36E7EA36E7EA36E7EA36E7EA26E7EA214014A7E5C4A7E9138 +1E3F80143C14784A6C7E1301EB03E049486C7EEB0F80EB1F00496D7E137E5B48486D7E48 +5A485A000F6E7E485A485A48C87E12FE167F4816800070151F293B7CB930>21 +DI<121C127FEAFF80A5EA7F00121C0909798817>58 D<121C127FEAFF80A213C0A3 +127F121C1200A412011380A2120313005A1206120E5A5A5A12600A19798817>II<124012F812FE6C7EEA3FE0EA0FF8EA03FE +C66C7EEB3FE0EB0FF8EB03FE903800FF80EC3FE0EC0FF8EC03FE913800FF80ED3FE0ED0F +F8ED03FE923800FF80EE3FE0EE0FF8EE03FE933800FF80EF3FC0A2EFFF80933803FE00EE +0FF8EE3FE0EEFF80DB03FEC7FCED0FF8ED3FE0EDFF80DA03FEC8FCEC0FF8EC3FE0ECFF80 +D903FEC9FCEB0FF8EB3FE0EBFF80D803FECAFCEA0FF8EA3FE0EAFF8048CBFC12F8126032 +3279AD41>62 D<92391FE00380DBFFFC130002036D5A91390FE01F8F91393F0007DF027E +EB01FE02F81300495A4948147E177C4948143C495AA2011F153891C8FCA3491530A28094 +C7FC80806D7E14FEECFFE06D13FE6DEBFFC06D14F06D806D80021F7F02037FEC003F0303 +7F1500167F163F161FA3120C160FA2001C151F94C7FCA3003C153EA25E003E5D127E007F +4A5A6D495A6DEB0FC0D8F9F0495AD8F0FE01FEC8FC39E03FFFF8010F13E0D8C00190C9FC +313D7CBA33>83 D<16F8ED03FEED0F8792381F0F80ED3E3F167F157CA215FC1700161C4A +48C7FCA414035DA414075DA20107B512F0A39026000FE0C7FC5DA4141F5DA4143F92C8FC +A45C147EA514FE5CA413015CA4495AA45C1307A25C121E123F387F8F80A200FF90C9FC13 +1E12FEEA7C3CEA7878EA1FF0EA07C0294C7CBA29>102 D<14E0EB03F8A21307A314F0EB +01C090C7FCAB13F8EA03FEEA070F000E1380121C121812381230EA701F1260133F00E013 +0012C05BEA007EA213FE5B1201A25B12035BA20007131813E01438000F133013C01470EB +806014E014C01381EB838038078700EA03FEEA00F815397EB71D>105 +D<150FED3F80A2157FA31600151C92C7FCABEC0F80EC3FE0ECF0F0903801C0F849487E14 +005B130E130C131CEB1801133801305BA2EB0003A25DA21407A25DA2140FA25DA2141FA2 +5DA2143FA292C7FCA25CA2147EA214FEA25CA21301001E5B123F387F83F0A238FF87E049 +5A00FE5BD87C1FC8FCEA707EEA3FF8EA0FC0214981B722>I110 D<90390F8003F090391FE00FFC903939F03C1F903A70F8700F80 +903AE0FDE007C09038C0FF80030013E00001491303018015F05CEA038113015CA2D80003 +1407A25CA20107140FA24A14E0A2010F141F17C05CEE3F80131FEE7F004A137E16FE013F +5C6E485A4B5A6E485A90397F700F80DA383FC7FC90387E1FFCEC07E001FEC9FCA25BA212 +01A25BA21203A25B1207B512C0A32C3583A42A>112 D<01F8EB03C0D803FEEB07E0D807 +0F130F000E018013F0121C12180038140700301403D8701F130112601500D8E03F14E000 +C090C7FC5BEA007E16C013FE5B1501000115805B150316001203495B1506150E150C151C +151815385D00015C6D485A6C6C485AD97E0FC7FCEB1FFEEB07F024267EA428>118 +D<903907E001F090391FF807FC9039783E0E0F9039E01F1C1FD801C09038383F803A0380 +0FF07F0100EBE0FF5A000E4A1300000C157E021F133C001C4AC7FC1218A2C7123FA292C8 +FCA25CA2147EA214FEA24A130CA20101141C001E1518003F5BD87F81143801835C00FF15 +60010714E03AFE0E7C01C0D87C1C495A2778383E0FC7FC391FF00FFC3907C003F029267E +A42F>120 D E /FA 105[42 27[42 46 42 69 46 51 28 37 32 +1[51 46 51 74 28 51 28 28 51 46 32 42 51 37 51 42 10[65 +65 55 51 60 69 51 69 69 83 51 2[32 69 69 46 51 69 60 +55 65 1[37 5[42 42 42 42 42 42 42 42 42 42 25 21 28 21 +50 39[51 51 2[{TeXBase1Encoding ReEncodeFont}64 83.333337 +/Palatino-Bold rf /FB 133[37 42 42 60 42 46 28 32 32 +38 42 37 46 65 23 37 23 23 42 42 23 32 42 34 38 37 3[28 +1[28 1[55 3[65 51 46 2[51 65 1[78 3[28 65 1[46 51 65 +1[51 60 1[42 3[21 21 7[42 42 1[25 21 28 21 2[28 28 23 +65 2[42 31[45 44 2[{TeXBase1Encoding ReEncodeFont}58 +83.333337 /Palatino-Italic rf /FC 64[37 39[83 42 1[42 +42 24[42 46 43 69 47 50 27 35 33 46 50 45 48 73 24 46 +19 24 48 46 28 40 51 37 46 42 3[28 1[28 55 55 55 83 60 +65 51 44 55 65 50 65 69 79 51 60 28 28 69 63 46 51 64 +59 51 65 1[37 1[50 1[21 21 42 42 42 42 42 42 42 42 42 +42 50 21 28 21 50 32 28 28 23 65 2[42 1[23 29[50 50 2[{ +TeXBase1Encoding ReEncodeFont}87 83.333337 /Palatino-Roman +rf /FD 134[115 103 172 115 126 69 92 80 1[126 115 126 +184 69 126 1[69 126 115 80 103 126 92 1[103 12[138 126 +149 1[126 172 172 207 3[80 5[149 1[161 17[61 2[52 41[126 +2[{TeXBase1Encoding ReEncodeFont}35 207.333362 /Palatino-Bold +rf /FE 137[66 1[40 53 47 2[66 73 106 40 2[40 73 2[60 +73 2[60 13[73 3[100 10[100 86 80 19[30 46[{ +TeXBase1Encoding ReEncodeFont}19 119.999948 /Palatino-Bold +rf /FF 140[39 36 2[50 2[27 3[53 2[44 1[41 1[46 26[51 +16[46 46 3[46 1[23 46[{TeXBase1Encoding ReEncodeFont}13 +91.666666 /Palatino-Roman rf /FG 138[104 1[76 66 3[104 +1[57 3[104 1[66 85 1[76 1[85 13[104 123 4[170 77[{ +TeXBase1Encoding ReEncodeFont}13 170.833325 /Palatino-Bold +rf end +%%EndProlog +%%BeginSetup +%%Feature: *Resolution 600dpi +TeXDict begin + +%%EndSetup +%%Page: 1 1 +1 0 bop 75 1114 a FG(Scsh)41 b(Reference)i(Manual)p 75 +1183 3900 34 v 2539 1283 a FF(For)23 b(scsh)f(r)n(elease)f(0.4.5)75 +4280 y FE(Olin)29 b(Shivers)g(and)h(Brian)f(D.)g(Carlstrom)p +75 4350 3900 17 v eop +%%Page: 2 2 +2 1 bop 681 1303 a FD(Acknowledgements)681 1784 y FC(Who)24 +b(should)g(I)f(thank?)33 b(My)23 b(so-called)g(\223colleagues,\224)f +(who)j(laugh)e(at)g(me)g(behind)h(my)681 1884 y(back,)19 +b(all)h(the)h(while)g(becoming)g(famous)f(on)h FB(my)e +FC(work?)26 b(My)20 b(worthless)h(graduate)e(stu-)681 +1983 y(dents,)h(whose)h(computer)f(skills)h(appear)e(to)h(be)g(limited) +g(to)h(downloading)g(bitmaps)f(of)o(f)681 2083 y(of)k(netnews?)37 +b(My)24 b(par)o(ents,)g(who)h(ar)o(e)e(still)i(waiting)g(for)f(me)g(to) +h(quit)g(\223fooling)g(ar)o(ound)681 2183 y(with)31 b(computers,\224)i +(go)e(to)h(med)e(school,)k(and)d(become)g(a)f(radiologist?)56 +b(My)31 b(depart-)681 2282 y(ment)24 b(chairman,)g(a)f(manager)g(who)i +(gives)f(one)g(new)g(insight)h(into)g(and)e(sympathy)h(for)681 +2382 y(disgr)o(untled)d(postal)g(workers?)805 2506 y(My)i(God,)g(no)h +(one)f(could)g(blame)f(me\227no)i(one!\227if)f(I)g(went)g(of)o(f)f(the) +h(edge)f(and)g(just)681 2606 y(lost)k(it)g(completely)g(one)h(day)-9 +b(.)39 b(I)26 b(couldn't)g(get)g(thr)o(ough)g(the)g(day)f(as)h(it)g(is) +g(without)h(the)681 2706 y(Pr)o(ozac)g(and)g(Jack)g(Daniels)i(I)f(keep) +g(on)h(the)f(shelf,)i(behind)e(my)g(T)-8 b(ops-20)28 +b(JSYS)f(manu-)681 2805 y(als.)43 b(I)27 b(start)f(getting)i(the)e +(shakes)h(r)o(eal)f(bad)g(ar)o(ound)g(10am,)h(right)g(befor)o(e)e(my)i +(advisor)681 2905 y(meetings.)h(A)20 b(10)h(oz.)g(Jack)f('n)i(Zac)f +(helps)g(me)h(get)f(thr)o(ough)h(the)f(meetings)h(without)h(one)681 +3005 y(of)e(my)h(students)g(winding)h(up)f(with)g(his)g(sever)o(ed)e +(head)h(in)h(a)f(bowling-ball)h(bag.)28 b(They)681 3104 +y(look)d(at)f(me)g(funny;)i(they)e(think)h(I)g(twitch)f(a)g(lot.)36 +b(I'm)25 b(not)f(twitching.)37 b(I'm)25 b(contr)o(olling)681 +3204 y(my)19 b(impulse)h(to)g(snag)f(my)h(9mm)f(Sig-Sauer)e(out)j(fr)o +(om)f(my)g(day-pack)f(and)h(make)g(a)f(few)681 3303 y(str)o(ong)j +(points)h(about)e(the)h(quality)h(of)e(under)o(graduate)f(education)h +(in)i(Amerika.)805 3428 y(If)h(I)f(thought)i(anyone)f(car)o(ed,)e(if)i +(I)f(thought)i(anyone)f(would)g(even)g(be)f(r)o(eading)g(this,)681 +3528 y(I'd)f(pr)o(obably)f(make)h(an)g(ef)o(fort)f(to)h(keep)g(up)g +(appearances)f(until)i(the)f(last)g(possible)h(mo-)681 +3627 y(ment.)k(But)20 b(no)h(one)g(does,)f(and)g(no)h(one)g(will.)26 +b(So)21 b(I)f(can)g(pr)o(etty)g(much)h(say)f(exactly)g(what)681 +3727 y(I)h(think.)805 3851 y(Oh,)g(yes,)g(the)g FB(acknowledgements.)k +FC(I)20 b(think)i(not.)k(I)21 b(did)f(it.)26 b(I)21 b(did)f(it)h(all,)g +(by)f(myself.)2834 4044 y(Olin)h(Shivers)2834 4144 y(Cambridge)2834 +4243 y(September)e(4,)h(1994)2089 5147 y(ii)p eop +%%Page: 3 3 +3 2 bop 365 1307 a FD(Contents)365 1852 y FA(1)83 b(Introduction)2217 +b(1)490 1981 y FC(1.1)86 b(Obtaining)21 b(scsh)63 b Fz(:)42 +b(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f +(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)132 b FC(1)490 +2110 y(1.2)86 b(Building)21 b(scsh)50 b Fz(:)42 b(:)g(:)f(:)h(:)f(:)h +(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:) +f(:)h(:)f(:)h(:)f(:)132 b FC(2)490 2239 y(1.3)86 b(Caveats)59 +b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h +(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)132 +b FC(2)490 2367 y(1.4)86 b(Naming)21 b(conventions)36 +b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h +(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)132 b FC(3)490 2496 +y(1.5)86 b(Lexical)20 b(issues)44 b Fz(:)e(:)g(:)f(:)h(:)f(:)h(:)f(:)h +(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:) +f(:)h(:)f(:)132 b FC(4)681 2625 y(1.5.1)97 b(Extended)20 +b(symbol)i(syntax)g Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)132 b FC(4)681 2754 y(1.5.2)97 +b(Extended)20 b(string)i(syntax)78 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f +(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)132 b +FC(5)681 2883 y(1.5.3)97 b(Block)21 b(comments)h(and)f(executable)e +(interpr)o(eter)o(-triggers)59 b Fz(:)42 b(:)f(:)132 +b FC(5)681 3011 y(1.5.4)97 b(Her)o(e-strings)81 b Fz(:)41 +b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h +(:)g(:)f(:)h(:)f(:)h(:)f(:)132 b FC(5)681 3140 y(1.5.5)97 +b(Dot)79 b Fz(:)41 b(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:) +h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)132 +b FC(7)490 3269 y(1.6)86 b(Recor)o(d)20 b(types)h(and)f(the)h +Fy(define-record)15 b FC(form)80 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:) +h(:)f(:)h(:)f(:)132 b FC(7)490 3398 y(1.7)86 b(A)20 b(wor)o(d)g(about)h +(Unix)g(standar)o(ds)29 b Fz(:)41 b(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f +(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)132 b FC(9)365 +3611 y FA(2)83 b(Process)20 b(notation)2035 b(10)490 +3739 y FC(2.1)86 b(Extended)19 b(pr)o(ocess)i(forms)g(and)f(i/o)i(r)o +(edir)o(ections)70 b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)91 +b FC(10)681 3868 y(2.1.1)97 b(Port)22 b(and)e(\002le)h(descriptor)f +(sync)85 b Fz(:)41 b(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:) +h(:)f(:)95 b FC(1)-5 b(1)490 3997 y(2.2)86 b(Pr)o(ocess)20 +b(forms)36 b Fz(:)42 b(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h +(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)91 +b FC(12)490 4126 y(2.3)86 b(Using)21 b(extended)f(pr)o(ocess)g(forms)h +(in)g(Scheme)75 b Fz(:)41 b(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f +(:)91 b FC(13)681 4254 y(2.3.1)97 b(Pr)o(ocedur)o(es)20 +b(and)g(special)g(forms)40 b Fz(:)h(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g +(:)f(:)h(:)f(:)h(:)f(:)91 b FC(14)681 4383 y(2.3.2)97 +b(Interfacing)21 b(pr)o(ocess)f(output)h(to)g(Scheme)81 +b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)91 +b FC(14)490 4512 y(2.4)86 b(Mor)o(e)19 b(complex)i(pr)o(ocess)g +(operations)i Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f +(:)h(:)f(:)h(:)f(:)91 b FC(16)681 4641 y(2.4.1)97 b(Pids)21 +b(and)g(ports)g(together)65 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f +(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)91 b FC(17)681 +4770 y(2.4.2)97 b(Multiple)21 b(str)o(eam)f(captur)o(e)39 +b Fz(:)j(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:) +h(:)f(:)91 b FC(17)490 4898 y(2.5)86 b(Conditional)21 +b(pr)o(ocess)g(sequencing)h(forms)45 b Fz(:)d(:)g(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)91 b FC(19)1761 5147 y(iii)p +eop +%%Page: 4 4 +4 3 bop 805 614 a FC(2.6)86 b(Pr)o(ocess)21 b(\002lters)41 +b Fz(:)h(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:) +h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b +FC(20)681 825 y FA(3)82 b(System)20 b(Calls)2164 b(21)805 +953 y FC(3.1)86 b(Err)o(ors)58 b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:)h(:)f +(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:) +g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(21)996 1080 y(3.1.1)98 +b(Interactive)20 b(mode)h(and)f(err)o(or)g(handling)39 +b Fz(:)i(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 +b FC(23)805 1207 y(3.2)c(I/O)79 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h +(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:) +h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(24)996 1334 y(3.2.1)98 +b(Standar)o(d)18 b(R4RS)j(I/O)h(pr)o(ocedur)o(es)34 b +Fz(:)42 b(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 +b FC(24)996 1462 y(3.2.2)98 b(Port)21 b(manipulation)h(and)e(standar)o +(d)f(ports)48 b Fz(:)42 b(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 +b FC(24)996 1589 y(3.2.3)98 b(String)21 b(ports)40 b +Fz(:)h(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(26)996 1716 +y(3.2.4)98 b(Revealed)20 b(ports)h(and)f(\002le)h(descriptors)36 +b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 +b FC(26)996 1844 y(3.2.5)98 b(Port-mapping)21 b(machinery)61 +b Fz(:)42 b(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f +(:)h(:)90 b FC(29)996 1971 y(3.2.6)98 b(Unix)21 b(I/O)64 +b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f +(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(31)996 +2098 y(3.2.7)98 b(Buf)o(fer)o(ed)18 b(I/O)57 b Fz(:)42 +b(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g +(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(36)996 2225 y(3.2.8)98 +b(File)21 b(locking)48 b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 +b FC(37)805 2353 y(3.3)c(File)21 b(system)69 b Fz(:)42 +b(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h +(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(40)805 +2480 y(3.4)c(Pr)o(ocesses)67 b Fz(:)41 b(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:) +h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h +(:)f(:)h(:)f(:)h(:)90 b FC(51)996 2607 y(3.4.1)98 b(Pr)o(ocess)20 +b(objects)i(and)e(pr)o(ocess)g(r)o(eaping)75 b Fz(:)41 +b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(54)996 +2735 y(3.4.2)98 b(Pr)o(ocess)20 b(waiting)28 b Fz(:)41 +b(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f +(:)h(:)f(:)h(:)f(:)h(:)90 b FC(57)996 2862 y(3.4.3)98 +b(Analysing)21 b(pr)o(ocess)g(status)f(codes)45 b Fz(:)d(:)f(:)h(:)f(:) +h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(58)805 +2989 y(3.5)c(Pr)o(ocess)21 b(state)79 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:) +h(:)f(:)h(:)f(:)h(:)90 b FC(59)805 3116 y(3.6)c(User)20 +b(and)h(gr)o(oup)f(database)f(access)k Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:) +h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b +FC(61)805 3244 y(3.7)c(Accessing)21 b(command-line)g(ar)o(guments)49 +b Fz(:)42 b(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:) +90 b FC(61)805 3371 y(3.8)c(System)21 b(parameters)38 +b Fz(:)j(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:) +f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(63)805 3498 +y(3.9)c(Signal)21 b(system)40 b Fz(:)i(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f +(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:) +f(:)h(:)90 b FC(63)805 3626 y(3.10)44 b(T)-5 b(ime)39 +b Fz(:)j(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:) +h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 +b FC(67)996 3753 y(3.10.1)56 b(T)-8 b(erminology)70 b +Fz(:)42 b(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(67)996 3880 +y(3.10.2)56 b(Basic)20 b(data)g(types)77 b Fz(:)42 b(:)g(:)f(:)h(:)f(:) +h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 +b FC(68)996 4007 y(3.10.3)56 b(T)-5 b(ime)21 b(zones)59 +b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h +(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(69)996 +4135 y(3.10.4)56 b(Pr)o(ocedur)o(es)61 b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f +(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:) +f(:)h(:)90 b FC(69)805 4262 y(3.1)-5 b(1)49 b(Envir)o(onment)22 +b(variables)30 b Fz(:)41 b(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h +(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(73)996 +4389 y(3.1)-5 b(1.1)61 b(Path)21 b(lists)g(and)g(colon)g(lists)44 +b Fz(:)d(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:) +f(:)h(:)90 b FC(75)996 4516 y(3.1)-5 b(1.2)61 b Fy($USER)p +FC(,)18 b Fy($HOME)p FC(,)h(and)h Fy($PATH)25 b Fz(:)41 +b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h +(:)90 b FC(76)805 4644 y(3.12)44 b(T)-8 b(erminal)21 +b(device)f(contr)o(ol)67 b Fz(:)42 b(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:) +f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 +b FC(76)996 4771 y(3.12.1)56 b(Portability)21 b(acr)o(oss)f(OS)h +(variants)35 b Fz(:)42 b(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:) +h(:)f(:)h(:)90 b FC(76)996 4898 y(3.12.2)56 b(Miscellaneous)21 +b(pr)o(ocedur)o(es)33 b Fz(:)42 b(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h +(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)90 b FC(77)2077 5147 y(iv)p +eop +%%Page: 5 5 +5 4 bop 681 614 a FC(3.12.3)55 b(The)21 b(tty-info)g(r)o(ecor)o(d)e +(type)52 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:) +f(:)h(:)f(:)h(:)f(:)91 b FC(77)681 742 y(3.12.4)55 b(Using)22 +b(tty-info)f(r)o(ecor)o(ds)55 b Fz(:)41 b(:)h(:)f(:)h(:)f(:)h(:)g(:)f +(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)91 b FC(79)681 +869 y(3.12.5)55 b(Other)21 b(terminal-device)f(pr)o(ocedur)o(es)69 +b Fz(:)41 b(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)91 +b FC(80)681 997 y(3.12.6)55 b(Contr)o(ol)22 b(terminals,)e(sessions,)i +(and)f(terminal)f(pr)o(ocess)h(gr)o(oups)126 b(81)681 +1124 y(3.12.7)55 b(Pseudo-terminals)22 b Fz(:)41 b(:)h(:)g(:)f(:)h(:)f +(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)91 +b FC(82)365 1335 y FA(4)83 b(Networking)2195 b(89)490 +1462 y FC(4.1)86 b(High-level)21 b(interface)73 b Fz(:)41 +b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h +(:)g(:)f(:)h(:)f(:)h(:)f(:)91 b FC(89)490 1590 y(4.2)86 +b(Sockets)77 b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:) +f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h +(:)f(:)91 b FC(90)490 1717 y(4.3)86 b(Socket)20 b(addr)o(esses)54 +b Fz(:)41 b(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h +(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)91 b FC(91)490 +1845 y(4.4)86 b(Socket)20 b(primitives)38 b Fz(:)j(:)h(:)f(:)h(:)f(:)h +(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:) +f(:)h(:)f(:)91 b FC(92)490 1972 y(4.5)86 b(Performing)21 +b(input)g(and)g(output)g(on)g(sockets)41 b Fz(:)h(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)91 b FC(94)490 2099 y(4.6)86 +b(Socket)20 b(options)76 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:) +h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f +(:)91 b FC(95)490 2227 y(4.7)86 b(Database-information)20 +b(entries)56 b Fz(:)41 b(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:) +h(:)g(:)f(:)h(:)f(:)h(:)f(:)91 b FC(96)365 2438 y FA(5)83 +b(Strings)20 b(and)f(characters)1821 b(98)490 2565 y +FC(5.1)86 b(String)21 b(manipulation)63 b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f +(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:) +f(:)91 b FC(98)681 2693 y(5.1.1)97 b(Regular)21 b(expr)o(essions)58 +b Fz(:)42 b(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f +(:)h(:)f(:)h(:)f(:)91 b FC(98)681 2820 y(5.1.2)97 b(Other)21 +b(string)h(manipulation)f(facilities)85 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g +(:)f(:)h(:)f(:)h(:)f(:)49 b FC(100)681 2947 y(5.1.3)97 +b(Manipulating)21 b(\002le-names)85 b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:)h +(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)49 b FC(101)490 +3075 y(5.2)86 b(ASCII)20 b(encoding)26 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:) +h(:)f(:)h(:)f(:)49 b FC(106)490 3202 y(5.3)86 b(Character)19 +b(sets)27 b Fz(:)42 b(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h +(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)49 +b FC(107)681 3330 y(5.3.1)97 b(Cr)o(eating)20 b(character)g(sets)27 +b Fz(:)41 b(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h +(:)f(:)h(:)f(:)49 b FC(107)681 3457 y(5.3.2)97 b(Querying)22 +b(character)d(sets)56 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h +(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)49 b FC(107)681 3584 +y(5.3.3)97 b(Character)20 b(set)g(algebra)g Fz(:)42 b(:)f(:)h(:)f(:)h +(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)49 +b FC(108)681 3712 y(5.3.4)97 b(Standar)o(d)19 b(character)g(sets)74 +b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f +(:)h(:)f(:)49 b FC(108)365 3923 y FA(6)83 b(Reading)19 +b(delimited)e(strings)1628 b(109)365 4134 y(7)83 b(A)-6 +b(wk,)20 b(record)h(I/O,)f(and)g(\002eld)f(parsing)1328 +b(1)m(12)490 4261 y FC(7.1)86 b(Recor)o(d)20 b(I/O)h(and)g(\002eld)f +(parsing)57 b Fz(:)41 b(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h +(:)g(:)f(:)h(:)f(:)h(:)f(:)54 b FC(1)-5 b(12)681 4389 +y(7.1.1)97 b(Reading)21 b(r)o(ecor)o(ds)68 b Fz(:)41 +b(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f +(:)h(:)f(:)h(:)f(:)54 b FC(1)-5 b(13)681 4516 y(7.1.2)97 +b(Parsing)21 b(\002elds)39 b Fz(:)i(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)54 +b FC(1)-5 b(13)681 4644 y(7.1.3)97 b(Field)21 b(r)o(eaders)59 +b Fz(:)41 b(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h +(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)54 b FC(1)-5 b(16)681 +4771 y(7.1.4)97 b(Forwar)o(d-pr)o(ogr)o(ess)19 b(guarantees)h(and)g +(empty-string)i(matches)g Fz(:)54 b FC(1)-5 b(17)681 +4898 y(7.1.5)97 b(Reader)20 b(limitations)57 b Fz(:)42 +b(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h +(:)f(:)h(:)f(:)54 b FC(1)-5 b(19)1774 5147 y(v)p eop +%%Page: 6 6 +6 5 bop 805 614 a FC(7.2)86 b(A)-6 b(wk)48 b Fz(:)42 +b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)53 +b FC(1)-5 b(19)996 739 y(7.2.1)98 b(Examples)50 b Fz(:)42 +b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 b FC(122)681 946 +y FA(8)82 b(Miscellaneous)18 b(routines)1731 b(125)805 +1071 y FC(8.1)86 b(Integer)21 b(bitwise)g(ops)40 b Fz(:)h(:)h(:)f(:)h +(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:) +f(:)h(:)f(:)h(:)49 b FC(125)805 1196 y(8.2)86 b(List)21 +b(pr)o(ocedur)o(es)40 b Fz(:)h(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h +(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 +b FC(125)805 1320 y(8.3)86 b(T)-8 b(op)21 b(level)82 +b Fz(:)41 b(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h +(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 +b FC(125)681 1528 y FA(9)82 b(Running)20 b(scsh)2096 +b(127)805 1652 y FC(9.1)86 b(Scsh)21 b(command-line)g(switches)72 +b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f +(:)h(:)f(:)h(:)49 b FC(128)996 1777 y(9.1.1)98 b(Scripts)20 +b(and)h(pr)o(ograms)72 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h +(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 b FC(128)996 +1901 y(9.1.2)98 b(Inserting)21 b(interpr)o(eter)f(triggers)h(into)g +(scsh)h(pr)o(ograms)62 b Fz(:)41 b(:)h(:)f(:)h(:)49 b +FC(128)996 2026 y(9.1.3)98 b(Module)20 b(system)37 b +Fz(:)k(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g +(:)f(:)h(:)f(:)h(:)f(:)h(:)49 b FC(129)996 2150 y(9.1.4)98 +b(Switches)84 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h +(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 +b FC(130)996 2275 y(9.1.5)98 b(The)21 b(meta)f(ar)o(gument)76 +b Fz(:)41 b(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h +(:)f(:)h(:)f(:)h(:)49 b FC(134)996 2399 y(9.1.6)98 b(Examples)50 +b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f +(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 b FC(136)996 +2524 y(9.1.7)98 b(Pr)o(ocess)20 b(exit)h(values)44 b +Fz(:)e(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h +(:)f(:)h(:)f(:)h(:)49 b FC(138)805 2648 y(9.2)86 b(The)21 +b(scsh)g(virtual)g(machine)81 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)f(:)h(:)g +(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 +b FC(139)996 2773 y(9.2.1)98 b(VM)20 b(ar)o(guments)50 +b Fz(:)41 b(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h +(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 b FC(139)996 2897 y(9.2.2)98 +b(Inserting)21 b(interpr)o(eter)f(triggers)h(into)g(heap)g(images)69 +b Fz(:)42 b(:)f(:)h(:)f(:)h(:)49 b FC(140)996 3022 y(9.2.3)98 +b(Inserting)21 b(a)g(double-level)f(trigger)g(into)i(Scheme)e(pr)o +(ograms)37 b Fz(:)42 b(:)49 b FC(141)805 3147 y(9.3)86 +b(Compiling)22 b(scsh)g(pr)o(ograms)49 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 +b FC(141)805 3271 y(9.4)86 b(Statically)20 b(linking)i(heap)f(images)26 +b Fz(:)42 b(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f +(:)h(:)f(:)h(:)49 b FC(142)805 3396 y(9.5)86 b(Standar)o(d)19 +b(\002le)i(locations)50 b Fz(:)41 b(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g +(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 +b FC(144)681 3603 y FA(10)40 b(Changes)20 b(from)h(the)e(previous)h +(release)1304 b(146)805 3728 y FC(10.1)44 b(New)21 b(featur)o(es)52 +b Fz(:)42 b(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f +(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 +b FC(146)805 3852 y(10.2)44 b(Incompatible)21 b(impr)o(ovements)i +Fz(:)41 b(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)g(:)f(:)h +(:)f(:)h(:)f(:)h(:)49 b FC(148)805 3977 y(10.3)44 b(Backwar)o +(ds-compatible)19 b(impr)o(ovements)55 b Fz(:)42 b(:)f(:)h(:)f(:)h(:)f +(:)h(:)g(:)f(:)h(:)f(:)h(:)f(:)h(:)49 b FC(150)681 4184 +y FA(1)m(1)43 b(T)-9 b(odo)2427 b(153)2077 5147 y FC(vi)p +eop +%%Page: 1 7 +1 6 bop 365 1276 a Fx(Chapter)45 b(1)365 1730 y FD(Introduction)365 +2200 y FC(This)32 b(is)g(the)f(r)o(efer)o(ence)d(manual)j(for)g(scsh,)j +(a)d(Unix)g(shell)h(that)f(is)g(embedded)f(within)365 +2300 y(Scheme.)c(Scsh)21 b(is)h(a)e(Scheme)h(system)h(designed)f(for)g +(writing)h(useful)f(standalone)g(Unix)365 2400 y(pr)o(ograms)d(and)g +(shell)h(scripts\227it)g(spans)g(a)f(wide)g(range)g(of)h(application,)f +(fr)o(om)h(\223script\224)365 2499 y(applications)k(usually)f(handled)g +(with)h(perl)f(or)h(sh,)g(to)f(mor)o(e)g(standar)o(d)f(systems)i +(appli-)365 2599 y(cations)e(usually)h(written)f(in)g(C.)490 +2737 y(Scsh)i(comes)g(built)h(on)f(top)h(of)f(Scheme)f(48,)h(and)f(has) +h(two)h(components:)31 b(a)23 b(pr)o(ocess)365 2837 y(notation)i(for)f +(r)o(unning)h(pr)o(ograms)e(and)h(setting)g(up)g(pipelines)g(and)g(r)o +(edir)o(ections,)f(and)365 2936 y(a)29 b(complete)h(syscall)f(library)g +(for)g(low-level)h(access)e(to)i(the)g(operating)f(system.)52 +b(This)365 3036 y(manual)26 b(gives)g(a)f(complete)h(description)g(of)g +(scsh.)40 b(A)26 b(general)f(discussion)i(of)f(the)f(de-)365 +3136 y(sign)31 b(principles)e(behind)h(scsh)g(can)f(be)g(found)g(in)h +(a)f(companion)h(paper)-6 b(,)30 b(\223A)f(Scheme)365 +3235 y(Shell.\224)365 3548 y Fw(1.1)99 b(Obtaining)26 +b(scsh)365 3781 y FC(Scsh)h(is)f(distributed)g(via)g(net)g +(publication.)43 b(W)-8 b(e)26 b(place)g(new)g(r)o(eleases)f(at)h +(well-known)365 3880 y(network)h(sites,)h(and)e(allow)h(them)g(to)f(pr) +o(opagate)f(fr)o(om)h(ther)o(e.)42 b(W)-8 b(e)26 b(curr)o(ently)g(r)o +(elease)365 3980 y(scsh)c(to)f(the)g(following)h(Internet)f(sites:)573 +4140 y Fy(ftp://ftp-swiss.)o(ai)o(.mi)o(t.)o(edu)o(/p)o(ub)o(/su)o(/) +573 4240 y(http://www-swiss)o(.a)o(i.m)o(it)o(.ed)o(u/)o(sc)o(sh/)o(sc) +o(sh.)o(ht)o(ml)573 4340 y(http://www.cs.in)o(di)o(ana)o(.e)o(du/)o(sc) +o(he)o(me-)o(re)o(pos)o(it)o(or)o(y/)365 4500 y FC(These)16 +b(sites)h(ar)o(e)e(the)h(MIT)g(Pr)o(oject)g(Mac)f(ftp)h(server)-6 +b(,)16 b(the)g(Scheme)g(Shell)g(home)h(page,)f(and)365 +4599 y(the)26 b(Indiana)g(Scheme)g(Repository)h(home)g(page,)f(r)o +(espectively)-9 b(.)40 b(Each)26 b(should)h(have)e(a)365 +4699 y(compr)o(essed)18 b(tar)f(\002le)h(of)g(the)g(entir)o(e)f(scsh)h +(r)o(elease,)f(which)i(includes)f(all)f(the)h(sour)o(ce)g(code)365 +4799 y(and)27 b(the)h(manual,)h(and)e(a)h(separate)e(\002le)i +(containing)g(just)h(this)f(manual)g(in)g(Postscript)365 +4898 y(form,)21 b(for)f(those)i(who)f(simply)h(wish)g(to)f(r)o(ead)e +(about)i(the)g(system.)1777 5147 y(1)p eop +%%Page: 2 8 +2 7 bop 805 614 a FC(However)-6 b(,)25 b(nothing)h(is)e(certain)g(for)g +(long)h(on)g(the)f(Net.)36 b(Pr)o(obably)23 b(the)h(best)h(way)f(to)681 +714 y(get)h(a)f(copy)h(of)g(scsh)g(is)g(to)h(use)e(a)h(network)g(r)o +(esour)o(ce-discovery)e(tool,)k(such)e(as)f(ar)o(chie,)681 +814 y(to)j(\002nd)f(ftp)g(servers)g(storing)h(scsh)g(tar)f(\002les.)43 +b(T)-8 b(ake)26 b(the)h(set)f(of)g(sites)h(storing)h(the)e(most)681 +913 y(r)o(ecent)20 b(r)o(elease)f(of)i(scsh,)g(choose)g(one)g(close)g +(to)h(your)f(site,)f(and)h(download)g(the)g(tar)f(\002le.)681 +1194 y Fw(1.2)99 b(Building)26 b(scsh)681 1409 y FC(Scsh)35 +b(curr)o(ently)g(r)o(uns)h(on)f(a)g(fairly)g(lar)o(ge)f(set)h(of)g +(Unix)h(systems,)j(including)d(Linux,)681 1509 y(NetBSD,)28 +b(SunOS,)h(Solaris,)i(AIX,)e(NeXTSTEP)-11 b(,)29 b(Irix,)i(and)e +(HP-UX.)g(W)-8 b(e)29 b(use)h(the)f(Gnu)681 1609 y(pr)o(oject's)38 +b(autocon\002g)i(tool)f(to)g(generate)f(self-con\002guring)h(shell)g +(scripts)g(that)f(cus-)681 1708 y(tomise)24 b(the)h(scsh)f(Make\002le)f +(for)h(dif)o(fer)o(ent)d(OS)j(variants.)35 b(This)24 +b(means)g(that)g(if)g(you)g(use)681 1808 y(one)30 b(of)g(the)g(common)i +(Unix)e(implementations,)j(building)e(scsh)f(should)h(r)o(equir)o(e)e +(ex-)681 1907 y(actly)20 b(the)h(following)h(steps:)938 +2050 y Fy(gunzip)41 b(scsh-0.4.0.tar.gz)159 b FB(Uncompr)o(ess)20 +b(the)g(r)o(elease)i(tar)f(\002le.)938 2149 y Fy(untar)42 +b(xfv)g(scsh-0.4.0.tar)160 b FB(Unpack)20 b(the)g(sour)o(ce)h(code.)938 +2249 y Fy(cd)43 b(scsh-0.4.0)641 b FB(Move)21 b(to)f(the)h(sour)o(ce)f +(dir)o(ectory)m(.)938 2349 y Fy(./configure)728 b FB(Examine)20 +b(host;)g(build)h(Make\002le.)938 2448 y Fy(make)1036 +b FB(Build)21 b(system.)681 2588 y FC(When)40 b(you)g(ar)o(e)f(done,)44 +b(you)d(should)f(have)g(a)f(virtual)g(machine)i(compiled)f(in)g(\002le) +681 2687 y Fy(scshvm)p FC(,)18 b(and)i(a)g(heap)h(image)f(in)i(\002le)e +Fy(scsh/scsh.image)p FC(.)g(T)-7 b(yping)888 2880 y Fy(make)42 +b(install)681 3173 y FC(will)63 b(install)f(these)h(pr)o(ograms)e(in)i +(your)f(installation)h(dir)o(ectory)f(\(by)f(default,)681 +3272 y Fy(/usr/local)p FC(\),)16 b(along)21 b(with)h(a)e(small)h(stub)g +(startup)f(binary)-9 b(,)20 b Fy(scsh)p FC(.)805 3398 +y(If)26 b(you)h(don't)g(have)f(the)h(patience)f(to)h(do)f(this,)j(you)e +(can)f(start)g(up)g(a)g(Scheme)g(shell)681 3498 y(immediately)21 +b(after)e(the)i(initial)g(make)g(by)g(simply)g(saying)888 +3638 y Fy(./scshvm)41 b(-o)h(./scshvm)f(-i)h(scsh/scsh.image)681 +3778 y FC(See)20 b(chapter)g(9)g(for)g(full)h(details)g(on)g +(installation)h(locations)f(and)g(startup)f(options.)805 +3904 y(It)i(is)f(not)i(too)f(dif)o(\002cult)f(to)g(port)h(scsh)g(to)g +(another)f(Unix)g(platform)g(if)h(your)f(OS)h(is)f(not)681 +4004 y(supported)e(by)g(the)h(curr)o(ent)e(r)o(elease.)24 +b(See)18 b(the)i(r)o(elease)e(notes)i(for)f(mor)o(e)g(details)g(on)h +(how)681 4103 y(to)h(do)g(this.)681 4384 y Fw(1.3)99 +b(Caveats)681 4599 y FC(It)19 b(is)g(important)h(to)f(note)g(what)g +(scsh)h(is)f FB(not)p FC(,)g(as)g(well)g(as)g(what)g(it)g(is.)25 +b(Scsh,)19 b(in)h(the)f(curr)o(ent)681 4699 y(r)o(elease,)28 +b(is)g(primarily)g(designed)g(for)g(the)g(writing)h(of)f(shell)h +(scripts\227pr)o(ogramming.)681 4799 y(It)e(is)g(not)h(a)e(very)h +(comfortable)g(system)g(for)g(interactive)f(command)i(use:)38 +b(the)27 b(curr)o(ent)681 4898 y(r)o(elease)22 b(lacks)h(job)h(contr)o +(ol,)h(command-line)f(editing,)g(a)f(terse,)g(convenient)i(command)2092 +5147 y(2)p eop +%%Page: 3 9 +3 8 bop 365 614 a FC(syntax,)36 b(and)c(it)i(does)e(not)i(r)o(ead)d(in) +j(an)e(initialisation)i(\002le)f(analogous)h(to)f Fy(.login)d +FC(or)365 714 y Fy(.profile)p FC(.)42 b(W)-8 b(e)28 b(hope)g(to)f(addr) +o(ess)f(all)h(of)h(these)f(issues)h(in)g(futur)o(e)e(r)o(eleases;)j(we) +f(even)365 814 y(have)22 b(designs)i(for)e(several)g(of)h(these)f +(featur)o(es;)g(but)h(the)g(system)g(as-r)o(eleased)d(does)j(not)365 +913 y(curr)o(ently)e(pr)o(ovide)e(these)i(featur)o(es.)490 +1057 y(In)28 b(the)h(curr)o(ent)e(r)o(elease,)i(the)f(system)h(has)g +(some)g(r)o(ough)f(edges.)48 b(It)28 b(is)h(quite)g(slow)365 +1156 y(to)h(start)f(up;)34 b(we)29 b(hope)h(to)f(\002x)h(that)f(by)h +(pr)o(oviding)f(a)g(static-heap)f(linker)i(in)g(the)g(next)365 +1256 y(r)o(elease.)24 b(For)d(now)-8 b(,)22 b(the)f(initial)g(image)g +(load)f(takes)h(about)f(a)h(cpu)f(second.)490 1399 y(This)i(manual)f +(is)h(very)-9 b(,)21 b(very)g(r)o(ough:)27 b(incomplete,)22 +b(inconsistent,)h(and)e(misleading.)365 1499 y(At)c(some)h(point,)h(we) +e(will)h(polish)h(it)e(up,)h(\002nish)h(it)e(of)o(f,)g(and)g(r)o +(e-typeset)f(it)i(using)g(markup,)365 1599 y(so)30 b(we)f(can)g +(generate)f(html,)k(info)d(nodes,)i(and)e(T)1990 1618 +y(E)2030 1599 y(X)h(output)f(fr)o(om)g(the)g(single)h(sour)o(ce)365 +1698 y(without)22 b(having)f(to)h(deal)d(with)j(T)-8 +b(exinfo.)26 b(But)20 b(it's)i(all)e(ther)o(e)g(is,)h(for)g(now)-8 +b(.)365 2024 y Fw(1.4)99 b(Naming)25 b(conventions)365 +2263 y FC(Scsh)18 b(follows)h(a)f(general)f(naming)i(scheme)f(that)g +(consistently)i(employs)f(a)e(set)i(of)f(abbr)o(e-)365 +2363 y(viations.)40 b(This)26 b(is)f(intended)g(to)h(make)f(it)g +(easier)g(to)g(r)o(emember)g(the)g(names)g(of)h(things.)365 +2462 y(Some)21 b(of)g(the)g(common)h(ones)f(ar)o(e:)365 +2685 y Fy(fdes)40 b FC(Means)30 b(\223\002le)g(descriptor)-6 +b(,\224)31 b(a)e(small)i(integer)f(used)g(in)h(Unix)f(to)g(r)o(epr)o +(esent)f(I/O)573 2784 y(channels.)365 2976 y Fy(...*)40 +b FC(A)26 b(given)h(bit)g(of)g(functionality)h(sometimes)f(comes)h(in)f +(two)g(r)o(elated)e(forms,)j(the)573 3075 y(\002rst)f(being)f(a)g +FB(special)h(form)f FC(that)g(contains)h(a)f(body)h(of)f(Scheme)g(code) +h(to)f(be)h(exe-)573 3175 y(cuted)f(in)h(some)g(context,)i(and)d(the)h +(other)f(being)h(a)g FB(pr)o(ocedur)o(e)e FC(that)i(takes)f(a)g(pr)o +(o-)573 3274 y(cedural)c(ar)o(gument)h(\(a)f(\223thunk\224\))h(to)h(be) +f(called)f(in)i(the)g(same)f(context.)33 b(The)23 b(pr)o(o-)573 +3374 y(cedur)o(e)e(variant)g(is)i(named)f(by)g(taking)h(the)f(name)h +(of)f(the)g(special)g(form,)h(and)f(ap-)573 3474 y(pending)f(an)g +(asterisk.)k(For)c(example:)756 3665 y Fy(;;;)42 b(Special)f(form:)756 +3765 y(\(with-cwd)e("/etc")843 3864 y(\(for-each)h(print-file)f +(\(directory-files)o(\)\))843 3964 y(\(display)h("All)i(done"\)\))756 +4163 y(;;;)g(Procedure:)756 4263 y(\(with-cwd*)d("/etc")843 +4362 y(\(lambda)h(\(\))930 4462 y(\(for-each)g(print-file)f +(\(directory-files\))o(\))930 4562 y(\(display)h("All)i(done"\)\)\))365 +4799 y FB(action)p Fy(/)p FB(modi\002er)e FC(The)e(in\002x)h(\223)p +Fy(/)p FC(\224)e(is)h(pr)o(onounced)g(\223with,\224)43 +b(as)37 b(in)i Fy(exec/env)p FC(\227\223exec)573 4898 +y(with)21 b(envir)o(onment.\224)1777 5147 y(3)p eop +%%Page: 4 10 +4 9 bop 681 614 a Fy(call/...)38 b FC(Pr)o(ocedur)o(es)30 +b(that)i(call)g(their)g(ar)o(gument)g(on)g(some)h(computed)f(value)f +(ar)o(e)888 714 y(usually)21 b(named)f(\223)p Fy(call/...)p +FC(,\224)c FB(e.g.)o FC(,)k Fy(\(call/fdes)40 b FB(port)j(pr)o(oc)o +Fy(\))p FC(,)20 b(which)h(calls)f FB(pr)o(oc)888 814 +y FC(on)f FB(port)o FC('s)f(\002le)g(descriptor)-6 b(,)18 +b(r)o(eturning)g(whatever)f FB(pr)o(oc)g FC(r)o(eturns.)24 +b(The)18 b(abbr)o(eviated)888 913 y(name)j(means)g(\223call)f(with)h +(\002le)g(descriptor)-6 b(.\224)681 1082 y Fy(with-...)38 +b FC(Pr)o(ocedur)o(es)22 b(that)i(call)g(their)g(ar)o(gument,)g(and)f +(special)h(forms)g(that)g(execute)888 1182 y(their)38 +b(bodies)h(in)f(some)h(special)e(dynamic)h(context)h(fr)o(equently)e +(have)h(names)888 1282 y(of)g(the)h(form)f Fy(with-...)p +FC(.)74 b(For)38 b(example,)k Fy(\(with-env)d FB(env)44 +b(body)3111 1309 y Fv(1)3192 1282 y Fy(...\))36 b FC(and)888 +1381 y Fy(\(with-env*)k FB(env)j(thunk)p Fy(\))p FC(.)28 +b(These)22 b(forms)g(set)g(the)g(pr)o(ocess)f(envir)o(onment)h(body)-9 +b(,)888 1481 y(execute)22 b(their)i(body)f(or)g(thunk,)h(and)f(then)g +(r)o(eturn)g(after)e(r)o(esetting)i(the)g(envir)o(on-)888 +1581 y(ment)f(to)f(its)g(original)g(state.)681 1750 y +Fy(create-)38 b FC(Pr)o(ocedur)o(es)d(that)i(cr)o(eate)e(objects)i(in)g +(the)g(\002le)g(system)g(\(\002les,)j(dir)o(ectories,)888 +1849 y(temp)21 b(\002les,)g(\002fos,)g FB(etc.)p FC(\),)f(begin)h(with) +g Fy(create-...)p FC(.)681 2019 y Fy(delete-)38 b FC(Pr)o(ocedur)o(es) +24 b(that)g(delete)g(objects)h(fr)o(om)g(the)f(\002le)h(system)h +(\(\002les,)f(dir)o(ectories,)888 2118 y(temp)c(\002les,)g(\002fos,)g +FB(etc.)p FC(\),)f(begin)h(with)g Fy(delete-...)p FC(.)702 +2287 y FB(r)o(ecord)o Fy(:)p FB(\002eld)62 b FC(Pr)o(ocedur)o(es)22 +b(that)i(access)f(\002elds)h(of)g(a)f(r)o(ecor)o(d)f(ar)o(e)h(usually)h +(written)g(with)888 2387 y(a)h(colon)i(between)e(the)g(name)h(of)f(the) +h(r)o(ecor)o(d)d(and)i(the)h(name)f(of)h(the)f(\002eld,)h(as)g(in)888 +2487 y Fy(user-info:home-di)o(r)p FC(.)681 2656 y Fy(\045...)40 +b FC(A)25 b(per)o(cent)g(sign)i(is)g(used)f(to)g(pr)o(e\002x)f(lower)o +(-level)g(scsh)i(primitives)g(that)f(ar)o(e)e(not)888 +2755 y(commonly)f(used.)681 2925 y Fy(-info)39 b FC(Data)17 +b(str)o(uctur)o(es)h(packaging)g(up)f(information)i(about)f(various)g +(OS)f(entities)i(fr)o(e-)888 3024 y(quently)k(end)e(in)h(.)12 +b(.)g(.)g Fy(-info)p FC(.)27 b(Examples:)g Fy(user-info)p +FC(,)18 b Fy(file-info)p FC(,)f Fy(group-info)p FC(,)888 +3124 y(and)k Fy(host-info)p FC(.)681 3319 y(Enumerated)15 +b(constants)i(fr)o(om)f(some)h(set)f FB(s)h FC(ar)o(e)e(usually)h +(named)g FB(s)p Fy(/)p FB(const)3022 3331 y Fv(1)3059 +3319 y FC(,)h FB(s)p Fy(/)p FB(const)3349 3331 y Fv(2)3387 +3319 y FC(,)g(.)12 b(.)g(.)g(.)681 3418 y(For)29 b(example,)i(the)e +(various)g(Unix)g(signal)h(integers)f(have)g(the)h(names)f +Fy(signal/cont)p FC(,)681 3518 y Fy(signal/kill)p FC(,)16 +b Fy(signal/int)p FC(,)g Fy(signal/hup)p FC(,)g(and)21 +b(so)g(forth.)681 3801 y Fw(1.5)99 b(Lexical)25 b(issues)681 +4018 y FC(Scsh's)c(lexical)f(syntax)h(is)g(just)g(R4RS)g(Scheme,)f +(with)i(the)f(following)h(exceptions.)681 4276 y FA(1.5.1)81 +b(Extended)18 b(symbol)i(syntax)681 4462 y FC(Scsh's)h(symbol)h(syntax) +e(dif)o(fers)g(fr)o(om)g(R4RS)h(Scheme)f(in)h(the)g(following)i(ways:) +805 4656 y Fu(\017)41 b FC(In)29 b(scsh,)i(symbol)e(case)f(is)h(pr)o +(eserved)d(by)j Fy(read)e FC(and)h(is)g(signi\002cant)i(on)f(symbol)888 +4756 y(comparison.)e(This)21 b(means)1071 4898 y Fy(\(run)42 +b(\(less)f(Readme\)\))2092 5147 y FC(4)p eop +%%Page: 5 11 +5 10 bop 573 614 a FC(displays)21 b(the)g(right)g(\002le.)490 +798 y Fu(\017)41 b FC(\223)p Fy(-)p FC(\224)16 b(and)h(\223)p +Fy(+)p FC(\224)e(ar)o(e)h(allowed)h(to)h(begin)g(symbols.)25 +b(So)17 b(the)h(following)h(ar)o(e)c(legitimate)573 897 +y(symbols:)756 1056 y Fy(-O2)42 b(-geometry)e(+Wn)490 +1256 y Fu(\017)h FC(\223)p Fy(|)p FC(\224)22 b(and)i(\223)p +Fy(.)p FC(\224)e(ar)o(e)h(symbol)i(constituents.)36 b(This)24 +b(allows)h Fy(|)e FC(for)h(the)g(pipe)g(symbol,)573 1356 +y(and)30 b Fy(..)f FC(for)h(the)g(par)o(ent-dir)o(ectory)e(symbol.)55 +b(\(Of)30 b(course,)i(\223)p Fy(.)p FC(\224)d(alone)i(is)f(not)h(a)573 +1455 y(symbol,)21 b(but)g(a)f(dotted-pair)g(marker)-6 +b(.\))490 1638 y Fu(\017)41 b FC(A)26 b(symbol)h(may)g(begin)f(with)i +(a)d(digit.)43 b(So)26 b(the)h(following)h(ar)o(e)d(legitimate)h(sym-) +573 1738 y(bols:)756 1897 y Fy(9x15)41 b(80x36-3+440)365 +2181 y FA(1.5.2)81 b(Extended)18 b(string)i(syntax)365 +2380 y FC(Scsh)e(strings)g(ar)o(e)e(allowed)h(to)h(contain)g(the)h(A)t +Ft(N)t(S)t(I)h FC(C)d(escape)g(sequences)h(such)f(as)g +Fy(\\n)g FC(and)365 2480 y Fy(\\161)p FC(.)365 2764 y +FA(1.5.3)81 b(Block)21 b(comments)e(and)h(executable)d(interpreter)o +(-triggers)365 2964 y FC(Scsh)k(allows)g(sour)o(ce)g(\002les)g(to)g +(begin)g(with)h(a)e(header)f(of)i(the)g(form)573 3122 +y Fy(#!/usr/local/bin)o(/s)o(csh)37 b(-s)365 3281 y FC(The)30 +b(Unix)g(operating)g(system)g(tr)o(eats)f(sour)o(ce)g(\002les)h +(beginning)h(with)g(the)f(headers)f(of)365 3381 y(this)23 +b(form)f(specially;)h(they)f(can)g(be)g(dir)o(ectly)f(executed)g(by)h +(the)g(operating)g(system)h(\(see)365 3480 y(chapter)32 +b(9)g(for)h(information)h(on)f(how)h(to)f(use)f(this)i(featur)o(e\).)59 +b(The)33 b(scsh)g(interpr)o(eter)365 3580 y(ignor)o(es)c(this)g +(special)f(header)f(by)i(tr)o(eating)f Fy(#!)f FC(as)i(a)e(comment)j +(marker)e(similar)g(to)h Fy(;)p FC(.)365 3679 y(When)18 +b(the)g(scsh)g(r)o(eader)d(encounters)j Fy(#!)p FC(,)f(it)h(skips)g +(characters)e(until)i(it)g(\002nds)g(the)f(closing)365 +3779 y(sequence)k(newline/exclamation-point/sharp-sign/newline.)490 +3916 y(Although)f(the)g(form)g(of)f(the)h Fy(#!)f FC(r)o(ead-macr)o(o)e +(was)i(chosen)i(to)f(support)g(interpr)o(eter)o(-)365 +4016 y(triggers)32 b(for)e(executable)g(Unix)h(scripts,)j(it)d(is)h(a)f +(general)f(block-comment)i(sequence)365 4116 y(and)21 +b(can)f(be)g(used)h(as)f(such)i(anywher)o(e)e(in)h(a)f(scsh)i(pr)o +(ogram.)365 4400 y FA(1.5.4)81 b(Here-strings)365 4599 +y FC(The)33 b(r)o(ead)e(macr)o(o)h Fy(#<)g FC(is)h(used)f(to)h(intr)o +(oduce)g(\223her)o(e-strings\224)e(in)i(pr)o(ograms,)i(similar)365 +4699 y(to)f(the)f Fy(<<)f FC(\223her)o(e)f(document\224)i(r)o(edir)o +(ections)f(pr)o(ovided)f(by)i(sh)h(and)e(csh.)62 b(Ther)o(e)32 +b(ar)o(e)365 4799 y(two)22 b(kinds)f(of)g(her)o(e-string,)f(character)o +(-delimited)e(and)i(line-delimited;)h(they)g(ar)o(e)e(both)365 +4898 y(intr)o(oduced)h(by)h(the)g Fy(#<)f FC(sequence.)1777 +5147 y(5)p eop +%%Page: 6 12 +6 11 bop 681 614 a FA(Character)o(-delimited)15 b(here-strings)681 +821 y FC(A)20 b FB(character-delimited)f FC(her)o(e-string)h(has)h(the) +g(form)888 988 y Fy(#<)p Fs(x)p Fy(...stuff...)p Fs(x)681 +1155 y FC(wher)o(e)i FB(x)g FC(is)h(any)f(single)h(character)e +(\(except)h Fy(<)p FC(,)g(see)g(below\),)h(which)h(is)f(used)f(to)h +(delimit)681 1255 y(the)d(string)g(bounds.)26 b(Some)21 +b(examples:)938 1423 y(Her)o(e-string)f(syntax)288 b(Or)o(dinary)20 +b(string)i(syntax)p 888 1457 1943 4 v 938 1526 a Fy(#<|Hello,)40 +b(world.|)227 b("Hello,)41 b(world.")938 1626 y(#)g FB([fdes])g +(\002le-name)p Fy(\))209 b(;)43 b(Open)f(file)g(create/truncate.)888 +3822 y(\(<<)h FB([fdes])g(object)p Fy(\))280 b(;)43 b(Use)g +FB(object)p Fy('s)g(printed)d(rep.)888 3921 y(\(>>)j +FB([fdes])g(\002le-name)o Fy(\))166 b(;)43 b(Open)f(file)g(for)h +(append.)888 4021 y(\(=)g FB(fdes)h(fdes/port)o Fy(\))279 +b(;)43 b(Dup2)888 4121 y(\(-)g FB(fdes/port)o Fy(\))452 +b(;)43 b(Close)f FB(fdes/port)o Fy(.)888 4220 y(stdports)567 +b(;)43 b(0,1,2)f(dup'd)f(from)h(standard)f(ports.)681 +4368 y FC(The)26 b(input)h(r)o(edir)o(ections)e(default)g(to)h(\002le)h +(descriptor)f(0;)i(the)e(output)h(r)o(edir)o(ections)e(de-)681 +4468 y(fault)20 b(to)h(\002le)g(descriptor)f(1.)805 4599 +y(The)42 b(subforms)g(of)f(a)g(r)o(edir)o(ection)g(ar)o(e)f(implicitly) +i(backquoted,)47 b(and)41 b(symbols)681 4699 y(stand)e(for)h(their)g +(print-names.)82 b(So)40 b Fy(\(>)i(,x\))d FC(means)h(\223output)g(to)g +(the)g(\002le)f(named)681 4799 y(by)h(Scheme)f(variable)g +Fy(x)p FC(,\224)44 b(and)39 b Fy(\(<)k(/usr/shivers/.lo)o(gi)o(n\))34 +b FC(means)40 b(\223r)o(ead)d(fr)o(om)681 4898 y Fy(/usr/shivers/.lo)o +(gi)o(n)p FC(.\224)2071 5147 y(10)p eop +%%Page: 11 17 +11 16 bop 490 614 a FC(Her)o(e)19 b(ar)o(e)h(two)h(mor)o(e)g(examples)f +(of)h(i/o)g(r)o(edir)o(ection:)1318 800 y Fy(\(<)43 b(,\(vector-ref)38 +b(fv)43 b(i\)\))1318 900 y(\(>>)f(2)h(/tmp/buf\))365 +1083 y FC(These)j(two)g(r)o(edir)o(ections)e(cause)h(the)h(\002le)f +Fy(fv[i])f FC(to)i(be)f(opened)g(on)h(stdin,)52 b(and)365 +1183 y Fy(/tmp/buf)18 b FC(to)j(be)f(opened)h(for)f(append)g(writes)h +(on)h(stderr)-6 b(.)490 1310 y(The)18 b(r)o(edir)o(ection)e +Fy(\(<<)42 b FB(object)q Fy(\))17 b FC(causes)g(input)i(to)f(come)g(fr) +o(om)f(the)h(printed)g(r)o(epr)o(esen-)365 1410 y(tation)j(of)g +FB(object)p FC(.)26 b(For)21 b(example,)573 1553 y Fy(\(<<)42 +b("The)g(quick)g(brown)f(fox)i(jumped)e(over)h(the)g(lazy)g(dog."\))365 +1697 y FC(causes)32 b(r)o(eads)f(fr)o(om)i(stdin)g(to)g(pr)o(oduce)e +(the)i(characters)e(of)h(the)h(above)f(string.)62 b(The)365 +1796 y(object)25 b(is)g(converted)e(to)i(its)g(printed)f(r)o(epr)o +(esentation)f(using)i(the)f Fy(display)e FC(pr)o(ocedur)o(e,)365 +1896 y(so)573 2039 y Fy(\(<<)42 b(\(A)h(five)f(element)f(list\)\))365 +2182 y FC(is)21 b(the)g(same)g(as)573 2326 y Fy(\(<<)42 +b("\(A)h(five)e(element)g(list\)"\))365 2469 y FC(is)21 +b(the)g(same)g(as)573 2612 y Fy(\(<<)42 b(,\(reverse)e('\(list)h +(element)g(five)h(A\)\)\))p FC(.)365 2756 y(\(Her)o(e)15 +b(we)h(use)g(the)g(implicit)h(backquoting)g(featur)o(e)d(to)j(compute)f +(the)h(list)f(to)h(be)e(printed.\))490 2883 y(The)27 +b(r)o(edir)o(ection)f Fy(\(=)43 b FB(fdes)h(fdes/port)o +Fy(\))26 b FC(causes)h FB(fdes/port)g FC(to)g(be)g(dup'd)g(into)h +(\002le)f(de-)365 2983 y(scriptor)21 b FB(fdes)p FC(.)26 +b(For)21 b(example,)f(the)h(r)o(edir)o(ection)573 3126 +y Fy(\(=)43 b(2)g(1\))365 3269 y FC(causes)20 b(stderr)f(to)i(be)e(the) +h(same)g(as)g(stdout.)26 b FB(fdes/port)19 b FC(can)g(also)i(be)e(a)h +(port,)g(for)g(example:)573 3413 y Fy(\(=)43 b(2)g(,\(current-output)o +(-p)o(ort)o(\)\))365 3556 y FC(causes)29 b(stderr)f(to)h(be)f(dup'd)h +(fr)o(om)f(the)h(curr)o(ent)f(output)h(port.)50 b(In)29 +b(this)h(case,)g(it)f(is)g(an)365 3656 y(err)o(or)19 +b(if)h(the)g(port)g(is)h(not)g(a)e(\002le)h(port)g(\()p +FB(e.g.)o FC(,)g(a)g(string)g(port\).)25 b(Mor)o(e)19 +b(complex)i(r)o(edir)o(ections)365 3755 y(can)31 b(be)f(accomplished)h +(using)h(the)f Fy(begin)e FC(pr)o(ocess)h(form,)j(discussed)e(below)-8 +b(,)34 b(which)365 3855 y(gives)21 b(the)g(pr)o(ogrammer)f(full)h +(contr)o(ol)g(of)g(i/o)g(r)o(edir)o(ection)f(fr)o(om)g(Scheme.)365 +4114 y FA(2.1.1)81 b(Port)21 b(and)f(\002le)f(descriptor)h(sync)365 +4301 y FC(It's)33 b(important)g(to)h(r)o(emember)d(that)i(r)o(ebinding) +f(Scheme's)h(curr)o(ent)f(I/O)h(ports)g(\()p FB(e.g.)o +FC(,)365 4400 y(using)28 b Fy(call-with-input-)o(fi)o(le)20 +b FC(to)27 b(r)o(ebind)f(the)h(value)f(of)g Fy(\(current-input-po)o(rt) +o(\))p FC(\))365 4500 y(does)42 b FB(not)f FC(automatically)h(\223r)o +(ebind\224)e(the)h(\002le)h(r)o(efer)o(enced)d(by)j(the)g(Unix)f(stdio) +h(\002le)365 4599 y(descriptors)f(0,)46 b(1,)g(and)41 +b(2.)87 b(This)42 b(is)g(impossible)g(to)g(do)g(in)f(general,)46 +b(since)c(some)365 4699 y(Scheme)37 b(ports)g(ar)o(e)f(not)i(r)o(epr)o +(esentable)c(as)j(Unix)g(\002le)g(descriptors.)74 b(For)38 +b(example,)365 4799 y(many)27 b(Scheme)e(implementations)j(pr)o(ovide)d +(\223string)h(ports,\224)h(that)g(is,)g(ports)f(that)h(col-)365 +4898 y(lect)36 b(characters)f(sent)h(to)g(them)g(into)h(memory)g(buf)o +(fers.)69 b(The)36 b(accumulated)f(string)1758 5147 y(1)-5 +b(1)p eop +%%Page: 12 18 +12 17 bop 681 614 a FC(can)41 b(later)h(be)f(r)o(etrieved)g(fr)o(om)g +(the)h(port)g(as)g(a)g(string.)90 b(If)41 b(a)h(user)f(wer)o(e)h(to)g +(bind)681 714 y Fy(\(current-output-)o(po)o(rt\))24 b +FC(to)32 b(such)g(a)f(port,)j(it)d(would)h(be)f(impossible)i(to)e +(associate)681 814 y(\002le)26 b(descriptor)g(1)g(with)g(this)h(port,)h +(as)e(it)g(cannot)h(be)e(r)o(epr)o(esented)f(in)j(Unix.)42 +b(So,)27 b(if)f(the)681 913 y(user)j(subsequently)i(forked)e(of)o(f)g +(some)h(other)g(pr)o(ogram)f(as)g(a)g(subpr)o(ocess,)i(that)f(pr)o(o-) +681 1013 y(gram)20 b(would)i(of)e(course)h(not)h(see)e(the)h(Scheme)f +(string)i(port)f(as)f(its)h(standar)o(d)e(output.)805 +1157 y(T)-8 b(o)32 b(keep)f(stdio)h(synced)g(with)g(the)f(values)g(of)h +(Scheme's)f(curr)o(ent)g(i/o)h(ports,)i(use)681 1257 +y(the)25 b(special)g(r)o(edir)o(ection)f Fy(stdports)p +FC(.)35 b(This)26 b(causes)f(0,)h(1,)f(2)g(to)h(be)e(r)o(edir)o(ected)f +(fr)o(om)i(the)681 1356 y(curr)o(ent)20 b(Scheme)g(standar)o(d)f +(ports.)26 b(It)21 b(is)g(equivalent)g(to)g(the)g(thr)o(ee)f(r)o(edir)o +(ections:)888 1580 y Fy(\(=)43 b(0)g(,\(current-input-p)o(or)o(t\)\)) +888 1679 y(\(=)g(1)g(,\(current-output-)o(po)o(rt\))o(\))888 +1779 y(\(=)g(2)g(,\(error-output-po)o(rt)o(\)\))681 2002 +y FC(The)30 b(r)o(edir)o(ections)g(ar)o(e)f(done)i(in)g(the)f +(indicated)g(or)o(der)-6 b(.)54 b(This)31 b(will)g(cause)f(an)h(err)o +(or)e(if)681 2102 y(one)23 b(of)h(the)f(curr)o(ent)g(i/o)h(ports)f +(isn't)h(a)f(Unix)g(port)h(\()p FB(e.g.)o FC(,)f(if)h(one)f(is)h(a)f +(string)h(port\).)32 b(This)681 2202 y(Scheme/Unix)18 +b(i/o)h(synchr)o(onisation)h(can)e(also)g(be)g(had)g(in)h(Scheme)e +(code)h(\(as)g(opposed)681 2301 y(to)j(a)f(r)o(edir)o(ection)g(spec\))g +(with)h(the)g Fy(\(stdports->stdio\))14 b FC(pr)o(ocedur)o(e.)681 +2629 y Fw(2.2)99 b(Process)25 b(forms)681 2868 y FC(A)19 +b FB(pr)o(ocess)h(form)g FC(speci\002es)g(a)g(computation)h(to)f +(perform)g(as)f(an)h(independent)g(Unix)g(pr)o(o-)681 +2968 y(cess.)25 b(It)c(can)g(be)f(one)h(of)g(the)g(following:)888 +3130 y Fy(\(begin)41 b(.)j FB(scheme-code)n Fy(\))888 +3230 y(\(|)f FB(pf)1072 3257 y Fv(1)1153 3230 y Fy(...)g +FB(pf)1381 3257 y Fo(n)1426 3230 y Fy(\))888 3329 y(\(|+)g +FB(connect-list)g(pf)1550 3356 y Fv(1)1631 3329 y Fy(...)f +FB(pf)1858 3356 y Fo(n)1904 3329 y Fy(\))888 3429 y(\(epf)g(.)h +FB(epf)p Fy(\))888 3528 y(\()p FB(pr)o(og)f(ar)o(g)1235 +3556 y Fv(1)1316 3528 y Fy(...)h FB(ar)o(g)1600 3556 +y Fo(n)1645 3528 y Fy(\))2134 3134 y(;)g(Run)f FB(scheme-code)h +Fy(in)g(a)g(fork.)2134 3234 y(;)g(Simple)e(pipeline)2134 +3334 y(;)i(Complex)e(pipeline)2134 3433 y(;)i(An)g(extended)d(process)h +(form.)2134 3533 y(;)i(Default:)d(exec)i(the)h(program.)681 +3694 y FC(The)19 b(default)g(case)g Fy(\()p FB(pr)o(og)42 +b(ar)o(g)1640 3721 y Fv(1)1721 3694 y Fy(...)g FB(ar)o(g)2004 +3721 y Fo(n)2049 3694 y Fy(\))19 b FC(is)h(also)g(implicitly)h +(backquoted.)k(That)19 b(is,)h(it)681 3793 y(is)h(equivalent)g(to:)888 +3962 y Fy(\(begin)41 b(\(apply)h(exec-path)d(`\()p FB(pr)o(og)j(ar)o(g) +2325 3989 y Fv(1)2406 3962 y Fy(...)g FB(ar)o(g)2689 +3989 y Fo(n)2735 3962 y Fy(\)\)\))681 4131 y(Exec-path)27 +b FC(is)j(the)h(version)g(of)g(the)f Fy(exec\(\))e FC(system)j(call)g +(that)f(uses)h(scsh's)g(path)f(list)681 4231 y(to)f(sear)o(ch)e(for)i +(an)f(executable.)48 b(The)29 b(pr)o(ogram)e(and)i(the)f(ar)o(guments)h +(must)g(be)f(either)681 4331 y(strings,)h(symbols,)g(or)d(integers.)44 +b(Symbols)27 b(and)f(integers)h(ar)o(e)e(coer)o(ced)g(to)i(strings.)44 +b(A)681 4430 y(symbol's)17 b(print-name)g(is)f(used.)24 +b(Integers)16 b(ar)o(e)f(converted)h(to)h(strings)g(in)g(base)f(10.)23 +b(Using)681 4530 y(symbols)k(instead)e(of)g(strings)i(is)f(convenient,) +h(since)f(it)f(suppr)o(esses)g(the)h(clutter)f(of)h(the)681 +4630 y(surr)o(ounding)f Fy("...")d FC(quotation)j(marks.)37 +b(T)-8 b(o)24 b(aid)g(this)h(purpose,)g(scsh)g(r)o(eads)e(symbols)681 +4729 y(in)e(a)f(case-sensitive)h(manner)-6 b(,)20 b(so)h(that)g(you)g +(can)g(say)888 4898 y Fy(\(more)42 b(Readme\))2071 5147 +y FC(12)p eop +%%Page: 13 19 +13 18 bop 365 614 a FC(and)21 b(get)f(the)h(right)h(\002le.)490 +739 y(A)31 b FB(connect-list)g FC(is)h(a)g(speci\002cation)g(of)f(how)i +(two)f(pr)o(ocesses)g(ar)o(e)e(to)i(be)g(wir)o(ed)f(to-)365 +839 y(gether)22 b(by)h(pipes.)30 b(It)22 b(has)g(the)h(form)f +Fy(\(\()p FB(fr)o(om)1791 866 y Fv(1)1872 839 y FB(fr)o(om)2028 +866 y Fv(2)2108 839 y Fy(...)43 b FB(to)o Fy(\))g(...\))21 +b FC(and)h(is)g(implicitly)365 938 y(backquoted.)k(For)21 +b(example,)573 1077 y Fy(\(|+)42 b(\(\(1)h(2)g(0\))f(\(3)h(1\)\))g +FB(pf)1498 1104 y Fv(1)1579 1077 y FB(pf)1632 1104 y +Fv(2)1669 1077 y Fy(\))365 1215 y FC(r)o(uns)26 b FB(pf)609 +1242 y Fv(1)672 1215 y FC(and)e FB(pf)890 1242 y Fv(2)928 +1215 y FC(.)38 b(The)25 b(\002rst)g(clause)g Fy(\(1)43 +b(2)g(0\))24 b FC(causes)h FB(pf)2221 1242 y Fv(1)2258 +1215 y FC('s)g(stdout)h(\(1\))e(and)g(stderr)h(\(2\))365 +1315 y(to)d(be)f(connected)g(via)g(pipe)g(to)h FB(pf)1426 +1342 y Fv(2)1463 1315 y FC('s)g(stdin)g(\(0\).)k(The)21 +b(second)h(clause)f Fy(\(3)42 b(1\))21 b FC(causes)g +FB(pf)3134 1342 y Fv(1)3171 1315 y FC('s)365 1415 y(\002le)g +(descriptor)g(3)f(to)h(be)f(connected)h(to)g FB(pf)1698 +1442 y Fv(2)1735 1415 y FC('s)g(\002le)g(descriptor)f(1.)490 +1539 y(The)32 b Fy(begin)e FC(pr)o(ocess)i(form)h(does)f(a)g +Fy(stdio->stdports)26 b FC(synchr)o(onisation)34 b(in)e(the)365 +1639 y(child)25 b(pr)o(ocess)g(befor)o(e)e(executing)i(the)g(body)g(of) +g(the)g(form.)37 b(This)26 b(guarantees)e(that)g(the)365 +1738 y Fy(begin)j FC(form,)k(like)f(all)f(other)g(pr)o(ocess)g(forms,)i +(\223sees\224)d(the)h(ef)o(fects)f(of)h(any)g(associated)365 +1838 y(I/O)22 b(r)o(edir)o(ections.)490 1962 y(Note)e(that)g(R4RS)g +(does)h(not)f(specify)g(whether)h(or)f(not)h Fy(|)f FC(and)f +Fy(|+)h FC(ar)o(e)e(r)o(eadable)g(sym-)365 2062 y(bols.)26 +b(Scsh)21 b(does.)365 2338 y Fw(2.3)99 b(Using)26 b(extended)d(process) +j(forms)f(in)f(Scheme)365 2553 y FC(Pr)o(ocess)32 b(forms)h(and)e +(extended)h(pr)o(ocess)f(forms)i(ar)o(e)d FB(not)i FC(Scheme.)60 +b(They)32 b(ar)o(e)f(a)g(dif-)365 2652 y(fer)o(ent)f(notation)h(for)f +(expr)o(essing)g(computation)h(that,)i(like)e(Scheme,)h(is)e(based)g +(upon)365 2752 y(s-expr)o(essions.)44 b(Extended)26 b(pr)o(ocess)g +(forms)h(ar)o(e)e(used)i(in)g(Scheme)g(pr)o(ograms)f(by)h(em-)365 +2851 y(bedding)17 b(them)g(inside)g(special)f(Scheme)g(forms.)25 +b(Ther)o(e)16 b(ar)o(e)f(thr)o(ee)h(basic)g(Scheme)g(forms)365 +2951 y(that)21 b(use)g(extended)f(pr)o(ocess)g(forms:)26 +b Fy(exec-epf)p FC(,)17 b Fy(&)p FC(,)j(and)g Fy(run)p +FC(.)365 3098 y Fy(\(exec-epf)40 b FB(.)21 b(epf)p Fy(\))86 +b Fu(\000)-14 b(!)87 b FB(no)21 b(r)o(eturn)g(value)1177 +b FC(syntax)365 3198 y Fy(\(&)43 b FB(.)21 b(epf)o Fy(\))87 +b Fu(\000)-14 b(!)87 b FB(pr)o(oc)1858 b FC(syntax)365 +3297 y Fy(\(run)42 b FB(.)21 b(epf)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(pr)o(oc)1771 b FC(syntax)573 3436 y(The)23 +b Fy(\(exec-epf)40 b(.)j FB(epf)p Fy(\))23 b FC(form)g(nukes)h(the)g +(curr)o(ent)e(pr)o(ocess:)30 b(it)24 b(establishes)f(the)573 +3536 y(i/o)c(r)o(edir)o(ections)f(and)h(then)g(overlays)g(the)f(curr)o +(ent)g(pr)o(ocess)h(with)g(the)g(r)o(equested)573 3636 +y(computation.)573 3767 y(The)d Fy(\(&)43 b(.)g FB(epf)p +Fy(\))15 b FC(form)i(is)f(similar)-6 b(,)17 b(except)e(that)i(the)f(pr) +o(ocess)g(is)g(forked)g(of)o(f)f(in)h(back-)573 3867 +y(gr)o(ound.)25 b(The)c(form)g(r)o(eturns)f(the)h(subpr)o(ocess')g(pr)o +(ocess)f(object.)573 3999 y(The)28 b Fy(\(run)42 b(.)h +FB(epf)p Fy(\))27 b FC(form)h(r)o(uns)h(the)f(pr)o(ocess)f(in)i(for)o +(egr)o(ound:)38 b(after)27 b(forking)h(of)o(f)573 4098 +y(the)f(computation,)i(it)e(waits)g(for)g(the)g(subpr)o(ocess)f(to)i +(exit,)g(and)e(r)o(eturns)g(its)i(exit)573 4198 y(status.)573 +4330 y(These)23 b(special)g(forms)g(ar)o(e)f(macr)o(os)h(that)g(expand) +f(into)j(the)e(equivalent)g(series)h(of)573 4429 y(system)31 +b(calls.)53 b(The)30 b(de\002nition)h(of)f(the)g Fy(exec-epf)d +FC(macr)o(o)j(is)g(non-trivial,)j(as)c(it)573 4529 y(pr)o(oduces)20 +b(the)i(code)f(to)h(handle)f(i/o)h(r)o(edir)o(ections)e(and)h(set)g(up) +h(pipelines.)27 b(How-)573 4628 y(ever)-6 b(,)19 b(the)i(de\002nitions) +h(of)f(the)g Fy(&)f FC(and)h Fy(run)e FC(macr)o(os)h(ar)o(e)g(very)g +(simple:)756 4769 y Fy(\(&)42 b(.)h FB(epf)p Fy(\))170 +b Fu(\021)83 b Fy(\(fork)41 b(\()p Fz(\025)e Fy(\(\))k(\(exec-epf)d(.)j +FB(epf)p Fy(\)\)\))756 4868 y(\(run)e(.)j FB(epf)o Fy(\))83 +b Fu(\021)g Fy(\(wait)41 b(\(&)i(.)g FB(epf)p Fy(\)\))1756 +5147 y FC(13)p eop +%%Page: 14 20 +14 19 bop 681 614 a FA(2.3.1)81 b(Procedures)19 b(and)h(special)f +(forms)681 931 y FC(It)33 b(is)g(a)f(general)g(design)i(principle)e(in) +i(scsh)f(that)g(all)g(functionality)g(made)f(available)681 +1030 y(thr)o(ough)25 b(special)e(syntax)i(is)f(also)h(available)e(in)i +(a)e(straightforwar)o(d)h(pr)o(ocedural)e(form.)681 1130 +y(So)f(ther)o(e)g(ar)o(e)f(pr)o(ocedural)g(equivalents)i(for)f(all)g +(of)h(the)g(pr)o(ocess)f(notation.)29 b(In)21 b(this)i(way)-9 +b(,)681 1229 y(the)25 b(pr)o(ogrammer)g(is)g(not)h(r)o(estricted)e(by)i +(the)f(particular)f(details)h(of)g(the)h(syntax.)39 b(Her)o(e)681 +1329 y(ar)o(e)19 b(some)i(of)g(the)g(syntax/pr)o(ocedur)o(e)e +(equivalents:)p 888 1562 1055 4 v 888 1661 4 100 v 941 +1632 a(Notation)172 b(Pr)o(ocedur)o(e)p 1940 1661 V 888 +1665 1055 4 v 888 1681 V 888 1781 4 100 v 941 1751 a +Fy(|)455 b(fork/pipe)p 1940 1781 V 888 1881 V 941 1851 +a(|+)411 b(fork/pipe+)p 1940 1881 V 888 1980 V 941 1950 +a(exec-epf)147 b(exec-path)p 1940 1980 V 888 2080 V 941 +2050 a FC(r)o(edir)o(ection)99 b Fy(open)p FC(,)19 b +Fy(dup)p 1940 2080 V 888 2179 V 941 2150 a(&)455 b(fork)p +1940 2179 V 888 2279 V 941 2249 a(run)367 b(wait)17 b +Fn(+)h Fy(fork)p 1940 2279 V 888 2282 1055 4 v 681 2549 +a FC(Having)e(a)g(solid)h(pr)o(ocedural)d(foundation)j(also)g(allows)f +(for)g(general)g(notational)h(experi-)681 2649 y(mentation)i(using)h +(Scheme's)f(macr)o(os.)24 b(For)19 b(example,)f(the)h(pr)o(ogrammer)f +(can)h(build)f(his)681 2748 y(own)g(pipeline)f(notation)h(on)g(top)f +(of)g(the)g Fy(fork)f FC(and)g Fy(fork/pipe)e FC(pr)o(ocedur)o(es.)22 +b(Chapter)17 b(3)681 2848 y(gives)k(the)g(full)f(story)i(on)f(all)g +(the)g(pr)o(ocedur)o(es)e(in)i(the)g(syscall)g(library)-9 +b(.)681 3359 y FA(2.3.2)81 b(Interfacing)19 b(process)h(output)g(to)g +(Scheme)681 3675 y FC(Ther)o(e)k(is)h(a)f(family)g(of)h(pr)o(ocedur)o +(es)e(and)h(special)h(forms)g(that)f(can)h(be)f(used)g(to)i(captur)o(e) +681 3775 y(the)21 b(output)g(of)g(pr)o(ocesses)f(as)g(Scheme)h(data.) +681 3992 y Fy(\(run/port)40 b FB(.)20 b(epf)p Fy(\))87 +b Fu(\000)-14 b(!)87 b FB(port)1558 b FC(syntax)681 4092 +y Fy(\(run/file)40 b FB(.)20 b(epf)p Fy(\))87 b Fu(\000)-14 +b(!)87 b FB(string)1494 b FC(syntax)681 4191 y Fy(\(run/string)39 +b FB(.)20 b(epf)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(string)1407 +b FC(syntax)681 4291 y Fy(\(run/strings)38 b FB(.)21 +b(epf)p Fy(\))87 b Fu(\000)-15 b(!)87 b FB(string)21 +b(list)1237 b FC(syntax)681 4391 y Fy(\(run/sexp)40 b +FB(.)20 b(epf)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(object)1505 +b FC(syntax)681 4490 y Fy(\(run/sexps)39 b FB(.)21 b(epf)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(list)1548 b FC(syntax)888 +4699 y(These)30 b(forms)g(all)g(fork)g(of)o(f)f(subpr)o(ocesses,)i +(collecting)g(the)f(pr)o(ocess')f(output)i(to)888 4799 +y(stdout)22 b(in)f(some)g(form)g(or)g(another)-6 b(.)25 +b(The)c(subpr)o(ocess)g(r)o(uns)g(with)h(\002le)e(descriptor)888 +4898 y(1)h(and)f(the)h(curr)o(ent)f(output)h(port)g(bound)g(to)g(a)f +(pipe.)2071 5147 y(14)p eop +%%Page: 15 21 +15 20 bop 805 636 a Fy(run/port)227 b FC(V)-8 b(alue)18 +b(is)h(a)f(port)g(open)h(on)f(pr)o(ocess's)g(stdout.)25 +b(Re-)1384 736 y(turns)d(immediately)e(after)g(forking)h(child.)805 +885 y Fy(run/file)227 b FC(V)-8 b(alue)22 b(is)f(name)h(of)f(a)g(temp)g +(\002le)h(containing)g(pr)o(o-)1384 985 y(cess's)f(output.)26 +b(Returns)c(when)f(pr)o(ocess)g(exits.)805 1134 y Fy(run/string)139 +b FC(V)-8 b(alue)21 b(is)g(a)f(string)i(containing)g(pr)o(ocess')e +(output.)1384 1234 y(Returns)i(when)f(eof)g(r)o(ead.)805 +1383 y Fy(run/strings)95 b FC(Splits)24 b(pr)o(ocess')f(output)g(into)h +(a)f(list)h(of)f(newline-)1384 1483 y(delimited)e(strings.)26 +b(Returns)c(when)f(eof)g(r)o(ead.)805 1632 y Fy(run/sexp)227 +b FC(Reads)33 b(a)g(single)g(object)h(fr)o(om)e(pr)o(ocess')h(stdout) +1384 1732 y(with)44 b Fy(read)p FC(.)88 b(Returns)44 +b(as)e(soon)h(as)f(the)h(r)o(ead)1384 1831 y(completes.)805 +1981 y Fy(run/sexps)183 b FC(Repeatedly)25 b(r)o(eads)f(objects)i(fr)o +(om)f(pr)o(ocess')g(std-)1384 2081 y(out)41 b(with)g +Fy(read)p FC(.)83 b(Returns)41 b(accumulated)f(list)1384 +2180 y(upon)22 b(eof.)609 2333 y(The)37 b(delimiting)g(newlines)g(ar)o +(e)e(not)i(included)g(in)f(the)h(strings)g(r)o(eturned)e(by)573 +2432 y Fy(run/strings)p FC(.)573 2561 y(These)17 b(special)g(forms)h +(just)g(expand)f(into)h(calls)f(to)h(the)f(following)i(analogous)f(pr)o +(o-)573 2661 y(cedur)o(es.)365 2840 y Fy(\(run/port*)40 +b FB(thunk)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(port)1321 +b FC(pr)o(ocedur)o(e)365 2939 y Fy(\(run/file*)40 b FB(thunk)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(string)1257 b FC(pr)o(ocedur)o(e)365 +3039 y Fy(\(run/string*)39 b FB(thunk)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(string)1170 b FC(pr)o(ocedur)o(e)365 3138 +y Fy(\(run/strings*)39 b FB(thunk)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(string)21 b(list)999 b FC(pr)o(ocedur)o(e)365 +3238 y Fy(\(run/sexp*)40 b FB(thunk)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(object)1268 b FC(pr)o(ocedur)o(e)365 3338 +y Fy(\(run/sexps*)39 b FB(thunk)p Fy(\))87 b Fu(\000)-14 +b(!)87 b FB(object)21 b(list)1097 b FC(pr)o(ocedur)o(e)573 +3471 y(For)21 b(example,)f Fy(\(run/port)40 b(.)j FB(epf)p +Fy(\))20 b FC(expands)g(into)756 3609 y Fy(\(run/port*)39 +b(\()p Fz(\025)g Fy(\(\))j(\(exec-epf)e(.)j FB(epf)p +Fy(\)\)\).)490 3827 y FC(The)35 b(following)i(pr)o(ocedur)o(es)d(ar)o +(e)g(also)i(of)f(utility)i(for)e(generally)g(parsing)h(input)365 +3927 y(str)o(eams)20 b(in)i(scsh:)365 4068 y Fy(\(port->string)39 +b FB(port)p Fy(\))86 b Fu(\000)-15 b(!)88 b FB(string)1186 +b FC(pr)o(ocedur)o(e)365 4167 y Fy(\(port->sexp-list)37 +b FB(port)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(list)1153 +b FC(pr)o(ocedur)o(e)365 4267 y Fy(\(port->string-lis)o(t)37 +b FB(port)p Fy(\))87 b Fu(\000)-15 b(!)87 b FB(string)21 +b(list)842 b FC(pr)o(ocedur)o(e)365 4367 y Fy(\(port->list)39 +b FB(r)o(eader)21 b(port)p Fy(\))86 b Fu(\000)-14 b(!)87 +b FB(list)1144 b FC(pr)o(ocedur)o(e)573 4500 y Fy(Port->string)32 +b FC(r)o(eads)37 b(the)g(port)h(until)g(eof,)k(then)c(r)o(eturns)f(the) +h(accumulated)573 4599 y(string.)46 b Fy(Port->sexp-list)21 +b FC(r)o(epeatedly)k(r)o(eads)h(data)g(fr)o(om)h(the)h(port)f(until)h +(eof,)573 4699 y(then)g(r)o(eturns)f(the)h(accumulated)e(list)j(of)e +(items.)47 b Fy(Port->string-lis)o(t)22 b FC(r)o(epeat-)573 +4799 y(edly)30 b(r)o(eads)f(newline-terminated)h(strings)h(fr)o(om)f +(the)g(port)h(until)g(eof,)h(then)f(r)o(e-)573 4898 y(turns)h(the)f +(accumulated)f(list)i(of)g(strings.)58 b(The)31 b(delimiting)i +(newlines)f(ar)o(e)e(not)1756 5147 y(15)p eop +%%Page: 16 22 +16 21 bop 888 614 a FC(part)39 b(of)h(the)g(r)o(eturned)e(strings.)83 +b Fy(Port->list)35 b FC(generalises)40 b(these)g(two)g(pr)o(o-)888 +714 y(cedur)o(es.)70 b(It)35 b(uses)h FB(r)o(eader)g +FC(to)g(r)o(epeatedly)e(r)o(ead)g(objects)j(fr)o(om)e(a)h(port.)70 +b(It)36 b(ac-)888 814 y(cumulates)h(these)h(objects)f(into)h(a)f(list,) +k(which)d(is)f(r)o(eturned)f(upon)i(eof.)74 b(The)888 +913 y Fy(port->string-list)20 b FC(and)26 b Fy(port->sexp-list)21 +b FC(pr)o(ocedur)o(es)k(ar)o(e)g(trivial)i(to)g(de-)888 +1013 y(\002ne,)21 b(being)g(mer)o(ely)f Fy(port->list)d +FC(curried)j(with)i(the)e(appr)o(opriate)f(parsers:)1071 +1212 y Fy(\(port->string-li)o(st)37 b FB(port)o Fy(\))44 +b Fu(\021)f Fy(\(port->list)c(read-line)h FB(port)o Fy(\))1071 +1312 y(\(port->sexp-list)124 b FB(port)o Fy(\))44 b Fu(\021)f +Fy(\(port->list)c(read)j FB(port)o Fy(\))888 1512 y FC(The)21 +b(following)h(compositions)h(also)e(hold:)1071 1711 y +Fy(run/string*)126 b Fu(\021)87 b Fy(port->string)256 +b Fu(\016)44 b Fy(run/port*)1071 1811 y(run/strings*)82 +b Fu(\021)87 b Fy(port->string-lis)o(t)37 b Fu(\016)44 +b Fy(run/port*)1071 1910 y(run/sexp*)214 b Fu(\021)87 +b Fy(read)608 b Fu(\016)44 b Fy(run/port*)1071 2010 y(run/sexps*)170 +b Fu(\021)87 b Fy(port->sexp-list)124 b Fu(\016)44 b +Fy(run/port*)681 2376 y(\(reduce-port)38 b FB(port)20 +b(r)o(eader)h(op)f(.)h(seeds)p Fy(\))87 b Fu(\000)-14 +b(!)87 b FB(object)2488 2346 y Fm(\003)3170 2376 y FC(pr)o(ocedur)o(e) +888 2534 y(This)28 b(pr)o(ocedur)o(e)d(can)h(be)h(used)f(to)i(perform)e +(a)h(variety)f(of)h(iterative)f(operations)888 2633 y(over)32 +b(an)f(input)h(str)o(eam.)57 b(It)32 b(r)o(epeatedly)d(uses)j +FB(r)o(eader)f FC(to)h(r)o(ead)e(an)i(object)f(fr)o(om)888 +2733 y FB(port)p FC(.)40 b(If)25 b(the)h(\002rst)g(r)o(ead)e(r)o +(eturns)h(eof,)h(then)g(the)g(entir)o(e)f Fy(reduce-port)c +FC(operation)888 2833 y(r)o(eturns)28 b(the)g(seeds)g(as)g(multiple)h +(values.)48 b(If)28 b(the)g(\002rst)h(r)o(ead)d(operation)j(r)o(eturns) +888 2932 y(some)20 b(other)g(value)e Fz(v)s FC(,)i(then)g +FB(op)e FC(is)i(applied)e(to)i Fz(v)j FC(and)18 b(the)i(seeds:)k +Fy(\()p FB(op)43 b(v)g Fy(.)g FB(seeds)q Fy(\))p FC(.)888 +3032 y(This)18 b(should)g(r)o(eturn)f(a)f(new)i(set)f(of)g(seed)g +(values,)g(and)g(the)g(r)o(eduction)g(then)g(loops,)888 +3132 y(r)o(eading)k(a)f(new)i(value)f(fr)o(om)g(the)g(port,)g(and)g(so) +h(forth.)27 b(\(If)21 b(multiple)h(seed)e(values)888 +3231 y(ar)o(e)g(used,)g(then)h FB(op)f FC(must)i(r)o(eturn)e(multiple)h +(values.\))888 3381 y(For)g(example,)f Fy(\(port->list)39 +b FB(r)o(eader)44 b(port)o Fy(\))20 b FC(could)h(be)g(de\002ned)f(as) +1071 3559 y Fy(\(reverse)40 b(\(reduce-port)f FB(port)k(r)o(eader)g +Fy(cons)f('\(\)\)\))888 3786 y FC(An)25 b(imperative)f(way)g(to)h(look) +g(at)f Fy(reduce-port)c FC(is)25 b(to)g(say)f(that)h(it)f(abstracts)g +(the)888 3886 y(idea)k(of)h(a)f(loop)h(over)g(a)f(str)o(eam)f(of)i +(values)f(r)o(ead)f(fr)o(om)h(some)h(port,)i(wher)o(e)d(the)888 +3986 y(seed)21 b(values)f(expr)o(ess)g(the)h(loop)g(state.)681 +4352 y Fw(2.4)99 b(More)24 b(complex)h(process)h(operations)681 +4599 y FC(The)21 b(pr)o(ocedur)o(es)e(and)h(special)g(forms)h(in)h(the) +f(pr)o(evious)f(section)h(pr)o(ovide)f(for)h(the)g(com-)681 +4699 y(mon)27 b(case,)h(wher)o(e)e(the)g(pr)o(ogrammer)g(is)h(only)h +(inter)o(ested)d(in)j(the)e(output)h(of)g(the)g(pr)o(o-)681 +4799 y(cess.)37 b(These)24 b(special)g(forms)h(and)f(pr)o(ocedur)o(es)f +(pr)o(ovide)h(mor)o(e)g(complicated)g(facilities)681 +4898 y(for)c(manipulating)i(pr)o(ocesses.)2071 5147 y(16)p +eop +%%Page: 17 23 +17 22 bop 365 614 a FA(2.4.1)81 b(Pids)20 b(and)g(ports)g(together)365 +828 y Fy(\(run/port+proc)38 b FB(.)21 b(epf)o Fy(\))87 +b Fu(\000)-14 b(!)87 b FB([port)20 b(pr)o(oc])1120 b +FC(syntax)365 928 y Fy(\(run/port+proc*)38 b FB(thunk)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB([port)20 b(pr)o(oc])883 +b FC(pr)o(ocedur)o(e)573 1054 y(This)32 b(special)f(form)h(and)f(its)h +(analogous)g(pr)o(ocedur)o(e)e(can)h(be)g(used)g(if)h(the)f(pr)o(o-)573 +1154 y(grammer)26 b(also)h(wishes)g(access)f(to)h(the)g(pr)o(ocess')f +(pid,)i(exit)e(status,)i(or)f(other)f(in-)573 1253 y(formation.)k(They) +22 b(both)g(fork)g(of)o(f)f(a)h(subpr)o(ocess,)g(r)o(eturning)g(two)g +(values:)28 b(a)21 b(port)573 1353 y(open)28 b(on)g(the)f(pr)o(ocess')h +(stdout)g(\(and)e(curr)o(ent)h(output)h(port\),)h(and)e(the)g(subpr)o +(o-)573 1452 y(cess's)d(pr)o(ocess)f(object.)35 b(A)23 +b(pr)o(ocess)g(object)h(encapsulates)f(the)h(subpr)o(ocess')f(pr)o(o-) +573 1552 y(cess)e(id)f(and)h(exit)f(code;)g(it)h(is)g(the)g(value)g +(passed)f(to)h(the)g Fy(wait)e FC(system)i(call.)573 +1689 y(For)34 b(example,)i(to)e(uncompr)o(ess)g(a)f(tech)h(r)o(eport,)h +(r)o(eading)e(the)h(uncompr)o(essed)573 1788 y(data)21 +b(into)i(scsh,)g(and)f(also)g(be)g(able)f(to)i(track)f(the)g(exit)g +(status)g(of)g(the)h(decompr)o(es-)573 1888 y(sion)f(pr)o(ocess,)e(use) +g(the)h(following:)756 2062 y Fy(\(receive)40 b(\(port)h(child\))g +(\(run/port+proc)d(\(zcat)k(tr91-145.tex.Z\))o(\))843 +2161 y(\(let*)f(\(\(paper)g(\(port->string)d(port\)\))1148 +2261 y(\(status)i(\(wait)i(child\)\)\))930 2361 y FC(.)12 +b(.)g(.)g(use)21 b Fy(paper)p FC(,)e Fy(status)p FC(,)f(and)i +Fy(child)f FC(her)o(e.)12 b(.)g(.)g Fy(\)\))573 2535 +y FC(Note)23 b(that)g(you)g(must)h FB(\002rst)f FC(do)g(the)g +Fy(port->string)18 b FC(and)k FB(then)g FC(do)h(the)g(wait\227the)573 +2634 y(other)33 b(way)f(ar)o(ound)g(may)h(lock)g(up)g(when)g(the)g +(zcat)f(\002lls)h(up)g(its)g(output)g(pipe)573 2734 y(buf)o(fer)-6 +b(.)365 3018 y FA(2.4.2)81 b(Multiple)19 b(stream)g(capture)365 +3209 y FC(Occasionally)-9 b(,)46 b(the)40 b(pr)o(ogrammer)g(may)h(want) +f(to)h(captur)o(e)e(multiple)i(distinct)g(out-)365 3308 +y(put)35 b(str)o(eams)e(fr)o(om)h(a)g(pr)o(ocess.)66 +b(For)35 b(instance,)i(he)e(may)f(wish)h(to)g(r)o(ead)e(the)h(stdout) +365 3408 y(and)e(stderr)g(str)o(eams)g(into)h(two)g(distinct)g +(strings.)61 b(This)33 b(is)g(accomplished)f(with)h(the)365 +3508 y Fy(run/collecting)15 b FC(form)21 b(and)f(its)i(analogous)f(pr)o +(ocedur)o(e,)d Fy(run/collecting*)p FC(.)365 3661 y Fy +(\(run/collecting)38 b FB(fds)20 b(.)h(epf)11 b Fy(\))87 +b Fu(\000)-15 b(!)88 b FB([port.)12 b(.)g(.)g(])1012 +b FC(syntax)365 3761 y Fy(\(run/collecting*)37 b FB(fds)21 +b(thunk)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB([port.)12 +b(.)g(.)g(])787 b FC(pr)o(ocedur)o(e)573 3906 y Fy(Run/collecting)15 +b FC(and)21 b Fy(run/collecting*)16 b FC(r)o(un)22 b(pr)o(ocesses)f +(that)g(pr)o(oduce)f(mul-)573 4005 y(tiple)28 b(output)h(str)o(eams)e +(and)h(r)o(eturn)g(ports)g(open)h(on)g(these)f(str)o(eams.)47 +b(T)-8 b(o)29 b(avoid)573 4105 y(issues)h(of)g(deadlock,)h +Fy(run/collecting)24 b FC(doesn't)30 b(use)g(pipes.)53 +b(Instead,)31 b(it)f(\002rst)573 4205 y(r)o(uns)19 b(the)g(pr)o(ocess)f +(with)h(output)g(to)g(temp)g(\002les,)g(then)g(r)o(eturns)f(ports)g +(open)h(on)g(the)573 4304 y(temp)i(\002les.)k(For)d(example,)756 +4452 y Fy(\(run/collecting)37 b(\(1)43 b(2\))f(\(ls\)\))573 +4599 y FC(r)o(uns)23 b Fy(ls)e FC(with)i(stdout)g(\(fd)e(1\))g(and)h +(stderr)f(\(fd)g(2\))h(r)o(edir)o(ected)d(to)k(temporary)e(\002les.)573 +4699 y(When)26 b(the)g Fy(ls)f FC(is)h(done,)h Fy(run/collecting)20 +b FC(r)o(eturns)25 b(thr)o(ee)g(values:)35 b(the)26 b +Fy(ls)f FC(pr)o(o-)573 4799 y(cess')31 b(exit)g(status,)j(and)d(two)h +(ports)g(open)f(on)h(the)g(temporary)e(\002les.)58 b(The)31 +b(\002les)573 4898 y(ar)o(e)17 b(deleted)h(befor)o(e)g +Fy(run/collecting)13 b FC(r)o(eturns,)19 b(so)g(when)h(the)f(ports)g +(ar)o(e)f(closed,)1756 5147 y(17)p eop +%%Page: 18 24 +18 23 bop 888 614 a FC(they)28 b(vanish.)45 b(The)27 +b Fy(fds)f FC(list)i(of)g(\002le)f(descriptors)g(is)h(implicitly)g +(backquoted)f(by)888 714 y(the)21 b(special-form)f(version.)888 +914 y(For)h(example,)f(if)h(Kaiming)g(has)g(his)h(mailbox)f(pr)o +(otected,)e(then)1071 1214 y Fy(\(receive)40 b(\(status)h(out)h(err\)) +1463 1313 y(\(run/collecting)c(\(1)k(2\))h(\(cat)f(/usr/kmshea/mbox)o +(\)\))1158 1413 y(\(list)g(status)f(\(port->string)d(out\))k +(\(port->string)c(err\)\)\))888 1713 y FC(might)22 b(pr)o(oduce)e(the)h +(list)1071 2008 y Fy(\(256)42 b("")h("cat:)e(/usr/kmshea/mbox:)c +(Permission)i(denied"\))888 2404 y FC(What)31 b(is)h(the)f(deadlock)g +(hazar)o(d)e(that)i(causes)g Fy(run/collecting)25 b FC(to)32 +b(use)f(temp)888 2504 y(\002les?)63 b(Pr)o(ocesses)32 +b(with)i(multiple)f(output)g(str)o(eams)g(can)f(lock)h(up)g(if)g(they)g +(use)888 2603 y(pipes)28 b(to)f(communicate)h(with)g(Scheme)f(i/o)h(r)o +(eaders.)43 b(For)28 b(example,)g(suppose)888 2703 y(some)22 +b(Unix)e(pr)o(ogram)g Fy(myprog)f FC(does)h(the)h(following:)967 +3003 y(1.)41 b(First,)21 b(outputs)g(a)g(single)g(\223)p +Fy(\()p FC(\224)e(to)j(stderr)-6 b(.)967 3203 y(2.)41 +b(Then,)21 b(outputs)g(a)f(megabyte)h(of)g(data)e(to)i(stdout.)967 +3402 y(3.)41 b(Finally)-9 b(,)21 b(outputs)g(a)g(single)g(\223)p +Fy(\))p FC(\224)e(to)j(stderr)-6 b(,)19 b(and)i(exits.)888 +3702 y(Our)e(scsh)h(pr)o(ogrammer)e(decides)g(to)i(r)o(un)f +Fy(myprog)d FC(with)k(stdout)g(and)e(stderr)g(r)o(edi-)888 +3802 y(r)o(ected)23 b FB(via)g(Unix)g(pipes)h FC(to)g(the)g(ports)h +Fy(port1)c FC(and)j Fy(port2)p FC(,)e(r)o(espectively)-9 +b(.)34 b(He)24 b(gets)888 3902 y(into)19 b(tr)o(ouble)f(when)h(he)f +(subsequently)h(says)f Fy(\(read)42 b(port2\))p FC(.)22 +b(The)c(Scheme)g Fy(read)888 4001 y FC(r)o(outine)h(r)o(eads)f(the)h +(open)g(par)o(en,)f(and)g(then)i(hangs)f(in)g(a)g Fy(read\(\))d +FC(system)k(call)e(try-)888 4101 y(ing)31 b(to)f(r)o(ead)d(a)i +(matching)i(close)f(par)o(en.)50 b(But)30 b(befor)o(e)e +Fy(myprog)f FC(sends)j(the)g(close)888 4200 y(par)o(en)d(down)h(the)f +(stderr)g(pipe,)i(it)e(\002rst)h(tries)g(to)f(write)h(a)f(megabyte)g +(of)g(data)g(to)888 4300 y(the)j(stdout)h(pipe.)53 b(However)-6 +b(,)31 b(Scheme)f(is)g(not)h(r)o(eading)e(that)h(pipe\227it's)g(stuck) +888 4400 y(waiting)37 b(for)f(input)g(on)h(stderr)-6 +b(.)71 b(So)36 b(the)g(stdout)g(pipe)g(quickly)h(\002lls)g(up,)i(and) +888 4499 y Fy(myprog)26 b FC(hangs,)k(waiting)f(for)f(the)g(pipe)g(to)h +(drain.)47 b(The)28 b Fy(myprog)e FC(child)i(is)h(stuck)888 +4599 y(in)i(a)e(stdout/)p Fy(port1)g FC(write;)35 b(the)30 +b(Scheme)g(par)o(ent)f(is)h(stuck)g(in)h(a)e(stderr/)p +Fy(port2)888 4699 y FC(r)o(ead.)24 b(Deadlock.)888 4898 +y(Her)o(e's)c(a)h(concr)o(ete)f(example)g(that)g(does)h(exactly)f(the)h +(above:)2071 5147 y(18)p eop +%%Page: 19 25 +19 24 bop 756 614 a Fy(\(receive)40 b(\(status)g(port1)i(port2\))1148 +714 y(\(run/collecting)37 b(\(1)43 b(2\))1322 814 y(\(begin)1409 +913 y(;;)g(Write)f(an)g(open)g(paren)g(to)h(stderr.)1409 +1013 y(\(run)f(\(echo)g("\("\))g(\(=)g(1)i(2\)\))1409 +1112 y(;;)f(Copy)f(a)h(lot)f(of)h(stuff)f(to)h(stdout.)1409 +1212 y(\(run)f(\(cat)g(/usr/dict/words\)\))1409 1312 +y(;;)h(Write)f(a)h(close)e(paren)h(to)h(stderr.)1409 +1411 y(\(run)f(\(echo)g("\)"\))g(\(=)g(1)i(2\)\)\)\))886 +1611 y(;;)f(OK.)f(Here,)g(I)h(have)f(a)h(port)f(PORT1)g(built)f(over)h +(a)h(pipe)886 1710 y(;;)g(connected)d(to)j(the)f(BEGIN)f(subproc's)f +(stdout,)h(and)886 1810 y(;;)i(PORT2)f(built)f(over)h(a)h(pipe)f +(connected)e(to)j(the)f(BEGIN)886 1910 y(;;)h(subproc's)d(stderr.)886 +2009 y(\(read)i(port2\))f(;)i(Should)e(return)g(the)i(empty)e(list.)886 +2109 y(\(port->string)d(port1\)\))j(;)i(Should)e(return)h(a)h(big)f +(string.)573 2291 y FC(In)29 b(or)o(der)e(to)i(avoid)f(this)h(pr)o +(oblem,)h Fy(run/collecting)23 b FC(and)28 b Fy(run/collecting*)573 +2391 y FC(\002rst)20 b(r)o(un)h(the)f(child)h(pr)o(ocess)e(to)i +(completion,)g(buf)o(fering)e(all)h(the)h(output)f(str)o(eams)573 +2490 y(in)c(temp)h(\002les)f(\(using)h(the)f Fy(temp-file-channel)9 +b FC(pr)o(ocedur)o(e,)15 b(see)h(below\).)24 b(When)573 +2590 y(the)j(child)g(pr)o(ocess)g(exits,)h(ports)f(open)g(on)h(the)f +(buf)o(fer)o(ed)d(output)k(ar)o(e)d(r)o(eturned.)573 +2689 y(This)c(appr)o(oach)f(has)g(two)i(disadvantages)d(over)i(using)g +(pipes:)672 2872 y Fu(\017)42 b FC(The)21 b(total)i(output)f(fr)o(om)g +(the)g(child)g(output)g(is)h(temporarily)f(written)g(to)g(the)756 +2971 y(disk)j(befor)o(e)f(r)o(eturning)g(fr)o(om)h Fy(run/collecting)p +FC(.)33 b(If)24 b(this)i(output)g(is)f(some)756 3071 +y(lar)o(ge)19 b(intermediate)h(r)o(esult,)g(the)h(disk)g(could)g +(\002ll)g(up.)672 3212 y Fu(\017)42 b FC(The)20 b(child)i(pr)o(oducer)d +(and)i(Scheme)g(consumer)g(ar)o(e)f(serialised;)g(ther)o(e)h(is)g(no) +756 3311 y(concurr)o(ency)f(overlap)g(in)h(their)g(execution.)573 +3493 y(However)-6 b(,)46 b(it)c(r)o(emains)g(a)f(simple)h(solution)i +(that)d(avoids)h(deadlock.)88 b(Mor)o(e)573 3593 y(sophisticated)50 +b(solutions)i(can)e(easily)g(be)g(pr)o(ogrammed)f(up)h(as)f(needed\227) +573 3693 y Fy(run/collecting*)14 b FC(itself)21 b(is)g(only)h(12)e +(lines)h(of)g(simple)g(code.)573 3834 y(See)27 b Fy(temp-file-channel) +21 b FC(for)28 b(mor)o(e)g(information)i(on)f(cr)o(eating)e(temp)h +(\002les)h(as)573 3933 y(communication)22 b(channels.)365 +4262 y Fw(2.5)99 b(Conditional)26 b(process)g(sequencing)f(forms)365 +4492 y FC(These)c(forms)g(allow)g(conditional)h(execution)f(of)g(a)f +(sequence)h(of)g(pr)o(ocesses.)365 4649 y Fy(\(||)43 +b FB(pf)604 4677 y Fv(1)662 4649 y FB(.)12 b(.)g(.)g(pfn)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(boolean)1514 b FC(syntax)573 +4799 y(Run)21 b(each)f(pr)o(oc)f(until)j(one)e(completes)h +(successfully)g(\()p FB(i.e.)o FC(,)f(exit)g(status)h(zer)o(o\).)j(Re-) +573 4898 y(turn)d(tr)o(ue)g(if)f(some)i(pr)o(oc)e(completes)h +(successfully;)g(otherwise)g Fy(#f)p FC(.)1756 5147 y(19)p +eop +%%Page: 20 26 +20 25 bop 681 614 a Fy(\(&&)42 b FB(pf)920 641 y Fv(1)978 +614 y FB(.)12 b(.)g(.)g(pfn)p Fy(\))87 b Fu(\000)-14 +b(!)87 b FB(boolean)1514 b FC(syntax)888 756 y(Run)23 +b(each)f(pr)o(oc)g(until)h(one)g(fails)e(\()p FB(i.e.)p +FC(,)h(exit)h(status)f(non-zer)o(o\).)29 b(Return)23 +b(tr)o(ue)f(if)g(all)888 855 y(pr)o(ocs)f(complete)g(successfully;)f +(otherwise)i Fy(#f)p FC(.)681 1149 y Fw(2.6)99 b(Process)25 +b(\002lters)681 1363 y FC(These)20 b(pr)o(ocedur)o(es)f(ar)o(e)h +(useful)g(for)h(forking)g(of)o(f)f(pr)o(ocesses)g(to)i(\002lter)e(text) +h(str)o(eams.)681 1513 y Fy(\(char-filter)38 b FB(\002lter)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(pr)o(ocedur)o(e)1085 +b FC(pr)o(ocedur)o(e)888 1654 y(The)27 b FB(\002lter)h +FC(ar)o(gument)e(is)i(a)f(character)p Fu(!)p FC(character)d(pr)o +(ocedur)o(e.)42 b(Returns)28 b(a)f(pr)o(o-)888 1753 y(cedur)o(e)h(that) +h(when)h(called,)g(r)o(epeatedly)e(r)o(eads)f(a)i(character)f(fr)o(om)h +(the)g(curr)o(ent)888 1853 y(input)23 b(port,)g(applies)f +FB(\002lter)h FC(to)g(the)f(character)-6 b(,)21 b(and)h(writes)h(the)g +(r)o(esult)f(to)h(the)f(cur)o(-)888 1953 y(r)o(ent)i(output)g(port.)36 +b(The)24 b(pr)o(ocedur)o(e)e(r)o(eturns)h(upon)i(r)o(eaching)e(eof)h +(on)g(the)h(input)888 2052 y(port.)888 2185 y(For)j(example,)f(to)h +(downcase)f(a)f(str)o(eam)h(of)g(text)g(in)g(a)g(spell-checking)g +(pipeline,)888 2285 y(instead)21 b(of)g(using)g(the)g(Unix)g +Fy(tr)43 b(A-Z)f(a-z)19 b FC(command,)i(we)g(can)f(say:)1071 +2451 y Fy(\(run)42 b(\(|)h(\(delatex\))1420 2550 y(\(begin)e +(\(\(char-filter)d(char-downcase\)\)\))f(;)43 b(tr)g(A-Z)f(a-z)1420 +2650 y(\(spell\))1420 2750 y(\(sort\))1420 2849 y(\(uniq\)\))1289 +2949 y(\(<)h(scsh.tex\))1289 3049 y(\(>)g(spell-errors.tx)o(t\)\))681 +3422 y(\(string-filter)38 b FB(\002lter)20 b([bu\003en])p +Fy(\))88 b Fu(\000)-14 b(!)87 b FB(pr)o(ocedur)o(e)713 +b FC(pr)o(ocedur)o(e)888 3563 y(The)30 b FB(\002lter)g +FC(ar)o(gument)f(is)h(a)f(string)p Fu(!)p FC(string)i(pr)o(ocedur)o(e.) +50 b(Returns)30 b(a)f(pr)o(ocedur)o(e)888 3663 y(that)e(when)g(called,) +f(r)o(epeatedly)f(r)o(eads)g(a)g(string)i(fr)o(om)f(the)h(curr)o(ent)e +(input)i(port,)888 3763 y(applies)18 b FB(\002lter)h +FC(to)g(the)f(string,)i(and)e(writes)h(the)f(r)o(esult)g(to)h(the)g +(curr)o(ent)e(output)i(port.)888 3862 y(The)i(pr)o(ocedur)o(e)e(r)o +(eturns)h(upon)h(r)o(eaching)g(eof)f(on)h(the)g(input)h(port.)888 +3995 y(The)i(optional)g FB(bu\003en)h FC(ar)o(gument)e(contr)o(ols)h +(the)g(number)f(of)h(characters)e(each)h(in-)888 4095 +y(ternal)c(r)o(ead)e(operation)i(r)o(equests;)g(this)h(means)f(that)g +FB(\002lter)g FC(will)h(never)e(be)h(applied)888 4194 +y(to)i(a)g(string)g(longer)g(than)g FB(bu\003en)i FC(chars.)i(The)20 +b(default)g FB(bu\003en)i FC(value)e(is)h(1024.)2071 +5147 y(20)p eop +%%Page: 21 27 +21 26 bop 365 1276 a Fx(Chapter)45 b(3)365 1731 y FD(System)51 +b(Calls)365 2226 y FC(Scsh)24 b(pr)o(ovides)f(\(almost\))g(complete)g +(access)g(to)h(the)g(basic)f(Unix)g(kernel)h(services:)30 +b(pr)o(o-)365 2326 y(cesses,)18 b(\002les,)h(signals)f(and)f(so)h +(forth.)25 b(These)17 b(pr)o(ocedur)o(es)f(comprise)i(a)f(Scheme)g +(binding)365 2426 y(for)j(P)t Ft(O)t(S)t(I)t(X)r FC(,)g(with)g(a)d(few) +h(of)h(the)f(mor)o(e)g(standar)o(d)f(extensions)i(thr)o(own)g(in)g(\()p +FB(e.g.)o FC(,)f(symbolic)365 2525 y(links,)k Fy(fchown)p +FC(,)c Fy(fstat)p FC(,)g(sockets\).)365 2840 y Fw(3.1)99 +b(Errors)365 3073 y FC(Scsh)24 b(syscalls)g(never)f(r)o(eturn)g(err)o +(or)g(codes,)h(and)f(do)h(not)g(use)g(a)f(global)h Fy(errno)e +FC(variable)365 3173 y(to)29 b(r)o(eport)e(err)o(ors.)47 +b(Err)o(ors)27 b(ar)o(e)f(consistently)k(r)o(eported)d(by)h(raising)g +(exceptions.)48 b(This)365 3272 y(fr)o(ees)19 b(up)i(the)f(pr)o(ocedur) +o(es)f(to)i(r)o(eturn)e(useful)h(values,)g(and)g(allows)h(the)g(pr)o +(ogrammer)e(to)365 3372 y(assume)26 b(that)g FB(if)f(a)h(syscall)g(r)o +(eturns,)h(it)e(succeeded.)40 b FC(This)27 b(gr)o(eatly)d(simpli\002es) +j(the)f(\003ow)h(of)365 3472 y(the)21 b(code)g(fr)o(om)f(the)h(pr)o +(ogrammer)6 b('s)20 b(point)i(of)e(view)-8 b(.)490 3611 +y(Since)20 b(Scheme)g(does)h(not)g(yet)f(have)g(a)g(standar)o(d)f +(exception)i(system,)g(the)f(scsh)h(de\002-)365 3710 +y(nition)d(r)o(emains)f(somewhat)g(vague)f(on)h(the)g(actual)f(form)h +(of)f(exceptions)h(and)g(exception)365 3810 y(handlers.)39 +b(When)26 b(a)f(standar)o(d)e(exception)i(system)h(is)g(de\002ned,)g +(scsh)f(will)h(move)g(to)g(it.)365 3910 y(For)21 b(now)-8 +b(,)21 b(scsh)g(uses)f(the)g(Scheme)g(48)f(exception)h(system,)h(with)g +(a)f(simple)g(sugaring)h(on)365 4009 y(top)g(to)g(hide)g(the)g(details) +f(in)i(the)f(common)h(case.)490 4148 y(System)27 b(call)f(err)o(or)g +(exceptions)h(contain)h(the)f(Unix)g Fy(errno)d FC(code)j(r)o(eported)e +(by)i(the)365 4248 y(system)21 b(call.)j(Unlike)c(C,)g(the)f +Fy(errno)f FC(value)h(is)h(a)f(part)g(of)h(the)f(exception)h(packet,)f +(it)h(is)g FB(not)365 4348 y FC(accessed)g(thr)o(ough)h(a)g(global)g +(variable.)490 4487 y(For)e(r)o(efer)o(ence)e(purposes,)i(the)h(Unix)f +Fy(errno)e FC(numbers)i(ar)o(e)f(bound)i(to)f(the)h(variables)365 +4586 y Fy(errno/perm)p FC(,)30 b Fy(errno/noent)p FC(,)f +FB(etc.)56 b FC(System)31 b(calls)g(never)g(r)o(eturn)f +Fy(error/intr)p FC(\227they)365 4686 y(automatically)21 +b(r)o(etry)-9 b(.)365 4845 y Fy(\(errno-error)39 b FB(errno)22 +b(syscall)e(.)h(data)p Fy(\))85 b Fu(\000)-14 b(!)87 +b FB(no)21 b(r)o(eturn)g(value)423 b FC(pr)o(ocedur)o(e)1756 +5147 y(21)p eop +%%Page: 22 28 +22 27 bop 888 614 a FC(Raises)30 b(a)f(Unix)h(err)o(or)e(exception)i +(for)f(Unix)h(err)o(or)e(number)i FB(errno)q FC(.)52 +b(The)29 b FB(syscall)888 714 y FC(and)f FB(data)f FC(ar)o(guments)g +(ar)o(e)g(packaged)g(up)h(in)g(the)g(exception)g(packet)f(passed)h(to) +888 814 y(the)21 b(exception)g(handler)-6 b(.)681 1065 +y Fy(\(with-errno-hand)o(le)o(r*)37 b FB(handler)21 b(thunk)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(value\(s\))20 b(of)h(thunk)181 +b FC(pr)o(ocedur)o(e)681 1164 y Fy(\(with-errno-hand)o(le)o(r)38 +b FB(handler-spec)20 b(.)g(body)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(value)21 b(of)f(body)318 b FC(syntax)888 +1310 y(Unix)30 b(syscalls)g(raise)f(err)o(or)g(exceptions)h(by)g +(calling)g Fy(errno-error)p FC(.)47 b(Pr)o(ograms)888 +1410 y(can)20 b(use)f Fy(with-errno-handle)o(r*)13 b +FC(to)20 b(establish)g(handlers)f(for)g(these)h(exceptions.)888 +1548 y(If)29 b(a)g(Unix)h(err)o(or)e(arises)h(while)h +FB(thunk)f FC(is)h(executing,)h FB(handler)e FC(is)h(called)e(on)i(two) +888 1647 y(ar)o(guments:)1071 1798 y Fy(\()p FB(handler)43 +b(errno)h(packet)o Fy(\))888 1948 y FB(packet)20 b FC(is)h(a)f(list)i +(of)f(the)f(form)1559 2136 y FB(packet)i Fn(=)g Fy(\()p +FB(errno-msg)43 b(syscall)h Fy(.)f FB(data)o Fy(\))p +Fz(;)888 2324 y FC(wher)o(e)24 b FB(errno-msg)g FC(is)h(the)f(standar)o +(d)f(Unix)h(err)o(or)g(message)g(for)g(the)g(err)o(or)-6 +b(,)24 b FB(syscall)888 2423 y FC(is)e(the)g(pr)o(ocedur)o(e)d(that)j +(generated)e(the)i(err)o(or)-6 b(,)20 b(and)h FB(data)g +FC(is)h(a)f(list)h(of)f(information)888 2523 y(generated)f(by)h(the)g +(err)o(or)-6 b(,)19 b(which)j(varies)e(fr)o(om)g(syscall)h(to)g +(syscall.)888 2661 y(If)32 b FB(handler)g FC(r)o(eturns,)j(the)d +(handler)g(sear)o(ch)f(continues)i(upwar)o(ds.)59 b FB(Handler)32 +b FC(can)888 2761 y(acquir)o(e)23 b(the)g(exception)g(by)h(invoking)h +(a)d(saved)h(continuation.)34 b(This)24 b(pr)o(ocedur)o(e)888 +2860 y(can)d(be)f(sugar)o(ed)g(over)g(with)i(the)f(following)h(syntax:) +1071 3036 y Fy(\(with-errno-hand)o(ler)1245 3136 y(\(\()p +FB(errno)44 b(packet)o Fy(\))f FB(clause)h Fy(...\))1158 +3236 y FB(body1)1158 3335 y(body2)1158 3435 y Fy(...\))888 +3611 y FC(This)31 b(form)g(executes)e(the)i(body)g(forms)f(with)h(a)f +(particular)g(errno)g(handler)g(in-)888 3711 y(stalled.)65 +b(When)34 b(an)g(errno)g(err)o(or)f(is)h(raised,)i(the)e(handler)g +(sear)o(ch)f(machinery)888 3810 y(will)f(bind)e(variable)f +FB(errno)j FC(to)f(the)f(err)o(or)6 b('s)30 b(integer)h(code,)h(and)e +(variable)f FB(packet)888 3910 y FC(to)22 b(the)f(err)o(or)6 +b('s)20 b(auxiliary)g(data)g(packet.)25 b(Then,)20 b(the)h(clauses)g +(will)g(be)g(checked)f(for)888 4010 y(a)29 b(match.)50 +b(The)29 b(\002rst)g(clause)f(that)h(matches)g(is)g(executed,)h(and)e +(its)h(value)g(is)g(the)888 4109 y(value)24 b(of)g(the)h(entir)o(e)f +Fy(with-errno-hand)o(ler)18 b FC(form.)36 b(If)24 b(no)h(clause)f +(matches,)h(the)888 4209 y(handler)c(sear)o(ch)e(continues.)888 +4347 y(Err)o(or)h(clauses)h(have)f(two)h(forms)1071 4523 +y Fy(\(\()p FB(errno)44 b Fy(...\))e FB(body)g Fy(...\))1071 +4622 y(\(else)g FB(body)g Fy(...\))888 4799 y FC(In)26 +b(the)g(\002rst)g(type)f(of)h(clause,)g(the)g FB(errno)g +FC(forms)g(ar)o(e)e(integer)i(expr)o(essions.)40 b(They)888 +4898 y(ar)o(e)25 b(evaluated)g(and)g(compar)o(ed)g(to)h(the)h(err)o(or) +6 b('s)25 b(errno)h(value.)41 b(An)26 b Fy(else)e FC(clause)2071 +5147 y(22)p eop +%%Page: 23 29 +23 28 bop 573 614 a FC(matches)23 b(any)g(errno)h(value.)32 +b(Note)24 b(that)f(the)h FB(errno)g FC(and)f FB(data)f +FC(variables)g(ar)o(e)g(lexi-)573 714 y(cally)e(visible)h(to)h(the)f +(err)o(or)e(clauses.)573 892 y(Example:)756 1149 y Fy(\(with-errno-han) +o(dl)o(er)930 1249 y(\(\(errno)41 b(packet\))f(;)j(Only)f(handle)f(3)j +(particular)39 b(errors.)973 1348 y(\(\(errno/wouldbloc)o(k)f +(errno/again\))1017 1448 y(\(loop\)\))973 1548 y(\(\(errno/acces\))1017 +1647 y(\(format)j(#t)h("Not)g(allowed)f(access!"\))1017 +1747 y(#f\)\))843 1946 y(\(foo)h(frobbotz\))843 2046 +y(\(blatz)f(garglemumph\)\))573 2302 y FC(It)25 b(is)h(not)g(de\002ned) +f(what)h(dynamic)f(context)h(the)g(handler)f(executes)f(in,)j(so)f +(\003uid)573 2402 y(variables)20 b(cannot)h(r)o(eliably)f(be)g(r)o +(efer)o(enced.)573 2580 y(Note)29 b(that)h(Scsh)f(system)i(calls)e +(always)g(r)o(etry)g(when)h(interr)o(upted,)h(so)f(that)f(the)573 +2680 y Fy(errno/intr)15 b FC(exception)20 b(is)g(never)f(raised.)24 +b(If)19 b(the)h(pr)o(ogrammer)f(wishes)h(to)g(abort)573 +2780 y(a)27 b(system)i(call)e(on)i(an)e(interr)o(upt,)j(he)e(should)h +(have)e(the)h(interr)o(upt)g(handler)f(ex-)573 2879 y(plicitly)19 +b(raise)g(an)g(exception)g(or)g(invoke)g(a)g(stor)o(ed)f(continuation)j +(to)e(thr)o(ow)g(out)h(of)573 2979 y(the)h(system)g(call.)365 +3636 y FA(3.1.1)81 b(Interactive)19 b(mode)h(and)g(error)h(handling)365 +3909 y FC(Scsh)28 b(r)o(uns)g(in)g(two)g(modes:)39 b(interactive)27 +b(and)g(script)g(mode.)46 b(It)27 b(starts)g(up)h(in)f(interac-)365 +4008 y(tive)c(mode)g(if)f(the)h(scsh)g(interpr)o(eter)e(is)i(started)f +(up)g(with)i(no)f(script)g(ar)o(gument.)30 b(Other)o(-)365 +4108 y(wise,)23 b(scsh)g(starts)f(up)g(in)h(script)f(mode.)30 +b(The)22 b(mode)h(determines)f(whether)g(scsh)h(prints)365 +4208 y(pr)o(ompts)c(in)g(between)f(r)o(eading)f(and)h(evaluating)g +(forms,)h(and)f(it)h(af)o(fects)e(the)h(default)g(er)o(-)365 +4307 y(r)o(or)h(handler)-6 b(.)24 b(In)c(interactive)e(mode,)i(the)f +(default)f(err)o(or)h(handler)f(will)i(r)o(eport)f(the)g(err)o(or)-6 +b(,)365 4407 y(and)29 b(generate)f(an)g(interactive)g(br)o(eakpoint)g +(so)i(that)f(the)f(user)h(can)g(interact)f(with)h(the)365 +4506 y(system)e(to)f(examine,)h(\002x,)g(or)f(dismiss)h(fr)o(om)f(the)g +(err)o(or)-6 b(.)40 b(In)26 b(script)g(mode,)h(the)g(default)365 +4606 y(err)o(or)20 b(handler)g(causes)h(the)g(scsh)g(pr)o(ocess)f(to)h +(exit.)490 4799 y(When)j(scsh)h(forks)f(a)g(child)g(with)h +Fy(\(fork\))p FC(,)e(the)h(child)g(r)o(esets)g(to)g(script)g(mode.)36 +b(This)365 4898 y(can)21 b(be)f(overridden)g(if)h(the)g(pr)o(ogrammer)f +(wishes.)1756 5147 y(23)p eop +%%Page: 24 30 +24 29 bop 681 614 a Fw(3.2)99 b(I/O)681 834 y FA(3.2.1)81 +b(Standard)18 b(R4RS)i(I/O)h(procedures)681 1022 y FC(In)29 +b(scsh,)j(most)d(standar)o(d)f(R4RS)h(i/o)h(operations)f(\(such)g(as)g +Fy(display)d FC(or)j Fy(read-char)p FC(\))681 1121 y(work)22 +b(on)h(both)g(integer)f(\002le)g(descriptors)g(and)g(Scheme)f(ports.)30 +b(When)23 b(doing)f(i/o)h(with)681 1221 y(a)j(\002le)h(descriptor)-6 +b(,)28 b(the)f(i/o)h(operation)f(is)h(done)f(dir)o(ectly)f(on)i(the)f +(\002le,)i(bypassing)e(any)681 1321 y(buf)o(fer)o(ed)k(data)h(that)h +(may)h(have)f(accumulated)f(in)i(an)f(associated)g(port.)63 +b(Note)34 b(that)681 1420 y(character)o(-at-a-time)27 +b(operations)k(such)g(as)f Fy(read-char)d FC(ar)o(e)i(likely)i(to)g(be) +f(quite)h(slow)681 1520 y(when)21 b(performed)f(dir)o(ectly)g(upon)h +(\002le)g(descriptors.)805 1648 y(The)27 b(standar)o(d)e(R4RS)h(pr)o +(ocedur)o(es)f Fy(read-char)p FC(,)f Fy(char-ready?)p +FC(,)f Fy(write)p FC(,)j Fy(display)p FC(,)681 1748 y +Fy(newline)p FC(,)f(and)i Fy(write-char)c FC(ar)o(e)i(all)i(generic,)h +(accepting)f(integer)g(\002le)g(descriptor)g(ar)o(-)681 +1848 y(guments)g(as)f(well)h(as)f(ports.)42 b(Scsh)26 +b(also)h(mandates)e(the)i(availability)e(of)i Fy(format)p +FC(,)d(and)681 1947 y(further)c(r)o(equir)o(es)g Fy(format)e +FC(to)j(accept)f(\002le)h(descriptor)f(ar)o(guments)h(as)f(well)h(as)g +(ports.)805 2076 y(The)36 b(pr)o(ocedur)o(es)e Fy(peek-char)f +FC(and)i Fy(read)f FC(do)i FB(not)g FC(accept)f(\002le)h(descriptor)f +(ar)o(gu-)681 2175 y(ments,)41 b(since)c(these)g(functions)h(r)o(equir) +o(e)e(the)h(ability)g(to)g(r)o(ead)e(ahead)h(in)i(the)f(input)681 +2275 y(str)o(eam,)19 b(a)i(featur)o(e)e(not)i(supported)g(by)f(Unix)h +(I/O.)681 2536 y FA(3.2.2)81 b(Port)20 b(manipulation)e(and)h(standard) +g(ports)681 2748 y Fy(\(close-after)38 b FB(port)20 b(consumer)p +Fy(\))88 b Fu(\000)-15 b(!)88 b FB(value\(s\))20 b(of)h(consumer)394 +b FC(pr)o(ocedur)o(e)888 2865 y(Returns)35 b Fy(\()p +FB(consumer)43 b(port)p Fy(\))p FC(,)36 b(but)e(closes)g(the)g(port)f +(on)i(r)o(eturn.)63 b(No)34 b(dynamic-)888 2957 y(wind)22 +b(magic.)1071 3120 y Fl(Remark:)51 b Fk(Is)18 b(ther)o(e)h(a)g +(less-awkwar)o(d)e(name?)681 3372 y Fy(\(error-output-po)o(rt)o(\))81 +b Fu(\000)-14 b(!)87 b FB(port)1214 b FC(pr)o(ocedur)o(e)888 +3516 y(This)33 b(pr)o(ocedur)o(e)d(is)j(analogous)g(to)g +Fy(current-output-)o(por)o(t)p FC(,)c(but)j(pr)o(oduces)g(a)888 +3615 y(port)21 b(used)g(for)f(err)o(or)g(messages\227the)h(scsh)g +(equivalent)g(of)g(stderr)-6 b(.)681 3814 y Fy(\(with-current-in)o(pu)o +(t-p)o(or)o(t*)37 b FB(port)20 b(thunk)p Fy(\))83 b Fu(\000)-14 +b(!)83 b FB(value\(s\))20 b(of)h(thunk)86 b FC(pr)o(ocedur)o(e)681 +3914 y Fy(\(with-current-ou)o(tp)o(ut-)o(po)o(rt)o(*)38 +b FB(port)17 b(thunk)p Fy(\))65 b Fu(\000)-15 b(!)66 +b FB(value\(s\))17 b(of)i(thunk)86 b FC(pr)o(ocedur)o(e)681 +4013 y Fy(\(with-error-outp)o(ut)o(-po)o(rt)o(*)37 b +FB(port)21 b(thunk)p Fy(\))86 b Fu(\000)-14 b(!)87 b +FB(value\(s\))20 b(of)h(thunk)122 b FC(pr)o(ocedur)o(e)888 +4157 y(These)31 b(pr)o(ocedur)o(es)e(install)j FB(port)e +FC(as)h(the)g(curr)o(ent)f(input,)k(curr)o(ent)c(output,)j(and)888 +4257 y(err)o(or)20 b(output)h(port,)g(r)o(espectively)-9 +b(,)19 b(for)i(the)g(duration)f(of)h(a)f(call)h(to)g +FB(thunk)o FC(.)681 4456 y Fy(\(with-current-in)o(pu)o(t-p)o(or)o(t)37 +b FB(port)21 b(.)f(body)p Fy(\))86 b Fu(\000)-14 b(!)87 +b FB(value\(s\))20 b(of)h(body)295 b FC(syntax)681 4555 +y Fy(\(with-current-ou)o(tp)o(ut-)o(po)o(rt)37 b FB(port)20 +b(.)h(body)p Fy(\))86 b Fu(\000)-15 b(!)88 b FB(value\(s\))20 +b(of)h(body)251 b FC(syntax)681 4655 y Fy(\(with-error-outp)o(ut)o(-po) +o(rt)37 b FB(port)20 b(.)g(body)p Fy(\))87 b Fu(\000)-15 +b(!)87 b FB(value\(s\))21 b(of)f(body)339 b FC(syntax)888 +4799 y(These)33 b(special)f(forms)h(ar)o(e)f(simply)h(syntactic)g +(sugar)g(for)f(the)h Fy(with-current-)888 4898 y(input-port*)17 +b FC(pr)o(ocedur)o(e)h(and)j(friends.)2071 5147 y(24)p +eop +%%Page: 25 31 +25 30 bop 365 614 a Fy(\(set-current-inpu)o(t-)o(por)o(t!)37 +b FB(port)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(unde\002ned)580 +b FC(pr)o(ocedur)o(e)365 714 y Fy(\(set-current-outp)o(ut)o(-po)o(rt)o +(!)38 b FB(port)p Fy(\))86 b Fu(\000)-15 b(!)88 b FB(unde\002ned)536 +b FC(pr)o(ocedur)o(e)365 814 y Fy(\(set-error-output)o(-p)o(ort)o(!)37 +b FB(port)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(unde\002ned)624 +b FC(pr)o(ocedur)o(e)573 958 y(These)21 b(pr)o(ocedur)o(es)f(alter)h +(the)g(dynamic)h(binding)g(of)g(the)f(curr)o(ent)g(I/O)h(port)f(pr)o +(o-)573 1057 y(cedur)o(es)e(to)i(new)h(values.)365 1257 +y Fy(\(close)41 b FB(fd/port)p Fy(\))86 b Fu(\000)-15 +b(!)88 b FB(boolean)1355 b FC(pr)o(ocedur)o(e)573 1402 +y(Close)21 b(the)g(port)g(or)g(\002le)f(descriptor)-6 +b(.)573 1537 y(If)27 b FB(fd/port)g FC(is)h(a)g(\002le)g(descriptor)-6 +b(,)29 b(and)e(it)h(has)g(a)g(port)g(allocated)f(to)h(it,)i(the)e(port) +g(is)573 1637 y(shifted)c(to)h(a)e(new)i(\002le)f(descriptor)g(cr)o +(eated)e(with)k Fy(\(dup)41 b(fd/port\))21 b FC(befor)o(e)i(clos-)573 +1737 y(ing)c Fy(fd/port)p FC(.)i(The)e(port)f(then)g(has)h(its)f(r)o +(evealed)e(count)j(set)f(to)h(zer)o(o.)k(This)c(r)o(e\003ects)573 +1836 y(the)k(design)h(criteria)e(that)i(ports)f(ar)o(e)f(not)i +(associated)f(with)h(\002le)f(descriptors,)h(but)573 +1936 y(with)d(open)g(\002les.)573 2072 y(T)-8 b(o)19 +b(close)f(a)g(\002le)g(descriptor)-6 b(,)18 b(and)g(any)g(associated)g +(port)g(it)h(might)g(have,)f(you)h(must)573 2171 y(instead)h(say)h(one) +g(of)g(\(as)f(appr)o(opriate\):)756 2343 y Fy(\(close)41 +b(\(fdes->inport)81 b(fd\)\))756 2443 y(\(close)41 b(\(fdes->outport)c +(fd\)\))573 2651 y FC(The)26 b(pr)o(ocedur)o(e)e(r)o(eturns)h(tr)o(ue)h +(if)g(it)h(closed)f(an)g(open)g(port.)41 b(If)26 b(the)g(port)g(was)g +(al-)573 2751 y(r)o(eady)19 b(closed,)i(it)g(r)o(eturns)f(false;)g +(this)h(is)g(not)h(an)e(err)o(or)-6 b(.)365 2951 y Fy +(\(stdports->stdio\))80 b Fu(\000)-14 b(!)87 b FB(unde\002ned)1111 +b FC(pr)o(ocedur)o(e)365 3051 y Fy(\(stdio->stdports\))80 +b Fu(\000)-14 b(!)87 b FB(unde\002ned)1111 b FC(pr)o(ocedur)o(e)573 +3195 y(These)30 b(two)h(pr)o(ocedur)o(es)e(ar)o(e)g(used)h(to)h(synchr) +o(onise)g(Unix')g(standar)o(d)d(I/O)j(\002le)573 3294 +y(descriptors)20 b(and)h(Scheme's)f(curr)o(ent)g(I/O)i(ports.)573 +3430 y Fy(\(stdports->stdio)o(\))14 b FC(causes)21 b(the)f(standar)o(d) +f(I/O)j(\002le)e(descriptors)h(\(0,)e(1,)h(and)g(2\))573 +3530 y(to)h(take)f(their)h(values)f(fr)o(om)g(the)h(curr)o(ent)f(I/O)h +(ports.)26 b(It)20 b(is)h(exactly)f(equivalent)h(to)573 +3630 y(the)g(series)f(of)h(r)o(edir)o(ections:)1486 3599 +y Fv(1)756 3802 y Fy(\(dup)41 b(\(current-input-po)o(rt\))80 +b(0\))756 3901 y(\(dup)41 b(\(current-output-p)o(ort)o(\))c(1\))756 +4001 y(\(dup)k(\(error-output-por)o(t\))124 b(2\))573 +4173 y(stdio->stdports)32 b FC(causes)37 b(the)h(bindings)h(of)f(the)g +(curr)o(ent)g(I/O)g(ports)g(to)h(be)573 4273 y(changed)28 +b(to)h(ports)f(constr)o(ucted)h(over)f(the)g(standar)o(d)f(I/O)i +(\002le)g(descriptors.)48 b(It)573 4372 y(is)21 b(exactly)f(equivalent) +h(to)g(the)g(series)g(of)f(assignments)756 4544 y Fy(\(set-current-in)o +(pu)o(t-p)o(or)o(t!)81 b(\(fdes->inport)h(0\)\))756 4644 +y(\(set-current-ou)o(tp)o(ut-)o(po)o(rt!)37 b(\(fdes->outport)h(1\)\)) +756 4744 y(\(set-error-outp)o(ut)o(-po)o(rt)o(!)125 b(\(fdes->outport) +38 b(2\)\))p 365 4821 1146 4 v 450 4875 a Fq(1)485 4898 +y Ft(Why)16 b(not)g Fj(move->fdes)p Ft(?)24 b(Because)16 +b(the)g(curr)o(ent)g(output)g(port)h(and)e(err)o(or)i(port)g(might)e +(be)h(the)g(same)g(port.)1756 5147 y FC(25)p eop +%%Page: 26 32 +26 31 bop 888 614 a FC(However)-6 b(,)57 b(you)51 b(ar)o(e)d(mor)o(e)i +(likely)h(to)f(\002nd)g(the)g(dynamic-extent)g(variant,)888 +714 y Fy(with-stdio-ports*)o FC(,)15 b(below)-8 b(,)21 +b(to)g(be)g(of)f(use)h(in)g(general)g(pr)o(ogramming.)681 +909 y Fy(\(with-stdio-port)o(s*)37 b FB(thunk)p Fy(\))86 +b Fu(\000)-14 b(!)87 b FB(value\(s\))21 b(of)f(thunk)543 +b FC(pr)o(ocedur)o(e)681 1009 y Fy(\(with-stdio-port)o(s)37 +b FB(body)20 b(.)12 b(.)g(.)g Fy(\))88 b Fu(\000)-14 +b(!)87 b FB(value\(s\))20 b(of)h(body)680 b FC(syntax)888 +1151 y Fy(with-stdio-ports*)31 b FC(binds)37 b(the)h(standar)o(d)e +(ports)i Fy(\(current-input-)o(por)o(t\))o FC(,)888 1251 +y Fy(\(current-output-p)o(or)o(t\))p FC(,)23 b(and)k +Fy(\(error-output-por)o(t\))21 b FC(to)28 b(be)g(ports)g(on)g(\002le) +888 1351 y(descriptors)21 b(0,)f(1,)g(2,)g(and)g(then)h(calls)g +FB(thunk)o FC(.)26 b(It)21 b(is)g(equivalent)g(to:)1071 +1519 y Fy(\(with-current-in)o(put)o(-p)o(or)o(t)38 b(\(fdes->inport)g +(0\))1158 1619 y(\(with-current-out)o(pu)o(t-)o(por)o(t)f +(\(fdes->inport)i(1\))1245 1719 y(\(with-error-outpu)o(t-)o(por)o(t)e +(\(fdes->outport)h(2\))1333 1818 y(\(thunk\)\)\)\))888 +1987 y FC(The)21 b Fy(with-stdio-ports)14 b FC(special)21 +b(form)f(is)h(mer)o(ely)g(syntactic)g(sugar)-6 b(.)681 +2261 y FA(3.2.3)81 b(String)20 b(ports)681 2447 y FC(Scheme)30 +b(48)g(has)h(string)h(ports,)h(which)f(you)f(can)g(use.)56 +b(Scsh)31 b(has)g(not)g(committed)h(to)681 2546 y(the)27 +b(particular)f(interface)h(or)g(names)h(that)f(Scheme)g(48)f(uses,)j +(so)f(be)f(warned)g(that)g(the)681 2646 y(interface)19 +b(described)h(her)o(ein)g(may)h(be)g(liable)f(to)h(change.)681 +2797 y Fy(\(make-string-inp)o(ut)o(-po)o(rt)37 b FB(string)p +Fy(\))87 b Fu(\000)-15 b(!)88 b FB(port)749 b FC(pr)o(ocedur)o(e)888 +2939 y(Returns)22 b(a)e(port)h(that)g(r)o(eads)e(characters)g(fr)o(om)i +(the)g(supplied)f(string.)681 3135 y Fy(\(make-string-out)o(pu)o(t-p)o +(or)o(t\))81 b Fu(\000)-15 b(!)88 b FB(port)952 b FC(pr)o(ocedur)o(e) +681 3234 y Fy(\(string-output-p)o(or)o(t-o)o(ut)o(pu)o(t)38 +b FB(port)p Fy(\))86 b Fu(\000)-15 b(!)88 b FB(string)619 +b FC(pr)o(ocedur)o(e)888 3377 y(A)45 b(string)g(output)h(port)f(is)g(a) +g(port)g(that)f(collects)i(the)f(characters)e(given)j(to)888 +3476 y(it)j(into)h(a)e(string.)109 b(The)49 b(accumulated)e(string)i +(is)g(r)o(etrieved)e(by)i(applying)888 3576 y Fy(string-output-por)o +(t-)o(out)o(pu)o(t)15 b FC(to)21 b(the)g(port.)681 3771 +y Fy(\(call-with-strin)o(g-)o(out)o(pu)o(t-)o(por)o(t)37 +b FB(pr)o(ocedur)o(e)p Fy(\))86 b Fu(\000)-14 b(!)87 +b FB(string)301 b FC(pr)o(ocedur)o(e)888 3914 y(The)74 +b FB(pr)o(ocedur)o(e)e FC(value)h(is)h(called)f(on)h(a)f(port.)184 +b(When)74 b(it)g(r)o(eturns,)888 4013 y Fy(call-with-string-)o(ou)o +(tpu)o(t-)o(por)o(t)18 b FC(r)o(eturns)24 b(a)g(string)h(containing)g +(the)g(charac-)888 4113 y(ters)c(that)g(wer)o(e)e(written)j(to)f(that)f +(port)h(during)g(the)g(execution)g(of)g FB(pr)o(ocedur)o(e)o +FC(.)681 4387 y FA(3.2.4)81 b(Revealed)18 b(ports)j(and)e(\002le)h +(descriptors)681 4572 y FC(The)g(material)f(in)i(this)g(section)g(and)e +(the)i(following)g(one)g(is)f(not)h(critical)f(for)g(most)h(appli-)681 +4672 y(cations.)26 b(Y)-8 b(ou)21 b(may)g(safely)f(skim)i(or)e +(completely)h(skip)g(this)h(section)f(on)g(a)f(\002rst)h(r)o(eading.) +805 4799 y(Dealing)j(with)g(Unix)f(\002le)g(descriptors)g(in)h(a)f +(Scheme)f(envir)o(onment)i(is)g(dif)o(\002cult.)32 b(In)681 +4898 y(Unix,)h(open)f(\002les)g(ar)o(e)e(part)g(of)i(the)f(pr)o(ocess)g +(envir)o(onment,)k(and)30 b(ar)o(e)g(r)o(efer)o(enced)f(by)2071 +5147 y(26)p eop +%%Page: 27 33 +27 32 bop 365 614 a FC(small)29 b(integers)g(called)f +FB(\002le)h(descriptors)p FC(.)49 b(Open)29 b(\002le)g(descriptors)f +(ar)o(e)f(the)i(fundamen-)365 714 y(tal)e(way)h(i/o)g(r)o(edir)o +(ections)e(ar)o(e)g(passed)h(to)g(subpr)o(ocesses,)i(since)e(\002le)h +(descriptors)f(ar)o(e)365 814 y(pr)o(eserved)19 b(acr)o(oss)h(fork's)h +(and)g(exec's.)490 939 y(Scheme,)h(on)g(the)h(other)f(hand,)g(uses)g +(ports)h(for)f(specifying)g(i/o)h(sour)o(ces.)29 b(Ports)23 +b(ar)o(e)365 1039 y(garbage-collected)c(Scheme)h(objects,)h(not)g +(integers.)26 b(Ports)21 b(can)f(be)g(garbage)f(collected;)365 +1139 y(when)27 b(a)f(port)g(is)h(collected,)g(it)g(is)f(also)h(closed.) +42 b(Because)25 b(\002le)h(descriptors)h(ar)o(e)d(just)j(in-)365 +1238 y(tegers,)f(it's)f(impossible)h(to)f(garbage)f(collect)h +(them\227you)h(wouldn't)f(be)g(able)f(to)h(close)365 +1338 y(\002le)f(descriptor)f(3)g(unless)h(ther)o(e)f(wer)o(e)f(no)i +(3's)f(in)h(the)g(system,)h(and)e(you)h(could)f(further)365 +1437 y(pr)o(ove)j(that)h(your)f(pr)o(ogram)g(would)h(never)f(again)h +(compute)g(a)f(3.)42 b(This)27 b(is)g(dif)o(\002cult)f(at)365 +1537 y(best.)490 1663 y(If)d(a)f(Scheme)h(pr)o(ogram)g(only)h(used)f +(Scheme)f(ports,)i(and)f(never)g(actually)f(used)h(\002le)365 +1762 y(descriptors,)28 b(this)g(would)f(not)g(be)g(a)f(pr)o(oblem.)43 +b(But)27 b(Scheme)f(code)h(must)g(descend)f(to)365 1862 +y(the)21 b(\002le)g(descriptor)f(level)h(in)g(at)g(least)f(two)h(cir)o +(cumstances:)490 2055 y Fu(\017)41 b FC(when)21 b(interfacing)g(to)g +(for)o(eign)f(code)490 2223 y Fu(\017)41 b FC(when)21 +b(interfacing)g(to)g(a)f(subpr)o(ocess.)365 2416 y(This)30 +b(causes)f(a)g(pr)o(oblem.)50 b(Suppose)29 b(we)g(have)g(a)g(Scheme)g +(port)g(constr)o(ucted)g(on)h(top)365 2515 y(of)d(\002le)g(descriptor)g +(2.)44 b(W)-8 b(e)27 b(intend)g(to)h(fork)f(of)o(f)f(a)g(pr)o(ogram)g +(that)h(will)h(inherit)g(this)f(\002le)365 2615 y(descriptor)-6 +b(.)25 b(If)c(we)g(dr)o(op)f(r)o(efer)o(ences)e(to)j(the)g(port,)g(the) +g(garbage)e(collector)i(may)g(pr)o(ema-)365 2714 y(tur)o(ely)e(close)h +(\002le)g(2)f(befor)o(e)f(we)i(fork)f(the)h(subpr)o(ocess.)25 +b(The)19 b(interface)g(described)f(below)365 2814 y(is)24 +b(intended)g(to)g(\002x)f(this)h(and)g(other)f(pr)o(oblems)h(arising)g +(fr)o(om)f(the)g(mismatch)i(between)365 2914 y(ports)c(and)g(\002le)g +(descriptors.)490 3039 y(The)h(Scheme)g(kernel)g(maintains)h(a)e(port)h +(table)g(that)g(maps)g(a)g(\002le)g(descriptor)g(to)g(the)365 +3139 y(Scheme)33 b(port)g(allocated)f(for)h(it)h(\(or)-6 +b(,)35 b Fy(#f)e FC(if)g(ther)o(e)f(is)h(no)h(port)f(allocated)g(for)g +(this)g(\002le)365 3239 y(descriptor\).)e(This)23 b(is)g(used)f(to)h +(ensur)o(e)f(that)h(ther)o(e)e(is)i(at)g(most)g(one)g(open)g(port)g +(for)f(each)365 3338 y(open)f(\002le)g(descriptor)-6 +b(.)490 3464 y(The)25 b(port)f(data)g(str)o(uctur)o(e)g(for)h(\002le)g +(ports)g(has)g(two)g(\002elds)g(besides)f(the)h(descriptor:)365 +3564 y FB(r)o(evealed)h FC(and)f FB(closed?)p FC(.)41 +b(When)26 b(a)g(\002le)g(port)g(is)g(closed)g(with)h +Fy(\(close)41 b(port\))p FC(,)25 b(the)h(port's)365 3663 +y(\002le)32 b(descriptor)f(is)h(closed,)i(its)f(entry)e(in)h(the)g +(port)g(table)f(is)h(clear)o(ed,)g(and)f(the)h(port's)365 +3763 y FB(closed?)20 b FC(\002eld)h(is)g(set)g(to)g(tr)o(ue.)490 +3889 y(When)32 b(a)f(\002le)g(descriptor)h(is)f(closed)h(with)g +Fy(\(close)41 b(fdes\))p FC(,)32 b(any)g(associated)e(port)365 +3988 y(is)f(shifted)g(to)g(a)f(new)h(\002le)g(descriptor)f(cr)o(eated)f +(with)j Fy(\(dup)42 b(fdes\))p FC(.)47 b(The)29 b(port)f(has)h(its)365 +4088 y(r)o(evealed)e(count)i(r)o(eset)f(to)h(zer)o(o)e(\(and)h(hence)h +(becomes)g(eligible)f(for)h(closing)h(on)f(GC\).)365 +4187 y(See)16 b(discussion)i(below)-8 b(.)25 b(T)-8 b(o)17 +b(r)o(eally)e(put)i(a)f(stake)g(thr)o(ough)i(a)e(descriptor)6 +b('s)16 b(heart)g(without)365 4287 y(waiting)22 b(for)e(associated)g +(ports)h(to)g(be)g(GC'd,)f(you)i(must)f(say)g(one)g(of)573 +4480 y Fy(\(close)41 b(\(fdes->inport)d(fdes\)\))573 +4580 y(\(close)j(\(fdes->output)d(fdes\)\))490 4799 y +FC(The)20 b FB(r)o(evealed)h FC(\002eld)f(is)h(an)g(aid)f(to)h(garbage) +e(collection.)27 b(It)20 b(is)h(an)g(integer)f(semaphor)o(e.)365 +4898 y(If)25 b(it)g(is)h(zer)o(o,)e(the)i(port's)f(\002le)g(descriptor) +g(can)g(be)g(closed)g(when)g(the)h(port)f(is)g(collected.)1756 +5147 y(27)p eop +%%Page: 28 34 +28 33 bop 681 614 a FC(Essentially)-9 b(,)31 b(the)f +FB(r)o(evealed)e FC(\002eld)i(r)o(e\003ects)e(whether)i(or)f(not)h(the) +f(port's)h(\002le)f(descriptor)681 714 y(has)21 b(escaped)e(to)i(the)g +(Scheme)g(user)-6 b(.)25 b(If)c(the)g(Scheme)f(user)h(doesn't)g(know)h +(what)f(\002le)g(de-)681 814 y(scriptor)i(is)h(associated)f(with)i(a)e +(given)h(port,)g(then)g(he)f(can't)h(possibly)g(r)o(etain)f(an)h +(\223inte-)681 913 y(ger)17 b(handle\224)f(on)i(the)f(port)g(after)f +(dr)o(opping)h(pointers)g(to)h(the)f(port)g(itself,)g(so)h(the)f +(garbage)681 1013 y(collector)k(is)g(fr)o(ee)e(to)i(close)g(the)g +(\002le.)805 1162 y(Ports)36 b(allocated)f(with)h Fy(open-output-file) +29 b FC(and)35 b Fy(open-input-file)29 b FC(ar)o(e)34 +b(unr)o(e-)681 1262 y(vealed)24 b(ports\227)p FB(i.e.)p +FC(,)j FB(r)o(evealed)e FC(is)h(initialised)g(to)h(0.)39 +b(No)26 b(one)g(knows)h(the)f(port's)g(\002le)g(de-)681 +1362 y(scriptor)-6 b(,)20 b(so)i(the)e(\002le)h(descriptor)g(can)f(be)h +(closed)f(when)i(the)f(port)g(is)g(collected.)805 1511 +y(The)44 b(functions)g Fy(fdes->output-port)o FC(,)g +Fy(fdes->input-por)o(t)p FC(,)f Fy(port->fdes)c FC(ar)o(e)681 +1611 y(used)45 b(to)h(shift)g(back)f(and)h(forth)f(between)h(\002le)g +(descriptors)f(and)g(ports.)101 b(When)681 1710 y Fy(port->fdes)31 +b FC(r)o(eveals)j(a)h(port's)h(\002le)f(descriptor)-6 +b(,)38 b(it)e(incr)o(ements)f(the)h(port's)f FB(r)o(evealed)681 +1810 y FC(\002eld.)119 b(When)53 b(the)f(user)g(is)h(thr)o(ough)f(with) +h(the)g(\002le)f(descriptor)-6 b(,)59 b(he)52 b(can)g(call)681 +1910 y Fy(\(release-port-ha)o(nd)o(le)37 b FB(port)o +Fy(\))p FC(,)65 b(which)58 b(decr)o(ements)d(the)i(count.)133 +b(The)57 b(func-)681 2009 y(tion)44 b Fy(\(call/fdes)39 +b(fd/port)i FB(pr)o(oc)o Fy(\))i FC(automates)g(this)h(pr)o(otocol.)94 +b Fy(call/fdes)40 b FC(uses)681 2109 y Fy(dynamic-wind)18 +b FC(to)23 b(enfor)o(ce)e(the)i(pr)o(otocol.)32 b(If)22 +b FB(pr)o(oc)g FC(thr)o(ows)h(out)g(of)g(the)g Fy(call/fdes)c +FC(ap-)681 2208 y(plication,)28 b(the)f(unwind)g(handler)f(r)o(eleases) +g(the)g(descriptor)h(handle;)i(if)d(the)h(user)f(sub-)681 +2308 y(sequently)32 b(tries)g(to)g(thr)o(ow)g FB(back)g +FC(into)h FB(pr)o(oc)n FC('s)f(context,)j(the)d(wind)g(handler)f +(raises)g(an)681 2408 y(err)o(or)-6 b(.)42 b(When)27 +b(the)f(user)h(maps)f(a)h(\002le)f(descriptor)g(to)h(a)g(port)f(with)i +Fy(fdes->outport)21 b FC(or)681 2507 y Fy(fdes->inport)p +FC(,)15 b(the)21 b(port)g(has)g(its)g(r)o(evealed)e(\002eld)h(incr)o +(emented.)805 2657 y(Not)k(all)f(\002le)g(descriptors)g(ar)o(e)e(cr)o +(eated)g(by)i(r)o(equests)g(to)h(make)f(ports.)32 b(Some)23 +b(ar)o(e)f(in-)681 2756 y(herited)27 b(on)i(pr)o(ocess)e(invocation)i +(via)e Fy(exec\(2\))p FC(,)g(and)g(ar)o(e)f(simply)j(part)e(of)h(the)g +(global)681 2856 y(envir)o(onment.)55 b(Subpr)o(ocesses)30 +b(may)g(depend)g(upon)h(them,)i(so)e(if)f(a)g(port)h(is)g(later)f(al-) +681 2956 y(located)e(for)h(these)g(\002le)g(descriptors,)i(is)e(should) +h(be)e(consider)o(ed)g(as)h(a)f(r)o(evealed)f(port.)681 +3055 y(For)35 b(example,)j(when)e(the)f(Scheme)g(shell's)h(pr)o(ocess)f +(starts)f(up,)39 b(it)c(opens)h(ports)f(on)681 3155 y(\002le)g +(descriptors)g(0,)k(1,)f(and)d(2)g(for)g(the)g(initial)h(values)f(of)h +Fy(\(current-input-)o(por)o(t\))o FC(,)681 3254 y Fy(\(current-output-) +o(po)o(rt\))o FC(,)k(and)h Fy(\(error-output-po)o(rt)o(\))p +FC(.)81 b(These)41 b(ports)g(ar)o(e)f(ini-)681 3354 y(tialised)28 +b(with)i FB(r)o(evealed)f FC(set)f(to)i(1,)g(so)f(that)g(stdin,)i +(stdout,)g(and)e(stderr)f(ar)o(e)f(not)j(closed)681 3454 +y(even)20 b(if)h(the)g(user)f(dr)o(ops)h(the)f(port.)805 +3603 y(Unr)o(evealed)i(\002le)j(ports)f(have)g(the)g(nice)g(pr)o +(operty)g(that)g(they)g(can)g(be)g(closed)g(when)681 +3703 y(all)34 b(pointers)i(to)f(the)g(port)f(ar)o(e)g(dr)o(opped.)66 +b(This)35 b(can)g(happen)f(during)h(gc,)j(or)d(at)f(an)681 +3802 y Fy(exec\(\))p FC(\227since)29 b(all)h(memory)i(is)f(dr)o(opped)f +(at)g(an)h Fy(exec\(\))p FC(.)53 b(No)31 b(one)h(knows)g(the)f(\002le) +681 3902 y(descriptor)25 b(associated)g(with)h(the)g(port,)g(so)g(the)g +(exec'd)e(pr)o(ocess)h(certainly)g(can't)h(r)o(efer)681 +4002 y(to)21 b(it.)805 4151 y(This)c(facility)f(pr)o(eserves)e(the)i +(transpar)o(ent)f(close-on-collect)i(pr)o(operty)e(for)h(\002le)g +(ports)681 4251 y(that)h(ar)o(e)f(used)h(in)h(straightforwar)o(d)e +(ways,)i(yet)g(allows)g(access)f(to)h(the)f(underlying)h(Unix)681 +4350 y(substrate)j(without)h(interfer)o(ence)e(fr)o(om)h(the)g(garbage) +f(collector)-6 b(.)28 b(This)21 b(is)h(critical,)f(since)681 +4450 y(shell)29 b(pr)o(ogramming)g(absolutely)g(r)o(equir)o(es)f +(access)g(to)h(the)g(Unix)f(\002le)h(descriptors,)h(as)681 +4550 y(their)21 b(numerical)f(values)h(ar)o(e)e(a)h(critical)h(part)f +(of)g(the)h(pr)o(ocess)g(interface.)805 4699 y(A)d(port's)g(underlying) +g(\002le)g(descriptor)f(can)g(be)g(shifted)h(ar)o(ound)f(with)h +Fy(dup\(2\))d FC(when)681 4799 y(convenient.)52 b(That)29 +b(is,)j(the)d(actual)g(\002le)g(descriptor)g(on)h(top)g(of)f(which)i(a) +e(port)g(is)h(con-)681 4898 y(str)o(ucted)e(can)f(be)h(shifted)g(ar)o +(ound)f(underneath)h(the)g(port)g(by)h(the)f(scsh)g(kernel)g(when)2071 +5147 y(28)p eop +%%Page: 29 35 +29 34 bop 365 614 a FC(necessary)-9 b(.)35 b(This)25 +b(is)g(important,)g(because)e(when)i(the)g(user)f(is)g(setting)h(up)f +(\002le)h(descrip-)365 714 y(tors)e(prior)f(to)h(a)e +Fy(exec\(2\))p FC(,)f(he)i(may)g(explicitly)h(use)f(a)g(\002le)g +(descriptor)g(that)g(has)g(alr)o(eady)365 814 y(been)k(allocated)e(to)i +(some)g(port.)40 b(In)26 b(this)g(case,)g(the)g(scsh)g(kernel)f(just)h +(shifts)h(the)e(port's)365 913 y(\002le)17 b(descriptor)g(to)g(some)h +(new)f(location)g(with)h Fy(dup)p FC(,)e(fr)o(eeing)g(up)h(its)g(old)g +(descriptor)-6 b(.)24 b(This)365 1013 y(pr)o(events)d(err)o(ors)g(fr)o +(om)h(happening)g(in)g(the)g(following)i(scenario.)k(Suppose)22 +b(we)g(have)f(a)365 1112 y(\002le)i(open)h(on)f(port)g +Fy(f)p FC(.)31 b(Now)24 b(we)f(want)g(to)g(r)o(un)h(a)e(pr)o(ogram)g +(that)h(r)o(eads)e(input)j(on)f(\002le)g(0,)365 1212 +y(writes)f(output)f(to)h(\002le)f(1,)g(err)o(ors)f(to)i(\002le)f(2,)g +(and)g(logs)h(execution)f(information)h(on)g(\002le)f(3.)365 +1312 y(W)-8 b(e)21 b(want)g(to)g(r)o(un)h(this)f(pr)o(ogram)f(with)i +(input)f(fr)o(om)f Fy(f)p FC(.)25 b(So)c(we)g(write:)573 +1533 y Fy(\(run)42 b(\(/usr/shivers/bi)o(n/)o(pro)o(g\))791 +1632 y(\(>)h(1)g(output.txt\))791 1732 y(\(>)g(2)g(error.log\))791 +1832 y(\(>)g(3)g(trace.log\))791 1931 y(\(=)g(0)g(,f\)\))365 +2152 y FC(Now)-8 b(,)42 b(suppose)c(by)g(ill)f(chance)g(that,)42 +b(unbeknownst)d(to)f(us,)j(when)d(the)g(operating)365 +2252 y(system)31 b(opened)e Fy(f)p FC('s)h(\002le,)i(it)e(allocated)f +(descriptor)g(3)g(for)h(it.)52 b(If)30 b(we)f(blindly)i(r)o(edir)o(ect) +365 2351 y Fy(trace.log)22 b FC(into)27 b(\002le)f(descriptor)f(3,)h +(we'll)g(clobber)g Fy(f)p FC(!)40 b(However)-6 b(,)26 +b(the)g(port-shuf)o(\003ing)365 2451 y(machinery)18 b(saves)f(us:)24 +b(when)18 b(the)g Fy(run)e FC(form)i(tries)f(to)h(dup)f +Fy(trace.log)p FC('s)d(\002le)k(descriptor)365 2551 y(to)29 +b(3,)g Fy(dup)e FC(will)h(notice)h(that)f(\002le)g(descriptor)f(3)h(is) +g(alr)o(eady)f(associated)g(with)i(an)e(unr)o(e-)365 +2650 y(vealed)d(port)i(\()p FB(i.e.)o FC(,)h Fy(f)p FC(\).)38 +b(So,)26 b(it)g(will)g(\002rst)g(move)f Fy(f)g FC(to)h(some)g(other)g +(\002le)f(descriptor)-6 b(.)39 b(This)365 2750 y(keeps)27 +b Fy(f)f FC(alive)g(and)h(well)g(so)g(that)f(it)h(can)g(subsequently)h +(be)e(dup'd)g(into)i(descriptor)e(0)365 2849 y(for)21 +b Fy(prog)p FC('s)e(stdin.)490 2992 y(The)j(port-shifting)i(machinery)e +(makes)h(the)g(following)h(guarantee:)k(a)22 b(port)h(is)g(only)365 +3092 y(moved)h(when)g(the)g(underlying)g(\002le)f(descriptor)g(is)h +(closed,)g(either)f(by)h(a)f Fy(close\(\))d FC(or)k(a)365 +3191 y Fy(dup2\(\))19 b FC(operation.)25 b(Otherwise)d(a)e +(port/\002le-descriptor)g(association)i(is)f(stable.)490 +3334 y(Under)38 b(normal)h(cir)o(cumstances,)j(all)d(this)g(machinery)g +(just)g(works)h(behind)e(the)365 3433 y(scenes)31 b(to)f(keep)g(things) +h(straightened)f(out.)55 b(The)30 b(only)h(time)f(the)h(user)f(has)g +(to)h(think)365 3533 y(about)17 b(it)h(is)g(when)g(he)f(starts)g +(accessing)h(\002le)f(descriptors)g(fr)o(om)g(ports,)h(which)g(he)g +(should)365 3633 y(almost)j(never)f(have)g(to)g(do.)26 +b(If)20 b(a)f(user)h(starts)g(asking)h(what)g(\002le)f(descriptors)g +(have)g(been)365 3732 y(allocated)25 b(to)h(what)g(ports,)h(he)e(has)h +(to)g(take)f(r)o(esponsibility)h(for)g(managing)g(this)g(infor)o(-)365 +3832 y(mation.)365 4129 y FA(3.2.5)81 b(Port-mapping)19 +b(machinery)365 4336 y FC(The)30 b(pr)o(ocedur)o(es)e(pr)o(ovided)h(in) +h(this)h(section)f(ar)o(e)f(almost)h(never)g(needed.)52 +b(Y)-8 b(ou)31 b(may)365 4435 y(safely)20 b(skim)i(or)f(completely)g +(skip)g(this)h(section)f(on)h(a)e(\002rst)h(r)o(eading.)490 +4578 y(Her)o(e)g(ar)o(e)f(the)i(r)o(outines)h(for)e(manipulating)i +(ports)f(in)h(scsh.)29 b(The)22 b(important)h(points)365 +4677 y(to)e(r)o(emember)f(ar)o(e:)490 4898 y Fu(\017)41 +b FC(A)20 b(\002le)h(port)g(is)g(associated)f(with)i(an)e(open)h +(\002le,)g(not)g(a)g(particular)e(\002le)i(descriptor)-6 +b(.)1756 5147 y(29)p eop +%%Page: 30 36 +30 35 bop 805 614 a Fu(\017)41 b FC(The)16 b(association)h(between)f(a) +g(\002le)g(port)h(and)e(a)h(particular)f(\002le)h(descriptor)g(is)g +(never)888 714 y(changed)31 b FB(except)g FC(when)h(the)g(\002le)f +(descriptor)h(is)f(explicitly)h(closed.)58 b(\223Closing\224)888 +814 y(includes)18 b(being)g(used)g(as)f(the)h(tar)o(get)e(of)i(a)f +Fy(dup2)p FC(,)f(so)j(the)e(set)h(of)g(pr)o(ocedur)o(es)e(below)888 +913 y(that)22 b(close)h(their)f(tar)o(gets)f(ar)o(e)g +Fy(close)p FC(,)f(two-ar)o(gument)i Fy(dup)p FC(,)f(and)g +Fy(move->fdes)p FC(.)k(If)888 1013 y(the)k(tar)o(get)f(\002le)h +(descriptor)g(of)g(one)g(of)g(these)g(r)o(outines)g(has)g(an)g +(allocated)f(port,)888 1112 y(the)i(port)f(will)h(be)f(shifted)h(to)f +(another)h(fr)o(eshly-allocated)d(\002le)j(descriptor)-6 +b(,)30 b(and)888 1212 y(marked)g(as)g(unr)o(evealed,)h(thus)g(pr)o +(eserving)f(the)g(port)h(but)f(fr)o(eeing)f(its)i(old)g(\002le)888 +1312 y(descriptor)-6 b(.)681 1492 y(These)19 b(r)o(ules)i(ar)o(e)d +(what)i(is)g(necessary)f(to)h(\223make)f(things)i(work)f(out\224)g +(with)h(no)f(surprises)681 1591 y(in)h(the)g(general)f(case.)681 +1735 y Fy(\(fdes->inport)38 b FB(fd)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(port)1324 b FC(pr)o(ocedur)o(e)681 1835 y +Fy(\(fdes->outport)38 b FB(fd)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(port)1280 b FC(pr)o(ocedur)o(e)681 1935 y +Fy(\(port->fdes)39 b FB(port)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(\002xnum)1233 b FC(pr)o(ocedur)o(e)888 2070 +y(These)21 b(incr)o(ement)g(the)g(port's)g(r)o(evealed)d(count.)681 +2253 y Fy(\(port-revealed)38 b FB(port)p Fy(\))86 b Fu(\000)-15 +b(!)88 b FB(integer)21 b(or)g Fy(#f)911 b FC(pr)o(ocedur)o(e)888 +2389 y(Return)22 b(the)e(port's)i(r)o(evealed)c(count)k(if)e(positive,) +h(otherwise)h Fy(#f)p FC(.)681 2572 y Fy(\(release-port-ha)o(nd)o(le)37 +b FB(port)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(unde\002ned)754 +b FC(pr)o(ocedur)o(e)888 2707 y(Decr)o(ement)21 b(the)f(port's)i(r)o +(evealed)c(count.)681 2890 y Fy(\(call/fdes)39 b FB(fd/port)19 +b(consumer)p Fy(\))88 b Fu(\000)-15 b(!)88 b FB(value\(s\))20 +b(of)h(consumer)392 b FC(pr)o(ocedur)o(e)888 3026 y(Calls)28 +b FB(consumer)g FC(on)g(a)f(\002le)h(descriptor;)j(takes)c(car)o(e)f +(of)i(r)o(evealed)d(bookkeeping.)888 3125 y(If)h FB(fd/port)f +FC(is)h(a)g(\002le)g(descriptor)-6 b(,)27 b(this)f(is)h(just)g +Fy(\()p FB(consumer)43 b(fd/port)o Fy(\))p FC(.)e(If)26 +b FB(fd/port)e FC(is)j(a)888 3225 y(port,)j(calls)d FB(consumer)h +FC(on)h(its)f(underlying)g(\002le)g(descriptor)-6 b(.)45 +b(While)29 b FB(consumer)f FC(is)888 3325 y(r)o(unning,)22 +b(the)f(port's)g(r)o(evealed)e(count)i(is)g(incr)o(emented.)888 +3455 y(When)30 b Fy(call/fdes)c FC(is)j(called)g(with)h(port)f(ar)o +(gument,)i(you)f(ar)o(e)d(not)j(allowed)g(to)888 3554 +y(thr)o(ow)20 b(into)g FB(consumer)g FC(with)h(a)e(stor)o(ed)g +(continuation,)i(as)e(that)g(would)h(violate)g(the)888 +3654 y(r)o(evealed-count)f(bookkeeping.)681 3837 y Fy(\(move->fdes)39 +b FB(fd/port)19 b(tar)o(get-fd)p Fy(\))85 b Fu(\000)-14 +b(!)87 b FB(port)20 b(or)h(fdes)699 b FC(pr)o(ocedur)o(e)888 +3973 y(Maps)20 b(fd)p Fu(!)p FC(fd)g(and)g(port)p Fu(!)p +FC(port.)888 4103 y(If)27 b FB(fd/port)e FC(is)i(a)f(\002le-descriptor) +g(not)h(equal)g(to)g FB(tar)o(get-fd)n FC(,)h(dup)e(it)h(to)g +FB(tar)o(get-fd)d FC(and)888 4202 y(close)d(it.)26 b(Returns)c +FB(tar)o(get-fd)n FC(.)888 4332 y(If)j FB(fd/port)e FC(is)j(a)e(port,)i +(it)f(is)g(shifted)g(to)g FB(tar)o(get-fd)n FC(,)h(by)f(duping)g(its)h +(underlying)f(\002le-)888 4432 y(descriptor)19 b(if)f(necessary)-9 +b(.)24 b FB(Fd/port)o FC('s)18 b(original)i(\002le)e(descriptor)h(is)g +(closed)f(\(if)g(it)h(was)888 4532 y(dif)o(fer)o(ent)j(fr)o(om)i +FB(tar)o(get-fd)n FC(\).)35 b(Returns)25 b(the)f(port.)36 +b(This)25 b(operation)f(r)o(esets)f FB(fd/port)o FC('s)888 +4631 y(r)o(evealed)c(count)i(to)h(1.)888 4761 y(In)e(all)f(cases)g +(when)h FB(fd/port)e FC(is)i(actually)f(shifted,)g(if)g(ther)o(e)g(is)g +(a)g(port)h(alr)o(eady)d(using)888 4861 y FB(tar)o(get-fd)n +FC(,)k(it)g(is)g(\002rst)g(r)o(elocated)e(to)i(some)h(other)f(\002le)g +(descriptor)-6 b(.)2071 5147 y(30)p eop +%%Page: 31 37 +31 36 bop 365 614 a FA(3.2.6)81 b(Unix)20 b(I/O)365 828 +y Fy(\(dup)42 b FB(fd/port)19 b([newfd])p Fy(\))86 b +Fu(\000)-14 b(!)87 b FB(fd/port)1185 b FC(pr)o(ocedur)o(e)365 +927 y Fy(\(dup->inport)39 b FB(fd/port)19 b([newfd])p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(port)926 b FC(pr)o(ocedur)o(e)365 +1027 y Fy(\(dup->outport)39 b FB(fd/port)19 b([newfd])p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(port)882 b FC(pr)o(ocedur)o(e)365 +1127 y Fy(\(dup->fdes)40 b FB(fd/port)19 b([newfd])p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(fd)1087 b FC(pr)o(ocedur)o(e)573 +1253 y(These)36 b(pr)o(ocedur)o(es)f(pr)o(ovide)g(the)i(functionality)g +(of)f(C's)h Fy(dup\(\))d FC(and)i Fy(dup2\(\))p FC(.)573 +1353 y(The)i(dif)o(fer)o(ent)e(r)o(outines)i(r)o(eturn)g(dif)o(fer)o +(ent)e(types)i(of)g(values:)60 b Fy(dup->inport)p FC(,)573 +1452 y Fy(dup->outport)p FC(,)22 b(and)k Fy(dup->fdes)c +FC(r)o(eturn)k(input)g(ports,)i(output)e(ports,)i(and)d(in-)573 +1552 y(teger)d(\002le)h(descriptors,)g(r)o(espectively)-9 +b(.)30 b Fy(dup)p FC('s)22 b(r)o(eturn)g(value)g(depends)g(on)h(on)g +(the)573 1651 y(type)d(of)h FB(fd/port)o FC(\227it)g(maps)f(fd)p +Fu(!)p FC(fd)g(and)g(port)p Fu(!)p FC(port.)573 1788 +y(These)h(pr)o(ocedur)o(es)f(use)i(the)g(Unix)f Fy(dup\(\))f +FC(syscall)i(to)g(r)o(eplicate)e(the)i(\002le)g(descrip-)573 +1888 y(tor)i(or)h(\002le)f(port)h FB(fd/port)n FC(.)37 +b(If)24 b(a)g FB(newfd)g FC(\002le)h(descriptor)f(is)g(given,)i(it)e +(is)h(used)f(as)g(the)573 1987 y(tar)o(get)i(of)h(the)g(dup)g +(operation,)i FB(i.e.)p FC(,)g(the)e(operation)g(is)h(a)f +Fy(dup2\(\))p FC(.)42 b(In)28 b(this)f(case,)573 2087 +y(pr)o(ocedur)o(es)18 b(that)i(r)o(eturn)g(a)f(port)i(\(such)f(as)g +Fy(dup->inport)p FC(\))15 b(will)21 b(r)o(eturn)e(one)i(with)573 +2186 y(the)c(r)o(evealed)e(count)j(set)f(to)h(one.)25 +b(For)17 b(example,)g Fy(\(dup)42 b(\(current-input-p)o(or)o(t\))573 +2286 y(5\))17 b FC(pr)o(oduces)f(a)h(new)h(port)g(with)h(underlying)f +(\002le)f(descriptor)h(5,)f(whose)i(r)o(evealed)573 2386 +y(count)g(is)g(1.)25 b(If)18 b FB(newfd)h FC(is)g(not)g(speci\002ed,)g +(then)g(the)g(operating)f(system)i(chooses)f(the)573 +2485 y(\002le)i(descriptor)-6 b(,)20 b(and)g(any)h(r)o(eturned)e(port)i +(is)g(marked)f(as)h(unr)o(evealed.)573 2622 y(If)27 b(the)g +FB(newfd)g FC(tar)o(get)f(is)h(given,)i(and)e(some)g(port)g(is)h(alr)o +(eady)d(using)j(that)f(\002le)g(de-)573 2722 y(scriptor)-6 +b(,)23 b(the)g(port)g(is)g(\002rst)g(quietly)h(shifted)f(\(with)g +(another)g Fy(dup)p FC(\))f(to)h(some)g(other)573 2821 +y(\002le)e(descriptor)f(\(zer)o(oing)g(its)h(r)o(evealed)e(count\).)573 +2958 y(Since)54 b(Scheme)f(doesn't)i(pr)o(ovide)e(r)o(ead/write)g +(ports,)62 b Fy(dup->inport)50 b FC(and)573 3057 y Fy(dup->outport)27 +b FC(can)32 b(be)g(useful)h(for)f(getting)h(an)f(output)h(version)g(of) +f(an)g(input)573 3157 y(port,)20 b(or)f FB(vice)h(versa)p +FC(.)25 b(For)20 b(example,)f(if)g Fy(p)h FC(is)g(an)f(input)h(port)g +(open)g(on)g(a)g(tty)-9 b(,)19 b(and)h(we)573 3257 y(would)f(like)g(to) +g(do)g(output)g(to)h(that)e(tty)-9 b(,)19 b(we)g(can)g(simply)g(use)g +Fy(\(dup->outport)38 b(p\))573 3356 y FC(to)21 b(pr)o(oduce)f(an)g +(equivalent)h(output)g(port)g(for)g(the)g(tty)-9 b(.)365 +3558 y Fy(\(seek)42 b FB(fd/port)19 b(offset)i([whence])p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(integer)896 b FC(pr)o(ocedur)o(e)573 +3695 y(Reposition)36 b(the)e(I/O)h(cursor)f(for)g(a)f(\002le)i +(descriptor)e(or)i(port.)65 b FB(whence)35 b FC(is)f(one)573 +3786 y(of)39 b Fu(f)p Fy(seek/set)p FC(,)h Fy(seek/delta)p +FC(,)g Fy(seek/end)p Fu(g)p FC(,)g(and)f(defaults)f(to)i +Fy(seek/set)p FC(.)78 b(If)573 3878 y Fy(seek/set)p FC(,)33 +b(then)i FB(offset)f FC(is)g(an)f(absolute)h(index)g(into)g(the)g +(\002le;)40 b(if)34 b Fy(seek/delta)p FC(,)573 3969 y(then)c +FB(offset)g FC(is)h(a)e(r)o(elative)g(of)o(fset)g(fr)o(om)g(the)h(curr) +o(ent)g(I/O)g(cursor;)k(if)c Fy(seek/end)p FC(,)573 4060 +y(then)e FB(offset)g FC(is)g(a)f(r)o(elative)f(of)o(fset)h(fr)o(om)g +(the)h(end)f(of)h(\002le.)46 b(The)28 b FB(fd/port)e +FC(ar)o(gument)573 4151 y(may)e(be)f(a)g(port)h(or)g(an)g(integer)f +(\002le)h(descriptor)-6 b(.)34 b(Not)24 b(all)g(such)g(values)g(ar)o(e) +e(seek-)573 4243 y(able;)c(this)h(is)g(dependent)e(on)i(the)g(OS)f +(implementation.)25 b(The)19 b(r)o(eturn)e(value)h(is)g(the)573 +4334 y(r)o(esulting)j(position)h(of)f(the)g(I/O)g(cursor)g(in)g(the)g +(I/O)g(str)o(eam.)756 4499 y Fl(Oops:)74 b Fk(The)25 +b(curr)o(ent)f(implementation)h(doesn't)f(handle)h Fi(offset)f +Fk(ar)o(guments)756 4591 y(that)c(ar)o(e)e(not)h(immediate)f(integers)g +(\()p Fi(i.e.)o Fk(,)g(r)o(epr)o(esentable)f(in)i(30)g(bits\).)365 +4848 y Fy(\(tell)42 b FB(fd/port)p Fy(\))85 b Fu(\000)-14 +b(!)87 b FB(integer)1414 b FC(pr)o(ocedur)o(e)1756 5147 +y(31)p eop +%%Page: 32 38 +32 37 bop 888 614 a FC(Returns)24 b(the)f(position)h(of)f(the)g(I/O)g +(cursor)g(in)g(the)g(the)g(I/O)g(str)o(eam.)31 b(Not)23 +b(all)g(\002le)888 714 y(descriptors)29 b(or)g(ports)h(support)f +(cursor)o(-r)o(eporting;)j(this)e(is)g(dependent)e(on)i(the)888 +814 y(OS)21 b(implementation.)681 998 y Fy(\(open-file)39 +b FB(fname)21 b(\003ags)g([perms])p Fy(\))86 b Fu(\000)-15 +b(!)88 b FB(port)860 b FC(pr)o(ocedur)o(e)888 1135 y +FB(Perms)22 b FC(defaults)e(to)i Fy(#o666)p FC(.)k FB(Flags)21 +b FC(is)h(an)f(integer)g(bitmask,)h(composed)g(by)f(or)6 +b('ing)888 1235 y(together)34 b(constants)h(listed)f(in)g(table)f(3.1)f +(\(page)h(33\).)63 b(Y)-8 b(ou)35 b(must)f(use)g(exactly)888 +1334 y(one)d(of)f(the)h Fy(open/read)p FC(,)e Fy(open/write)p +FC(,)f(or)i Fy(open/read+write)24 b FC(\003ags.)55 b(The)30 +b(r)o(e-)888 1434 y(turned)h(port)g(is)h(an)f(input)g(port)g(if)g(the)g +FB(\003ags)g FC(permit)g(it,)j(otherwise)e(an)f(output)888 +1534 y(port.)h(R4RS/Scheme)23 b(48/scsh)f(do)h(not)h(have)e +(input/output)i(ports,)f(so)g(it's)h(one)888 1633 y(or)g(the)g(other)-6 +b(.)36 b(This)24 b(should)h(be)e(\002xed.)35 b(\(Y)-8 +b(ou)25 b(can)e(hack)h(simultaneous)h(i/o)g(on)g(a)888 +1733 y(\002le)i(by)g(opening)h(it)f(r/w)-8 b(,)28 b(taking)f(the)g(r)o +(esult)g(input)g(port,)h(and)e(duping)h(it)g(to)g(an)888 +1832 y(output)22 b(port)e(with)i Fy(dup->outport)p FC(.\))681 +2117 y Fy(\(open-input-file)37 b FB(fname)20 b([\003ags])p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(port)823 b FC(pr)o(ocedur)o(e)681 +2216 y Fy(\(open-output-fil)o(e)37 b FB(fname)21 b([\003ags)f(perms])p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(port)555 b FC(pr)o(ocedur)o(e)888 +2353 y(These)24 b(ar)o(e)f(equivalent)h(to)g Fy(open-file)p +FC(,)d(after)i(\002rst)h(setting)h(the)f(r)o(ead/write)f(bits)888 +2453 y(of)33 b(the)f FB(\003ags)h FC(ar)o(gument)f(to)g +Fy(open/read)d FC(or)k Fy(open/write)p FC(,)e(r)o(espectively)-9 +b(.)59 b FB(Flags)888 2552 y FC(defaults)20 b(to)h(zer)o(o)f(for)h +Fy(open-input-file)o FC(,)15 b(and)1071 2691 y Fy(\(bitwise-ior)39 +b(open/create)g(open/truncate\))888 2830 y FC(for)23 +b Fy(open-output-file)o FC(.)k(These)c(defaults)f(make)h(the)g(pr)o +(ocedur)o(es)e(backwar)o(ds-)888 2929 y(compatible)g(with)h(their)e +(unary)h(R4RS)g(de\002nitions.)681 3213 y Fy(\(open-fdes)39 +b FB(fname)21 b(\003ags)g([perms])p Fy(\))86 b Fu(\000)-15 +b(!)88 b FB(integer)764 b FC(pr)o(ocedur)o(e)888 3350 +y(Returns)22 b(a)e(\002le)h(descriptor)-6 b(.)681 3634 +y Fy(\(fdes-flags)39 b FB(fd/port)p Fy(\))85 b Fu(\000)-14 +b(!)87 b FB(integer)1152 b FC(pr)o(ocedur)o(e)681 3734 +y Fy(\(set-fdes-flags)37 b FB(fd/port)19 b(integer)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(unde\002ned)627 b +FC(pr)o(ocedur)o(e)888 3871 y(These)25 b(pr)o(ocedur)o(es)e(allow)h(r)o +(eading)g(and)g(writing)h(of)g(an)f(open)h(\002le's)g(\003ags.)37 +b(The)888 3971 y(only)27 b(such)g(\003ag)f(de\002ned)g(by)i(P)t +Ft(O)t(S)t(I)t(X)i FC(is)d Fy(fdflags/close-o)o(n-e)o(xe)o(c)p +FC(;)c(your)j(Unix)888 4070 y(implementation)c(may)f(pr)o(ovide)f +(others.)888 4201 y(These)d(pr)o(ocedur)o(es)e(should)j(not)f(be)g +(particularly)f(useful)h(to)g(the)g(pr)o(ogrammer)-6 +b(,)16 b(as)888 4301 y(the)22 b(scsh)f(r)o(untime)h(alr)o(eady)d(pr)o +(ovides)i(automatic)g(contr)o(ol)g(of)g(the)h(close-on-exec)888 +4400 y(pr)o(operty)-9 b(.)61 b(Unr)o(evealed)30 b(ports)k(always)e +(have)g(their)h(\002le)g(descriptors)g(marked)888 4500 +y(close-on-exec,)28 b(as)e(they)h(can)f(be)h(closed)f(when)h(the)g +(scsh)g(pr)o(ocess)g(execs)f(a)g(new)888 4599 y(pr)o(ogram.)48 +b(Whenever)28 b(the)h(user)f(r)o(eveals)f(or)h(unr)o(eveals)g(a)g +(port's)g(\002le)h(descrip-)888 4699 y(tor)-6 b(,)23 +b(the)f(r)o(untime)h(automatically)f(sets)g(or)g(clears)g(the)g(\003ag) +g(for)g(the)g(pr)o(ogrammer)-6 b(.)888 4799 y(Pr)o(ogrammers)29 +b(that)f(manipulate)h(this)h(\003ag)e(should)i(be)f(awar)o(e)e(of)h +(these)h(extra,)888 4898 y(automatic)21 b(operations.)2071 +5147 y(32)p eop +%%Page: 33 39 +33 38 bop 1158 601 a FC(Allowed)21 b(operations)272 b +Fy(Status)41 b(flag)p 1108 634 1999 4 v 488 701 a FA(Open+Get+Set)97 +b FC(These)21 b(\003ags)g(can)f(be)h(used)1158 800 y(in)g +Fy(open-file)p FC(,)1158 900 y Fy(fdes-status)p FC(,)16 +b(and)1158 1000 y Fy(set-fdes-status)f FC(calls.)2158 +701 y Fy(open/append)2158 800 y(open/non-blockin)o(g)2158 +900 y(open/async)39 b FC(\(Non-)r(P)t Ft(O)t(S)t(I)t(X)r +FC(\))2158 1000 y Fy(open/fsync)g FC(\(Non-)r(P)t Ft(O)t(S)t(I)t(X)r +FC(\))p 1108 1033 V 658 1099 a FA(Open+Get)98 b FC(These)21 +b(\003ags)g(can)f(be)h(used)1158 1199 y(in)g Fy(open-file)c +FC(and)1158 1298 y Fy(fdes-status)f FC(calls,)21 b(but)1158 +1398 y(ar)o(e)e(ignor)o(ed)i(by)1158 1498 y Fy(set-fdes-status)p +FC(.)2158 1099 y Fy(open/read)2158 1199 y(open/write)2158 +1298 y(open/read+write)2158 1398 y(open/access-mask)p +1108 1531 V 846 1597 a FA(Open)99 b FC(These)21 b(\003ags)g(ar)o(e)e +(only)1158 1697 y(r)o(elevant)h(in)h Fy(open-file)1158 +1797 y FC(calls;)g(they)g(ar)o(e)e(ignor)o(ed)1158 1896 +y(by)i Fy(fdes-status)16 b FC(and)1158 1996 y Fy(set-fdes-status)f +FC(calls.)2158 1597 y Fy(open/create)2158 1697 y(open/exclusive)2158 +1797 y(open/no-control-)o(tt)o(y)2158 1896 y(open/truncate)365 +2166 y FC(T)-8 b(able)38 b(3.1:)60 b(Status)38 b(\003ags)g(for)g +Fy(open-file)p FC(,)h Fy(fdes-status)34 b FC(and)k Fy(set-fdes-status)p +FC(.)365 2266 y(Only)23 b(P)t Ft(O)t(S)t(I)t(X)g FC(\003ags)d(ar)o(e)e +(guaranteed)h(to)h(be)f(pr)o(esent;)h(your)g(operating)f(system)i(may)e +(de-)365 2365 y(\002ne)25 b(others.)37 b(The)24 b Fy(open/access-mask) +18 b FC(value)24 b(is)g(not)i(an)e(actual)f(\003ag,)j(but)e(a)g(bit)g +(mask)365 2465 y(used)j(to)g(select)g(the)f(\002eld)h(for)g(the)g +Fy(open/read)p FC(,)d Fy(open/write)e FC(and)27 b Fy(open/read+write) +365 2565 y FC(bits.)365 2965 y Fy(\(fdes-status)39 b +FB(fd/port)p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(integer)1109 +b FC(pr)o(ocedur)o(e)365 3064 y Fy(\(set-fdes-status)37 +b FB(fd/port)19 b(integer)p Fy(\))88 b Fu(\000)-15 b(!)87 +b FB(unde\002ned)584 b FC(pr)o(ocedur)o(e)573 3205 y(These)20 +b(pr)o(ocedur)o(es)f(allow)i(r)o(eading)e(and)i(writing)g(of)f(an)h +(open)g(\002le's)g(status)f(\003ags)573 3305 y(\(table)g(3.1\).)573 +3438 y(Note)j(that)h(this)g(\002le-descriptor)f(state)g(is)h(shar)o(ed) +e(between)h(\002le)h(descriptors)f(cr)o(e-)573 3537 y(ated)h(by)h +Fy(dup)p FC(\227if)e(you)j(cr)o(eate)d(port)i FB(b)g +FC(by)g(applying)g Fy(dup)f FC(to)h(port)g FB(a)p FC(,)g(and)g(change) +573 3637 y FB(b)p FC('s)c(status)g(\003ags,)g(you)g(will)h(also)f(have) +f(changed)g FB(a)p FC('s)h(status)g(\003ags.)365 3927 +y Fy(\(pipe\))85 b Fu(\000)-14 b(!)87 b FB([rport)20 +b(wport)o(])1475 b FC(pr)o(ocedur)o(e)573 4068 y(Returns)21 +b(two)h(ports,)e(the)h(r)o(ead)e(and)i(write)g(end-points)g(of)f(a)h +(Unix)f(pipe.)365 4359 y Fy(\(read-string)39 b FB(nbytes)21 +b([fd/port])p Fy(\))85 b Fu(\000)-15 b(!)87 b FB(string)21 +b(or)g Fy(#f)648 b FC(pr)o(ocedur)o(e)365 4458 y Fy(\(read-string!)39 +b FB(str)20 b([fd/port)f(start)i(end])p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(nr)o(ead)21 b(or)f Fy(#f)428 b FC(pr)o(ocedur)o(e)573 +4599 y(These)28 b(calls)f(r)o(ead)f(exactly)i(as)f(much)i(data)d(as)i +(you)g(r)o(equested,)h(unless)f(ther)o(e)f(is)573 4699 +y(not)33 b(enough)h(data)e(\(eof\).)61 b Fy(read-string!)28 +b FC(r)o(eads)k(the)h(data)e(into)j(string)g FB(str)f +FC(at)573 4799 y(the)21 b(indices)g(in)h(the)f(half-open)g(interval)g +Fn([)p FB(start)p Fz(;)14 b FB(end)o Fn(\))p FC(;)22 +b(the)f(default)f(interval)h(is)g(the)573 4898 y(whole)30 +b(string:)42 b FB(start)c Fn(=)f(0)29 b FC(and)f FB(end)38 +b Fn(=)g Fy(\(string-length)g FB(string)o Fy(\))p FC(.)50 +b(They)29 b(will)1756 5147 y(33)p eop +%%Page: 34 40 +34 39 bop 888 614 a FC(persistently)29 b(r)o(etry)e(on)i(partial)e(r)o +(eads)g(and)h(when)h(interr)o(upted)f(until)g(\(1\))f(err)o(or)-6 +b(,)888 714 y(\(2\))24 b(eof,)h(or)g(\(3\))e(the)i(input)g(r)o(equest)g +(is)g(completely)g(satis\002ed.)37 b(Partial)24 b(r)o(eads)f(can)888 +814 y(occur)e(when)g(r)o(eading)f(fr)o(om)g(an)h(intermittent)h(sour)o +(ce,)e(such)h(as)f(a)h(pipe)f(or)h(tty)-9 b(.)888 944 +y Fy(read-string)21 b FC(r)o(eturns)k(the)h(string)g(r)o(ead;)g +Fy(read-string!)21 b FC(r)o(eturns)k(the)h(number)888 +1044 y(of)f(characters)e(r)o(ead.)36 b(They)25 b(both)h(r)o(eturn)e +(false)g(at)g(eof.)37 b(A)25 b(r)o(equest)f(to)h(r)o(ead)e(zer)o(o)888 +1143 y(bytes)e(r)o(eturns)f(immediately)-9 b(,)21 b(with)g(no)h(eof)e +(check.)888 1274 y(The)g(values)e(of)i FB(start)f FC(and)g +FB(end)g FC(must)h(specify)f(a)f(well-de\002ned)h(interval)g(in)h +FB(str)p FC(,)f FB(i.e.)p FC(,)888 1373 y Fn(0)k Fu(\024)g +FB(start)f Fu(\024)h FB(end)g Fu(\024)g Fy(\(string-length)37 +b FB(str)q Fy(\))o FC(.)888 1504 y(Any)26 b(partially-r)o(ead)d(data)i +(is)h(included)f(in)h(the)g(err)o(or)f(exception)h(packet.)39 +b(Err)o(or)888 1604 y(r)o(eturns)21 b(on)g(non-blocking)h(input)g(ar)o +(e)d(consider)o(ed)h(an)h(err)o(or)-6 b(.)681 1787 y +Fy(\(read-string/par)o(ti)o(al)37 b FB(nbytes)21 b([fd/port])p +Fy(\))85 b Fu(\000)-15 b(!)88 b FB(string)20 b(or)h Fy(#f)299 +b FC(pr)o(ocedur)o(e)681 1887 y Fy(\(read-string!/pa)o(rt)o(ial)37 +b FB(str)20 b([fd/port)f(start)h(end])p Fy(\))83 b Fu(\000)-14 +b(!)84 b FB(nr)o(ead)20 b(or)h Fy(#f)86 b FC(pr)o(ocedur)o(e)888 +2024 y(These)36 b(ar)o(e)d(atomic)j(best-ef)o(fort/forwar)o(d-pr)o(ogr) +o(ess)31 b(calls.)69 b(Best)35 b(ef)o(fort:)54 b(they)888 +2123 y(may)31 b(r)o(ead)e(less)i(than)g(you)h(r)o(equest)e(if)h(ther)o +(e)f(is)h(a)f(lesser)h(amount)h(of)e(data)g(im-)888 2223 +y(mediately)d(available)e(\()p FB(e.g.)o FC(,)i(because)f(you)h(ar)o(e) +e(r)o(eading)h(fr)o(om)g(a)g(pipe)h(or)f(a)g(tty\).)888 +2322 y(Forwar)o(d)c(pr)o(ogr)o(ess:)28 b(if)23 b(no)g(data)e(is)i +(immediately)g(available)e(\()p FB(e.g.)o FC(,)i(empty)g(pipe\),)888 +2422 y(they)i(will)g(block.)35 b(Ther)o(efor)o(e,)23 +b(if)h(you)h(r)o(equest)e(an)h Fz(n)29 b(>)g Fn(0)24 +b FC(byte)g(r)o(ead,)f(while)h(you)888 2522 y(may)32 +b(not)f(get)h(everything)f(you)h(asked)e(for)-6 b(,)34 +b(you)d(will)h(always)f(get)g(something)888 2621 y(\(barring)20 +b(eof\).)888 2752 y(Ther)o(e)25 b(is)h(one)g(case)f(in)h(which)h(the)f +(forwar)o(d-pr)o(ogr)o(ess)d(guarantee)h(is)i(cancelled:)888 +2851 y(when)20 b(the)f(pr)o(ogrammer)e(explicitly)i(sets)g(the)g(port)g +(to)g(non-blocking)i(i/o.)k(In)19 b(this)888 2951 y(case,)31 +b(if)f(no)g(data)f(is)h(immediately)f(available,)i(the)e(pr)o(ocedur)o +(e)f(will)i(not)h(block,)888 3051 y(but)21 b(will)h(immediately)e(r)o +(eturn)g(a)h(zer)o(o-byte)e(r)o(ead.)888 3181 y Fy(read-string/parti)o +(al)37 b FC(r)o(eads)42 b(the)i(data)f(into)h(a)g(fr)o(eshly)f +(allocated)g(string,)888 3281 y(which)24 b(it)f(r)o(eturns)f(as)h(its)g +(value.)31 b Fy(read-string!/par)o(ti)o(al)16 b FC(r)o(eads)22 +b(the)h(data)e(into)888 3380 y(string)30 b FB(str)e FC(at)g(the)h +(indices)g(in)g(the)f(half-open)g(interval)g Fn([)p FB(start)p +Fz(;)14 b FB(end)p Fn(\))p FC(;)32 b(the)d(default)888 +3480 y(interval)18 b(is)h(the)g(whole)g(string:)25 b +FB(start)e Fn(=)f(0)c FC(and)g FB(end)23 b Fn(=)g Fy(\(string-length)38 +b FB(string)p Fy(\))o FC(.)888 3580 y(The)20 b(values)e(of)i +FB(start)f FC(and)g FB(end)g FC(must)h(specify)f(a)f(well-de\002ned)h +(interval)g(in)h FB(str)p FC(,)f FB(i.e.)p FC(,)888 3679 +y Fn(0)30 b Fu(\024)g FB(start)g Fu(\024)g FB(end)g Fu(\024)g +Fy(\(string-length)38 b FB(str)p Fy(\))p FC(.)f(It)25 +b(r)o(eturns)f(the)g(number)h(of)g(bytes)888 3779 y(r)o(ead.)888 +3909 y(A)c(r)o(equest)f(to)h(r)o(ead)e(zer)o(o)h(bytes)h(r)o(eturns)f +(immediatedly)-9 b(,)20 b(with)i(no)f(eof)g(check.)888 +4040 y(In)26 b(sum,)i(ther)o(e)c(ar)o(e)h(only)h(thr)o(ee)f(ways)h(you) +g(can)f(get)h(a)f(zer)o(o-byte)f(r)o(ead:)34 b(\(1\))24 +b(you)888 4139 y(r)o(equest)k(one,)h(\(2\))d(you)i(turn)g(on)g +(non-blocking)h(i/o,)h(or)e(\(3\))e(you)i(try)g(to)g(r)o(ead)d(at)888 +4239 y(eof.)888 4370 y(These)g(ar)o(e)e(the)i(r)o(outines)f(to)h(use)g +(for)f(non-blocking)i(input.)38 b(They)24 b(ar)o(e)g(also)g(use-)888 +4469 y(ful)k(when)h(you)f(wish)h(to)f(ef)o(\002ciently)g(pr)o(ocess)f +(data)g(in)h(lar)o(ge)f(blocks,)j(and)e(your)888 4569 +y(algorithm)20 b(is)f(insensitive)h(to)f(the)g(block)g(size)g(of)g(any) +f(particular)g(r)o(ead)f(operation.)681 4753 y Fy(\(select)84 +b FB(rvec)21 b(wvec)f(evec)h([timeout])p Fy(\))85 b Fu(\000)-14 +b(!)87 b FB([rvec')20 b(wvec')h(evec'])308 b FC(pr)o(ocedur)o(e)681 +4852 y Fy(\(select!)40 b FB(rvec)21 b(wvec)f(evec)h([timeout])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB([nr)21 b(nw)g(ne])562 +b FC(pr)o(ocedur)o(e)2071 5147 y(34)p eop +%%Page: 35 41 +35 40 bop 573 614 a FC(The)26 b Fy(select)e FC(pr)o(ocedur)o(e)h +(allows)i(a)e(pr)o(ocess)h(to)h(block)g(and)f(wait)g(for)g(events)h(on) +573 714 y(multiple)c(I/O)g(channels.)31 b(The)23 b FB(rvec)f +FC(and)g FB(evec)h FC(ar)o(guments)f(ar)o(e)f(vectors)i(of)f(input)573 +814 y(ports)31 b(and)f(integer)h(\002le)f(descriptors;)36 +b FB(wvec)30 b FC(is)h(a)f(vector)g(of)h(output)g(ports)g(and)573 +913 y(integer)f(\002le)g(descriptors.)54 b(The)30 b(pr)o(ocedur)o(e)f +(r)o(eturns)g(thr)o(ee)h(vectors)g(whose)h(el-)573 1013 +y(ements)f(ar)o(e)f(subsets)i(of)f(the)g(corr)o(esponding)g(ar)o +(guments.)54 b(Every)29 b(element)i(of)573 1112 y FB(rvec')22 +b FC(is)g(r)o(eady)f(for)g(input;)i(every)f(element)g(of)g +FB(wvec')g FC(is)g(r)o(eady)e(for)i(output;)h(every)573 +1212 y(element)e(of)f FB(evec')h FC(has)g(an)g(exceptional)f(condition) +i(pending.)573 1350 y(The)d Fy(select)e FC(call)h(will)i(block)g(until) +f(at)g(least)g(one)g(of)g(the)h(I/O)f(channels)h(passed)e(to)573 +1450 y(it)i(is)g(r)o(eady)e(for)h(operation.)26 b(The)19 +b FB(timeout)g FC(value)g(can)h(be)f(used)g(to)h(for)o(ce)f(the)h(call) +f(to)573 1549 y(time-out)i(after)f(a)h(given)g(number)g(of)h(seconds.)k +(It)c(defaults)e(to)h(the)h(special)e(value)573 1649 +y Fy(#f)p FC(,)25 b(meaning)h(wait)f(inde\002nitely)-9 +b(.)40 b(A)25 b(zer)o(o)f(value)g(can)h(be)g(used)g(to)h(poll)g(the)f +(I/O)573 1749 y(channels.)573 1886 y(If)30 b(an)h(I/O)g(channel)g +(appears)f(mor)o(e)g(than)h(once)h(in)f(a)f(given)h(vector)o(\227per)o +(haps)573 1986 y(occuring)25 b(once)g(as)f(a)g(Scheme)h(port,)g(and)f +(once)h(as)g(the)f(port's)h(underlying)h(inte-)573 2086 +y(ger)g(\002le)h(descriptor)o(\227only)f(one)h(of)g(these)g(two)g(r)o +(efer)o(ences)d(may)i(appear)f(in)i(the)573 2185 y(r)o(eturned)h +(vector)-6 b(.)49 b(Buf)o(fer)o(ed)26 b(I/O)k(ports)f(ar)o(e)e(handled) +i(specially\227if)f(an)h(input)573 2285 y(port's)24 b(buf)o(fer)e(is)j +(not)f(empty)-9 b(,)25 b(or)f(an)g(output)g(port's)g(buf)o(fer)f(is)h +(not)h(yet)f(full,)g(then)573 2385 y(these)32 b(ports)g(ar)o(e)e +(immediately)h(consider)o(ed)g(eligible)h(for)g(I/O)g(without)h(using) +573 2484 y(the)25 b(actual,)g(primitive)g Fy(select)d +FC(system)j(call)g(to)g(check)g(the)g(underlying)g(\002le)g(de-)573 +2584 y(scriptor)-6 b(.)51 b(This)29 b(works)h(pr)o(etty)f(well)g(for)g +(buf)o(fer)o(ed)e(input)i(ports,)j(but)d(is)g(a)g(little)573 +2683 y(pr)o(oblematic)20 b(for)g(buf)o(fer)o(ed)e(output)k(ports.)573 +2821 y(The)j Fy(select!)d FC(pr)o(ocedur)o(e)h(is)i(similar)-6 +b(,)26 b(but)f(indicates)g(the)g(subset)h(of)f(active)f(I/O)573 +2921 y(channels)k(by)f(side-ef)o(fecting)f(the)i(ar)o(gument)f +(vectors.)46 b(Non-active)27 b(I/O)h(chan-)573 3021 y(nels)k(in)g(the)g +(ar)o(gument)f(vectors)g(ar)o(e)g(overwritten)g(with)i +Fy(#f)e FC(values.)57 b(The)32 b(call)573 3120 y(r)o(eturns)f(the)g +(number)g(of)h(active)e(elements)i(r)o(emaining)f(in)h(each)e(vector)-6 +b(.)57 b(As)31 b(a)573 3220 y(convenience,)24 b(the)g(vectors)g(passed) +f(in)h(to)g Fy(select!)d FC(ar)o(e)h(allowed)i(to)g(contain)g +Fy(#f)573 3319 y FC(values)c(as)h(well)g(as)f(integers)h(and)g(ports.) +756 3506 y Fl(Remark:)56 b Fk(I)20 b(have)h(found)f(the)g +Fh(select!)i Fk(interface)e(to)g(be)h(the)f(mor)o(e)f(useful)g(of)756 +3598 y(the)25 b(two.)44 b(After)24 b(the)i(system)f(call,)h(it)g +(allows)f(you)f(to)i(check)f(a)h(speci\002c)f(I/O)756 +3689 y(channel)20 b(in)f(constant)h(time.)365 3917 y +Fy(\(write-string)39 b FB(string)20 b([fd/port)f(start)i(end])p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(unde\002ned)373 b +FC(pr)o(ocedur)o(e)573 4063 y(This)33 b(pr)o(ocedur)o(e)e(writes)i(all) +f(the)h(data)e(r)o(equested.)60 b(If)33 b(the)g(pr)o(ocedur)o(e)d +(cannot)573 4163 y(perform)d(the)h(write)g(with)h(a)e(single)i(kernel)f +(call)g(\(due)f(to)h(interr)o(upts)g(or)g(partial)573 +4262 y(writes\),)18 b(it)f(will)i(perform)e(multiple)h(write)f +(operations)h(until)g(all)g(the)f(data)g(is)h(writ-)573 +4362 y(ten)25 b(or)h(an)f(err)o(or)f(has)h(occurr)o(ed.)38 +b(A)25 b(non-blocking)i(i/o)f(err)o(or)f(is)g(consider)o(ed)g(an)573 +4462 y(err)o(or)-6 b(.)24 b(\(Err)o(or)17 b(exception)j(packets)e(for)h +(this)h(syscall)f(include)h(the)f(amount)h(of)f(data)573 +4561 y(partially)h(transferr)o(ed)f(befor)o(e)g(the)i(err)o(or)f +(occurr)o(ed.\))573 4699 y(The)35 b(data)f(written)i(ar)o(e)d(the)j +(characters)e(of)h FB(string)g FC(in)h(the)f(half-open)g(interval)573 +4799 y Fn([)p FB(start)p Fz(;)14 b FB(end)p Fn(\))p FC(.)83 +b(The)40 b(default)e(interval)i(is)g(the)g(whole)h(string:)64 +b FB(start)59 b Fn(=)f(0)39 b FC(and)573 4898 y FB(end)26 +b Fn(=)f Fy(\(string-length)38 b FB(string)p Fy(\))p +FC(.)30 b(The)22 b(values)g(of)h FB(start)f FC(and)g +FB(end)g FC(must)h(specify)1756 5147 y(35)p eop +%%Page: 36 42 +36 41 bop 888 614 a FC(a)17 b(well-de\002ned)f(interval)g(in)i +FB(str)p FC(,)f FB(i.e.)p FC(,)g Fn(0)23 b Fu(\024)g +FB(start)f Fu(\024)h FB(end)g Fu(\024)g Fy(\(string-length)37 +b FB(str)q Fy(\))o FC(.)888 714 y(A)21 b(zer)o(o-byte)e(write)i(r)o +(eturns)f(immediately)-9 b(,)20 b(with)i(no)f(err)o(or)-6 +b(.)888 849 y(Output)28 b(to)f(buf)o(fer)o(ed)d(ports:)38 +b Fy(write-string)p FC('s)22 b(ef)o(forts)k(end)g(as)h(soon)h(as)e(all) +h(the)888 949 y(data)g(has)h(been)f(placed)g(in)h(the)g(output)g(buf)o +(fer)-6 b(.)45 b(Err)o(ors)27 b(and)g(tr)o(ue)h(output)g(may)888 +1048 y(not)22 b(happen)e(until)i(a)e(later)g(time,)h(of)g(course.)681 +1294 y Fy(\(write-string/pa)o(rt)o(ial)37 b FB(string)19 +b([fd/port)f(start)h(end])p Fy(\))74 b Fu(\000)-14 b(!)75 +b FB(nwritten)87 b FC(pr)o(ocedur)o(e)888 1437 y(This)62 +b(r)o(outine)e(is)h(the)g(atomic)g(best-ef)o(fort/forwar)o(d-pr)o(ogr)o +(ess)c(analog)k(to)888 1537 y Fy(write-string)p FC(.)c(It)32 +b(r)o(eturns)g(the)h(number)g(of)g(bytes)f(written,)k(which)e(may)e(be) +888 1637 y(less)c(than)g(you)h(asked)e(for)-6 b(.)46 +b(Partial)27 b(writes)h(can)g(occur)f(when)i(\(1\))d(we)i(write)g(of)o +(f)888 1736 y(the)23 b(physical)g(end)f(of)g(the)h(media,)f(\(2\))f +(the)h(write)h(is)g(interrr)o(upted,)f(or)g(\(3\))f(the)i(\002le)888 +1836 y(descriptor)e(is)g(set)g(for)f(non-blocking)j(i/o.)888 +1971 y(If)g(the)h(\002le)g(descriptor)f(is)h(not)g(set)f(up)h(for)f +(non-blocking)i(i/o,)g(then)f(a)f(successful)888 2071 +y(r)o(eturn)d(fr)o(om)h(these)f(pr)o(ocedur)o(es)f(makes)i(a)f(forwar)o +(d)f(pr)o(ogr)o(ess)h(guarantee\227that)888 2170 y(is,)h(a)f(partial)g +(write)h(took)h(place)e(of)g(at)h(least)f(one)h(byte:)988 +2341 y Fu(\017)41 b FC(If)23 b(we)g(ar)o(e)f(at)g(the)i(end)f(of)g +(physical)g(media,)g(and)g(no)h(write)f(takes)g(place,)f(an)1071 +2441 y(err)o(or)e(exception)g(is)i(raised.)i(So)d(a)f(r)o(eturn)g +(implies)i(we)e(wr)o(ote)h FB(something)p FC(.)988 2576 +y Fu(\017)41 b FC(If)28 b(the)h(call)f(is)h(interr)o(upted)f(after)f(a) +h(partial)g(transfer)-6 b(,)29 b(it)g(r)o(eturns)f(immedi-)1071 +2675 y(ately)-9 b(.)30 b(But)22 b(if)g(the)g(call)g(is)h(interr)o +(upted)f(befor)o(e)f(any)i(data)e(transfer)-6 b(,)21 +b(then)i(the)1071 2775 y(write)e(is)g(r)o(etried.)888 +2946 y(If)e(we)g(r)o(equest)g(a)g(zer)o(o-byte)f(write,)h(then)g(the)h +(call)f(immediately)g(r)o(eturns)g(0.)24 b(If)19 b(the)888 +3045 y(\002le)24 b(descriptor)g(is)g(set)g(for)f(non-blocking)i(i/o,)h +(then)e(the)g(call)f(may)h(r)o(eturn)f(0)g(if)h(it)888 +3145 y(was)f(unable)f(to)h(immediately)f(write)h(anything)g(\()p +FB(e.g.)o FC(,)g(full)f(pipe\).)30 b(Barring)22 b(these)888 +3245 y(two)c(cases,)g(a)f(write)g(either)h(r)o(eturns)f +FB(nwritten)23 b Fz(>)f Fn(0)p FC(,)c(or)f(raises)h(an)f(err)o(or)f +(exception.)888 3380 y(Non-blocking)36 b(i/o)f(is)g(only)g(available)e +(on)i(\002le)f(descriptors)g(and)g(unbuf)o(fer)o(ed)888 +3479 y(ports.)26 b(Doing)21 b(non-blocking)h(i/o)e(to)h(a)e(buf)o(fer)o +(ed)e(port)j(is)h(not)f(well-de\002ned,)f(and)888 3579 +y(is)i(an)g(err)o(or)f(\(the)g(pr)o(oblem)h(is)g(the)g(subsequent)g +(\003ush)h(operation\).)681 3985 y FA(3.2.7)81 b(Buf)o(fered)20 +b(I/O)681 4172 y FC(Scheme)30 b(48)f(ports)i(use)f(buf)o(fer)o(ed)e +(I/O\227data)i(is)g(transferr)o(ed)f(to)h(or)h(fr)o(om)f(the)g(OS)h(in) +681 4272 y(blocks.)43 b(Scsh)26 b(pr)o(ovides)g(contr)o(ol)h(of)g(this) +g(mechanism:)37 b(the)27 b(pr)o(ogrammer)f(may)g(for)o(ce)681 +4372 y(saved-up)f(output)i(data)f(to)h(be)f(transferr)o(ed)f(to)i(the)g +(OS)g(when)g(he)g(chooses,)i(and)d(may)681 4471 y(also)31 +b(choose)h(which)h(I/O)e(buf)o(fering)g(policy)g(to)h(employ)g(for)f(a) +g(given)g(port)h(\(or)f(turn)681 4571 y(buf)o(fering)20 +b(of)o(f)f(completely\).)805 4699 y(It)24 b(can)g(be)f(useful)h(to)g +(turn)g(I/O)g(buf)o(fering)f(of)o(f)g(in)h(some)g(cases,)g(for)f +(example)g(when)681 4799 y(an)16 b(I/O)i(str)o(eam)e(is)h(to)g(be)f +(shar)o(ed)g(by)h(multiple)g(subpr)o(ocesses.)24 b(For)17 +b(this)h(r)o(eason,)e(scsh)i(al-)681 4898 y(locates)k(an)g(unbuf)o(fer) +o(ed)f(port)h(for)g(\002le)h(descriptor)f(0)g(at)g(start-up)g(time.)31 +b(Because)21 b(shells)2071 5147 y(36)p eop +%%Page: 37 43 +37 42 bop 365 614 a FC(fr)o(equently)31 b(shar)o(e)e(stdin)i(with)h +(subpr)o(ocesses,)g(if)f(the)f(shell)i(does)e(buf)o(fer)o(ed)e(r)o +(eads,)j(it)365 714 y(might)e(\223steal\224)d(input)j(intended)e(for)h +(a)f(subpr)o(ocess.)46 b(For)28 b(this)g(r)o(eason,)h(all)e(shells,)j +(in-)365 814 y(cluding)20 b(sh,)h(csh,)f(and)f(scsh,)h(r)o(ead)e(stdin) +i(unbuf)o(fer)o(ed.)j(Applications)d(that)g(can)f(tolerate)365 +913 y(buf)o(fer)o(ed)d(input)j(on)g(stdin)g(can)g(r)o(eset)e +Fy(\(current-input-po)o(rt)o(\))12 b FC(to)19 b(block)g(buf)o(fering)f +(for)365 1013 y(higher)k(performance.)365 1169 y Fy(\(set-port-bufferi) +o(ng)37 b FB(port)20 b(policy)g([size])p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(unde\002ned)377 b FC(pr)o(ocedur)o(e)573 +1316 y(This)21 b(pr)o(ocedur)o(e)d(allows)k(the)e(pr)o(ogrammer)g(to)h +(assign)g(a)f(particular)f(I/O)i(buf)o(fer)o(-)573 1416 +y(ing)30 b(policy)h(to)f(a)g(port,)i(and)d(to)i(choose)f(the)g(size)g +(of)g(the)g(associated)f(buf)o(fer)-6 b(.)52 b(It)573 +1516 y(may)20 b(only)h(be)f(used)g(on)g(new)h(ports,)f +FB(i.e.)p FC(,)g(befor)o(e)f(I/O)h(is)h(performed)e(on)h(the)h(port.) +573 1615 y(Ther)o(e)f(ar)o(e)f(thr)o(ee)h(buf)o(fering)g(policies)h +(that)g(may)f(be)h(chosen:)805 1771 y Fy(bufpol/block)161 +b FC(General)21 b(block)g(buf)o(fering)f(\(general)g(default\))805 +1870 y Fy(bufpol/line)205 b FC(Line)21 b(buf)o(fering)f(\(tty)h +(default\))805 1970 y Fy(bufpol/none)205 b FC(Dir)o(ect)21 +b(I/O\227no)h(buf)o(fering)573 2123 y(The)27 b(line)h(buf)o(fering)f +(policy)h(\003ushes)h(output)f(whenever)f(a)g(newline)h(is)g(output;) +573 2222 y(whenever)18 b(the)h(buf)o(fer)d(is)j(full;)g(or)g(whenever)f +(an)g(input)h(is)g(r)o(ead)d(fr)o(om)i(stdin.)26 b(Line)573 +2322 y(buf)o(fering)20 b(is)h(the)g(default)e(for)i(ports)g(open)g(on)g +(terminal)g(devices.)573 2461 y(The)30 b FB(size)h FC(ar)o(gument)e(r)o +(equests)i(an)f(I/O)g(buf)o(fer)f(of)h FB(size)h FC(bytes.)54 +b(If)29 b(not)i(given,)i(a)573 2561 y(r)o(easonable)22 +b(default)g(is)h(used;)g(if)g(given)g(and)g(zer)o(o,)f(buf)o(fering)g +(is)h(turned)g(of)o(f)f(\()p FB(i.e.)p FC(,)573 2660 +y FB(size)h Fn(=)g(0)d FC(for)h(any)g(policy)g(is)g(equivalent)g(to)g +FB(policy)h Fn(=)h Fy(bufpol/none)-5 b FC(\).)365 2970 +y Fy(\(force-output)39 b FB([fd/port])p Fy(\))84 b Fu(\000)-14 +b(!)87 b FB(unde\002ned)915 b FC(pr)o(ocedur)o(e)573 +3118 y(This)27 b(pr)o(ocedur)o(e)e(does)i(nothing)i(when)f(applied)e +(to)h(an)g(integer)g(\002le)g(descriptor)573 3218 y(or)18 +b(unbuf)o(fer)o(ed)e(port.)25 b(It)18 b(\003ushes)h(buf)o(fer)o(ed)d +(output)j(when)g(applied)e(to)h(a)g(buf)o(fer)o(ed)573 +3317 y(port,)i(and)h(raises)f(a)g(write-err)o(or)g(exception)h(on)g +(err)o(or)-6 b(.)24 b(Returns)e(no)f(value.)365 3627 +y Fy(\(flush-all-ports\))80 b Fu(\000)-14 b(!)87 b FB(unde\002ned)1111 +b FC(pr)o(ocedur)o(e)573 3775 y(This)21 b(pr)o(ocedur)o(e)e(\003ushes)j +(all)e(open)h(output)h(ports)f(with)g(buf)o(fer)o(ed)d(data.)365 +4205 y FA(3.2.8)81 b(File)20 b(locking)365 4400 y FC(Scsh)i(pr)o +(ovides)h(P)t Ft(O)t(S)t(I)t(X)j FC(advisory)c(\002le)g(locking.)30 +b FB(Advisory)21 b FC(locks)h(ar)o(e)f(locks)h(that)g(can)g(be)365 +4500 y(checked)i(by)g(user)g(code,)h(but)f(do)g(not)h(af)o(fect)e +(other)h(I/O)h(operations.)36 b(For)25 b(example,)f(if)365 +4599 y(a)d(pr)o(ocess)f(has)h(an)f(exclusive)h(lock)g(on)h(a)e(r)o +(egion)h(of)f(a)h(\002le,)g(other)g(pr)o(ocesses)f(will)h(not)h(be)365 +4699 y(able)h(to)g(obtain)g(locks)h(on)g(that)f(r)o(egion)g(of)g(the)g +(\002le,)g(but)g(they)g(will)h(still)g(be)f(able)f(to)h(r)o(ead)365 +4799 y(and)16 b(write)g(the)g(\002le)g(with)h(no)g(hindrance.)23 +b(Using)17 b(advisory)e(locks)i(r)o(equir)o(es)e(cooperation)365 +4898 y(amongst)22 b(the)f(agents)g(accessing)f(the)h(shar)o(ed)f(r)o +(esour)o(ce.)1756 5147 y(37)p eop +%%Page: 38 44 +38 43 bop 888 614 a Fl(Remark:)94 b Fk(Unfortunately)-8 +b(,)24 b(P)t Fg(O)t(S)t(I)t(X)f Fk(\002le)f(locks)f(ar)o(e)g +(associated)h(with)g(actual)h(\002les,)888 706 y(not)d(with)f +(associated)f(open)h(\002le)f(descriptors.)j(Once)e(a)g(pr)o(ocess)d +(locks)i(a)h(\002le,)f(using)888 797 y(some)f(\002le)g(descriptor)e +Fi(fd)q Fk(,)i(the)h(next)f(time)h Fi(any)f Fk(\002le)g(descriptor)e(r) +o(efer)o(encing)h(that)j(\002le)888 888 y(is)e(closed,)f(all)i +(associated)f(locks)f(ar)o(e)h(r)o(eleased.)j(This)d(sever)o(ely)e +(limits)i(the)h(utility)f(of)890 980 y(P)t Fg(O)t(S)t(I)t(X)i +Fk(advisory)d(\002le)i(locks,)e(and)j(we'd)e(r)o(ecommend)f(caution)j +(when)g(using)e(them.)888 1071 y(It)30 b(is)f(not)g(without)i(r)o +(eason)d(that)j(the)e(Fr)o(eeBSD)f(man)i(pages)e(r)o(efer)f(to)32 +b(P)t Fg(O)t(S)t(I)t(X)e Fk(\002le)888 1162 y(locking)18 +b(as)h(\223completely)f(stupid.\224)888 1270 y(Scsh)i(moves)e(Scheme)h +(ports)g(fr)o(om)e(\002le)i(descriptor)e(to)i(\002le)g(descriptor)e +(with)i Fh(dup\(\))888 1361 y Fk(and)c Fh(close\(\))h +Fk(as)f(r)o(equir)o(ed)c(by)j(the)h(r)o(untime,)h(so)d(it)i(is)f +(impossible)f(to)h(keep)f(\002le)i(locks)888 1452 y(open)25 +b(acr)o(oss)e(one)i(of)f(these)h(shifts.)40 b(Hence)25 +b(we)g(can)g(only)f(of)o(fer)h(P)t Fg(O)t(S)t(I)t(X)h +Fk(advisory)888 1544 y(\002le)17 b(locking)g(dir)o(ectly)e(on)j(raw)f +(integer)f(\002le)h(descriptors;)f(r)o(egr)o(ettably)-8 +b(,)15 b(ther)o(e)i(ar)o(e)f(no)888 1635 y(facilities)i(for)g(locking)g +(Scheme)h(ports.)888 1742 y(Note)g(that)h(once)f(a)g(Scheme)g(port)g +(is)f(r)o(evealed)f(in)i(scsh,)f(the)i(r)o(untime)f(will)f(not)h(shift) +888 1834 y(the)i(port)e(ar)o(ound)h(with)h Fh(dup\(\))g +Fk(and)f Fh(close\(\))p Fk(.)29 b(This)19 b(means)i(the)f +(\002le-locking)f(pr)o(o-)888 1925 y(cedur)o(es)e(can)j(then)g(be)f +(applied)e(to)i(the)h(port's)d(associated)i(\002le)f(descriptor)-6 +b(.)888 2032 y(NeXTSTEP)21 b(users)e(should)i(also)f(note)i(that)h +(even)e(minimalist)i(P)t Fg(O)t(S)t(I)t(X)f Fk(\002le)e(locking)888 +2124 y(is)k(not)h(supported)e(for)g(NFS-mounted)h(\002les)g(in)g +(NeXTSTEP;)g(NeXT)f(claims)h(they)888 2215 y(will)19 +b(\002x)g(this)h(in)f(NS)h(r)o(elease)d(4.)25 b(W)-7 +b(e'd)19 b(appr)o(eciate)f(hearing)i(fr)o(om)e(users)g(when)i(and)888 +2306 y(if)f(this)g(happens.)807 2479 y FC(P)t Ft(O)t(S)t(I)t(X)29 +b FC(allows)e(the)e(user)h(to)g(lock)g(a)f(r)o(egion)h(of)f(a)g(\002le) +h(with)h(either)e(an)h(exclusive)f(or)681 2578 y(shar)o(ed)19 +b(lock.)26 b(Locked)21 b(r)o(egions)g(ar)o(e)e(described)h(by)g(the)h +FB(lock-r)o(egion)f FC(r)o(ecor)o(d:)888 2767 y Fy(\(define-record)38 +b(lock-region)976 2867 y(exclusive?)976 2966 y(start)976 +3066 y(len)976 3166 y(whence)976 3265 y(proc\))805 3642 +y Fu(\017)j FC(The)21 b Fy(exclusive?)c FC(\002eld)j(is)h(tr)o(ue)g(if) +g(the)g(lock)g(is)g(exclusive;)f(false)g(if)h(it)g(is)g(shar)o(ed.)805 +3807 y Fu(\017)41 b FC(The)e Fy(whence)d FC(\002eld)j(is)g(one)h(of)e +(the)h(values)g(fr)o(om)f(the)h Fy(seek)e FC(call:)62 +b Fy(seek/set)p FC(,)888 3907 y Fy(seek/delta)p FC(,)15 +b(or)20 b Fy(seek/end)p FC(,)c(and)i(determines)i(the)f(interpr)o +(etation)g(of)g(the)g Fy(start)888 4006 y FC(\002eld:)988 +4171 y FA(\226)41 b FC(If)30 b Fy(seek/set)p FC(,)f(the)i +Fy(start)d FC(value)i(is)h(simply)g(an)f(absolute)g(index)h(into)g(the) +1071 4271 y(\002le.)988 4403 y FA(\226)41 b FC(If)21 +b Fy(seek/delta)p FC(,)16 b(the)21 b Fy(start)e FC(value)h(is)i(an)e +(of)o(fset)g(fr)o(om)h(the)g(\002le)g(descriptor)6 b('s)1071 +4502 y(curr)o(ent)20 b(position)i(in)f(the)g(\002le.)988 +4634 y FA(\226)41 b FC(If)20 b Fy(seek/end)p FC(,)e(the)i +Fy(start)f FC(value)h(is)h(an)g(of)o(fset)f(fr)o(om)g(the)h(end)g(of)f +(the)h(\002le.)888 4799 y(The)k(r)o(egion)h(of)f(the)g(\002le)g(being)g +(locked)h(is)f(given)g(by)g(the)h Fy(start)d FC(and)h +Fy(len)g FC(\002elds;)888 4898 y(if)33 b Fy(len)e FC(is)i(zer)o(o,)h +(it)f(means)g(\223in\002nity)-9 b(,\224)36 b(that)c(is,)k(the)d(r)o +(egion)f(extends)h(fr)o(om)f(the)2071 5147 y(38)p eop +%%Page: 39 45 +39 44 bop 573 614 a FC(starting)24 b(point)h(thr)o(ough)f(the)g(end)g +(of)g(the)g(\002le,)g(even)g(as)f(the)h(\002le)g(is)h(extended)d(by)573 +714 y(subsequent)f(write)g(operations.)490 866 y Fu(\017)41 +b FC(The)21 b Fy(proc)e FC(\002eld)i(gives)g(the)g(pr)o(ocess)g(object) +g(for)g(the)g(pr)o(ocess)f(holding)i(the)g(r)o(egion)573 +965 y(lock,)f(when)g(r)o(elevant)f(\(see)g Fy(get-lock-region)15 +b FC(below\).)365 1138 y Fy(\(make-lock-region)37 b FB(exclusive?)17 +b(start)g(len)g([whence])p Fy(\))55 b Fu(\000)-14 b(!)56 +b FB(lock-r)o(egion)87 b FC(pr)o(ocedur)o(e)573 1264 +y(This)24 b(pr)o(ocedur)o(e)d(makes)i(a)f(lock-r)o(egion)i(r)o(ecor)o +(d.)30 b(The)23 b Fy(whence)e FC(\002eld)i(defaults)f(to)573 +1364 y Fy(seek/set)p FC(.)365 1633 y Fy(\(lock-region)39 +b FB(fdes)21 b(lock)p Fy(\))87 b Fu(\000)-15 b(!)88 b +FB(unde\002ned)960 b FC(pr)o(ocedur)o(e)365 1733 y Fy +(\(lock-region/no-b)o(lo)o(ck)37 b FB(fdes)21 b(lock)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(boolean)648 b FC(pr)o(ocedur)o(e)573 +1859 y(These)30 b(pr)o(ocedur)o(es)f(lock)i(a)f(r)o(egion)g(of)h(the)f +(\002le)h(r)o(efer)o(enced)d(by)i(\002le)h(descriptor)573 +1959 y FB(fdes)p FC(.)60 b(The)32 b Fy(lock-region)c +FC(pr)o(ocedur)o(e)i(blocks)j(until)g(the)g(lock)g(is)f(granted;)37 +b(the)573 2059 y(non-blocking)18 b(variant)e(r)o(eturns)h(a)f(boolean)h +(indicating)g(whether)h(or)f(not)g(the)g(lock)573 2158 +y(was)29 b(granted.)51 b(T)-8 b(o)30 b(take)f(an)g(exclusive)g +(\(write\))f(lock,)k(you)e(must)g(have)f(the)g(\002le)573 +2258 y(descriptor)21 b(open)g(with)i(write)e(access;)g(to)g(take)g(a)g +(shar)o(ed)f(\(r)o(ead\))f(lock,)j(you)g(must)573 2357 +y(have)e(the)h(\002le)g(descriptor)f(open)h(with)h(r)o(ead)d(access.) +365 2527 y Fy(\(get-lock-region)37 b FB(fdes)21 b(lock)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(lock-r)o(egion)20 +b(or)h Fy(#f)548 b FC(pr)o(ocedur)o(e)573 2653 y(Return)27 +b(the)g(\002rst)h(lock)f(r)o(egion)g(on)h FB(fdes)f FC(that)g(would)g +(con\003ict)h(with)g(lock)g(r)o(egion)573 2753 y FB(lock)o +FC(.)34 b(If)22 b(ther)o(e)h(is)h(no)g(such)f(lock)h(r)o(egion,)g(r)o +(eturn)e(false.)33 b(This)24 b(pr)o(ocedur)o(e)d(\002lls)j(out)573 +2853 y(the)e Fy(proc)f FC(\002eld)h(of)g(the)g(r)o(eturned)f(lock)i(r)o +(egion,)f(and)g(is)g(the)g(only)h(pr)o(ocedur)o(e)e(that)573 +2952 y(has)k(anything)h(to)f(do)g(with)g(this)h(\002eld.)37 +b(\(See)24 b(section)i(3.4.1)d(for)h(a)g(description)i(of)573 +3052 y(pr)o(ocess)i(objects.\))48 b(Note)29 b(that)f(if)g(you)h(apply)f +(this)h(pr)o(ocedur)o(e)e(to)h(a)g(\002le)h(system)573 +3152 y(that)19 b(is)g(shar)o(ed)f(acr)o(oss)g(multiple)i(operating)f +(systems)g(\()p FB(i.e.)p FC(,)g(an)g(NFS)f(\002le)h(system\),)573 +3251 y(the)27 b Fy(proc)e FC(\002eld)h(may)h(be)f(ambiguous.)44 +b(W)-8 b(e)27 b(note,)h(again,)g(that)h(P)t Ft(O)t(S)t(I)t(X)h +FC(advisory)573 3351 y(\002le)21 b(locking)h(is)f(not)g(a)g(terribly)f +(useful)h(or)g(well-designed)f(facility)-9 b(.)365 3620 +y Fy(\(unlock-region)38 b FB(fdes)21 b(lock)p Fy(\))87 +b Fu(\000)-14 b(!)87 b FB(unde\002ned)873 b FC(pr)o(ocedur)o(e)573 +3746 y(Release)20 b(a)h(lock)g(fr)o(om)f(a)g(\002le.)365 +4015 y Fy(\(with-region-lock)o(*)37 b FB(fdes)21 b(lock)g(thunk)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(value\(s\))20 b(of)h(thunk)242 +b FC(pr)o(ocedur)o(e)365 4115 y Fy(\(with-region-lock)37 +b FB(fdes)21 b(lock)f(body)g(.)12 b(.)g(.)g Fy(\))88 +b Fu(\000)-15 b(!)88 b FB(value\(s\))20 b(of)g(body)379 +b FC(syntax)573 4242 y(This)21 b(pr)o(ocedur)o(e)e(obtains)j(the)f(r)o +(equested)f(lock,)i(and)e(then)i(calls)e Fy(\()p FB(thunk)o +Fy(\))p FC(.)26 b(When)573 4341 y FB(thunk)i FC(r)o(eturns,)h(the)g +(lock)g(is)g(r)o(eleased.)46 b(A)28 b(non-local)i(exit)e(\()p +FB(e.g.)o FC(,)i(thr)o(owing)f(to)g(a)573 4441 y(saved)j(continuation)j +(or)e(raising)g(an)g(exception\))g(also)g(causes)g(the)g(lock)g(to)h +(be)573 4541 y(r)o(eleased.)573 4666 y(After)40 b(a)g(normal)h(r)o +(eturn)f(fr)o(om)h FB(thunk)o FC(,)46 b(its)41 b(r)o(eturn)f(values)g +(ar)o(e)g(r)o(eturned)f(by)573 4766 y Fy(with-region-lock)o(*)p +FC(.)f(The)28 b Fy(with-region-loc)o(k)21 b FC(special)27 +b(form)g(is)g(equivalent)573 4865 y(syntactic)21 b(sugar)-6 +b(.)1756 5147 y(39)p eop +%%Page: 40 46 +40 45 bop 681 614 a Fw(3.3)99 b(File)25 b(system)681 +828 y FC(Besides)30 b(the)h(following)h(pr)o(ocedur)o(es,)g(which)f +(allow)g(access)g(to)g(the)g(computer)6 b('s)31 b(\002le)681 +928 y(system,)j(scsh)d(also)g(pr)o(ovides)f(a)g(set)h(of)g(pr)o(ocedur) +o(es)e(which)j(manipulate)e(\002le)h FB(names)p FC(.)681 +1028 y(These)20 b(string-pr)o(ocessing)i(pr)o(ocedur)o(es)d(ar)o(e)g +(documented)i(in)g(section)g(5.1.3.)681 1172 y Fy(\(create-director)o +(y)37 b FB(fname)21 b([perms)f(override?])p Fy(\))87 +b Fu(\000)-15 b(!)87 b FB(unde\002ned)207 b FC(pr)o(ocedur)o(e)681 +1271 y Fy(\(create-fifo)38 b FB(fname)21 b([perms)g(override?])p +Fy(\))86 b Fu(\000)-15 b(!)88 b FB(unde\002ned)424 b +FC(pr)o(ocedur)o(e)681 1371 y Fy(\(create-hard-lin)o(k)37 +b FB(oldname)17 b(newname)g([override?])p Fy(\))52 b +Fu(\000)-14 b(!)54 b FB(unde\002ned)87 b FC(pr)o(ocedur)o(e)681 +1471 y Fy(\(create-symlink)37 b FB(old-name)18 b(new-name)g +([override?])p Fy(\))67 b Fu(\000)-14 b(!)68 b FB(unde\002ned)87 +b FC(pr)o(ocedur)o(e)888 1607 y(These)21 b(pr)o(ocedur)o(es)e(cr)o +(eate)g(objects)i(of)g(various)g(kinds)g(in)g(the)g(\002le)g(system.) +888 1737 y(The)h FB(override?)g FC(ar)o(gument)g(contr)o(ols)g(the)h +(action)f(if)g(ther)o(e)f(is)i(alr)o(eady)d(an)i(object)h(in)888 +1836 y(the)e(\002le)g(system)h(with)f(the)g(new)g(name:)1071 +1973 y Fy(#f)273 b FC(signal)21 b(an)g(err)o(or)f(\(default\))1071 +2122 y Fy('query)97 b FC(pr)o(ompt)21 b(the)g(user)1071 +2272 y FB(other)190 b FC(delete)29 b(the)h(old)g(object)g(\(with)h +Fy(delete-file)25 b FC(or)1432 2371 y Fy(delete-directory,)g +FC(as)32 b(appr)o(opriate\))d(befor)o(e)1432 2471 y(cr)o(eating)20 +b(the)h(new)g(object.)888 2633 y FB(Perms)g FC(defaults)f(to)h +Fy(#o777)e FC(\(but)h(is)i(masked)e(by)h(the)g(curr)o(ent)f(umask\).) +1071 2799 y Fl(Remark:)50 b Fk(Curr)o(ently)-8 b(,)16 +b(if)h(you)g(try)h(to)f(cr)o(eate)h(a)g(har)o(d)f(or)g(symbolic)g(link) +g(fr)o(om)g(a)1071 2890 y(\002le)k(to)h(itself,)f(you)f(will)h(err)o +(or)f(out)h(with)h Fi(override?)h Fk(false,)e(and)h(simply)e(delete) +1071 2982 y(your)k(\002le)h(with)h Fi(override?)h Fk(tr)o(ue.)42 +b(Catching)27 b(this)e(will)g(r)o(equir)o(e)e(some)h(sort)h(of)1071 +3073 y(tr)o(ue-name)19 b(pr)o(ocedur)o(e,)d(which)k(I)f(curr)o(ently)e +(do)i(not)g(have.)681 3417 y Fy(\(delete-director)o(y)37 +b FB(fname)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(unde\002ned)820 +b FC(pr)o(ocedur)o(e)681 3516 y Fy(\(delete-file)38 b +FB(fname)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(unde\002ned)1038 +b FC(pr)o(ocedur)o(e)681 3616 y Fy(\(delete-filesys-)o(ob)o(jec)o(t)37 +b FB(fname)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(unde\002ned)602 +b FC(pr)o(ocedur)o(e)888 3752 y(These)43 b(pr)o(ocedur)o(es)e(delete)h +(objects)h(fr)o(om)f(the)h(\002le)g(system.)92 b(The)43 +b Fy(delete-)888 3852 y(filesys-object)15 b FC(pr)o(ocedur)o(e)k(will)i +(delete)f(an)g(object)h(of)f(any)h(type)f(fr)o(om)g(the)h(\002le)888 +3951 y(system:)27 b(\002les,)20 b(\(empty\))h(dir)o(ectories,)e +(symlinks,)j(\002fos,)f FB(etc.)p FC(.)681 4189 y Fy(\(read-symlink)38 +b FB(fname)p Fy(\))87 b Fu(\000)-15 b(!)88 b FB(string)1121 +b FC(pr)o(ocedur)o(e)888 4325 y(Return)22 b(the)e(\002lename)h(r)o +(efer)o(enced)d(by)j(symbolic)h(link)f Fy(fname)p FC(.)681 +4563 y Fy(\(rename-file)38 b FB(old-fname)20 b(new-fname)h([override?]) +p Fy(\))86 b Fu(\000)-15 b(!)88 b FB(unde\002ned)129 +b FC(pr)o(ocedur)o(e)888 4699 y(If)34 b(you)h(override)e(an)h(existing) +h(object,)i(then)e FB(old-fname)e FC(and)g FB(new-fname)h +FC(must)888 4799 y(type-match\227either)26 b(both)i(dir)o(ectories,)f +(or)f(both)h(non-dir)o(ectories.)43 b(This)27 b(is)g(r)o(e-)888 +4898 y(quir)o(ed)21 b(by)f(the)h(semantics)g(of)g(Unix)g +Fy(rename\(\))p FC(.)2071 5147 y(40)p eop +%%Page: 41 47 +41 46 bop 756 614 a Fl(Remark:)186 b Fk(Ther)o(e)37 b(is)f(an)j +(unfortunate)f(atomicity)g(pr)o(oblem)e(with)i(the)756 +706 y Fh(rename-file)c Fk(pr)o(ocedur)o(e:)48 b(if)31 +b(you)h(specify)f(no-override,)i(but)g(cr)o(eate)f(\002le)756 +797 y Fh(new-fname)21 b Fk(sometime)d(between)j Fh(rename-file)p +Fk('s)g(existence)e(check)g(and)h(the)756 888 y(actual)i(r)o(ename)g +(operation,)g(your)e(\002le)i(will)f(be)h(clobber)o(ed)f(with)h +Fh(old-fname)p Fk(.)756 980 y(Ther)o(e)33 b(is)g(no)i(way)f(to)h(\002x) +f(this)g(pr)o(oblem,)j(given)d(the)h(semantics)f(of)g(Unix)756 +1071 y Fh(rename\(\))p Fk(;)20 b(at)f(least)g(it)f(is)h(highly)f +(unlikely)f(to)i(occur)f(in)h(practice.)365 1487 y Fy(\(set-file-mode) +38 b FB(fname/fd/port)19 b(mode)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(unde\002ned)503 b FC(pr)o(ocedur)o(e)365 +1587 y Fy(\(set-file-owner)38 b FB(fname/fd/port)18 b(uid)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(unde\002ned)524 b +FC(pr)o(ocedur)o(e)365 1687 y Fy(\(set-file-group)38 +b FB(fname/fd/port)18 b(gid)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(unde\002ned)529 b FC(pr)o(ocedur)o(e)573 +1840 y(These)30 b(pr)o(ocedur)o(es)f(set)h(the)h(permission)h(bits,)h +(owner)e(id,)h(and)e(gr)o(oup)g(id)h(of)f(a)573 1939 +y(\002le,)35 b(r)o(espectively)-9 b(.)58 b(The)32 b(\002le)g(can)g(be)g +(speci\002ed)f(by)h(giving)h(the)g(\002le)f(name,)i(or)573 +2039 y(either)19 b(an)g(integer)h(\002le)g(descriptor)f(or)g(a)g(port)h +(open)g(on)g(the)f(\002le.)26 b(Setting)19 b(\002le)h(user)573 +2138 y(ownership)i(usually)f(r)o(equir)o(es)e(r)o(oot)i(privileges.)365 +2365 y Fy(\(set-file-times)38 b FB(fname)20 b([access-time)g(mod-time]) +p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(unde\002ned)116 +b FC(pr)o(ocedur)o(e)573 2518 y(This)19 b(pr)o(ocedur)o(e)e(sets)i(the) +g(access)g(and)f(modi\002ed)h(times)h(for)e(the)h(\002le)g +FB(fname)g FC(to)g(the)573 2618 y(supplied)26 b(values)g(\(see)f +(section)i(3.10)e(for)h(the)g(scsh)h(r)o(epr)o(esentation)e(of)h +(time\).)42 b(If)573 2717 y(neither)24 b(time)g(ar)o(gument)g(is)g +(supplied,)g(they)h(ar)o(e)d(both)j(taken)e(to)i(be)e(the)h(curr)o(ent) +573 2817 y(time.)h(Y)-8 b(ou)20 b(must)f(pr)o(ovide)f(both)h(times)h +(or)e(neither)-6 b(.)25 b(If)19 b(the)f(pr)o(ocedur)o(e)f(completes)573 +2917 y(successfully)-9 b(,)23 b(the)h(\002le's)f(time)h(of)f(last)g +(status-change)g(\()p Fy(ctime)p FC(\))d(is)k(set)f(to)g(the)h(cur)o(-) +573 3016 y(r)o(ent)c(time.)365 3243 y Fy(\(sync-file)40 +b FB(fd/port)p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(unde\002ned)1101 +b FC(pr)o(ocedur)o(e)365 3342 y Fy(\(sync-file-system)o(\))81 +b Fu(\000)-14 b(!)87 b FB(unde\002ned)1067 b FC(pr)o(ocedur)o(e)573 +3495 y(Calling)28 b Fy(sync-file)c FC(causes)j(Unix)g(to)h(update)f +(the)g(disk)h(data)e(str)o(uctur)o(es)i(for)f(a)573 3595 +y(given)17 b(\002le.)24 b(If)17 b FB(fd/port)e FC(is)i(a)f(port,)i(any) +e(buf)o(fer)o(ed)f(data)g(it)i(may)g(have)f(is)h(\002rst)g(\003ushed.) +573 3695 y(Calling)33 b Fy(sync-file-system)27 b FC(synchr)o(onises)34 +b(the)g(kernel's)f(entir)o(e)g(\002le)g(system)573 3794 +y(with)21 b(the)g(disk.)573 3939 y(These)43 b(pr)o(ocedur)o(es)e(ar)o +(e)g(not)k(P)t Ft(O)t(S)t(I)t(X)r FC(.)93 b(Inter)o(estingly)44 +b(enough,)49 b Fy(sync-file-)573 4039 y(system)30 b FC(doesn't)i +(actually)g(do)h(what)f(it)h(is)f(claimed)g(to)h(do.)60 +b(W)-8 b(e)32 b(just)h(thr)o(ew)f(it)573 4138 y(in)21 +b(for)g(humor)g(value.)k(See)20 b(the)h Fy(sync\(2\))d +FC(man)j(page)f(for)g(Unix)h(enlightenment.)365 4365 +y Fy(\(truncate-file)38 b FB(fname/fd/port)19 b(len)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(unde\002ned)577 b +FC(pr)o(ocedur)o(e)573 4518 y(The)21 b(speci\002ed)f(\002le)h(is)g(tr)o +(uncated)f(to)h FB(len)h FC(bytes)f(in)g(length.)365 +4844 y Fy(\(file-info)40 b FB(fname/fd/port)19 b([chase?])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(\002le-info-r)o(ecord)417 +b FC(pr)o(ocedur)o(e)1756 5147 y(41)p eop +%%Page: 42 48 +42 47 bop 888 614 a FC(The)32 b Fy(file-info)d FC(pr)o(ocedur)o(e)h(r)o +(eturns)h(a)h(r)o(ecor)o(d)e(str)o(uctur)o(e)i(containing)h(every-)888 +714 y(thing)25 b(ther)o(e)d(is)i(to)g(know)g(about)g(a)f(\002le.)33 +b(If)23 b(the)h FB(chase?)f FC(\003ag)g(is)h(tr)o(ue)f(\(the)h +(default\),)888 814 y(then)19 b(the)e(pr)o(ocedur)o(e)f(chases)i +(symlinks)h(and)e(r)o(eports)h(on)g(the)g(\002les)g(to)g(which)h(they) +888 913 y(r)o(efer)-6 b(.)23 b(If)16 b FB(chase?)g FC(is)h(false,)g +(then)g(the)g(pr)o(ocedur)o(e)e(checks)i(the)g(actual)f(\002le)h +(itself,)g(even)888 1013 y(if)j(it's)g(a)g(symlink.)26 +b(The)20 b FB(chase?)f FC(\003ag)h(is)h(ignor)o(ed)e(if)h(the)g(\002le) +g(ar)o(gument)f(is)i(a)e(\002le)h(de-)888 1112 y(scriptor)h(or)g(port.) +888 1252 y(The)c(value)f(r)o(eturned)g(is)h(a)g FB(\002le-info)g(r)o +(ecord)p FC(,)g(de\002ned)f(to)h(have)g(the)g(following)h(str)o(uc-)888 +1352 y(tur)o(e:)1071 1531 y Fy(\(define-record)38 b(file-info)1158 +1631 y(type)260 b(;)43 b Fu(f)p Fy(block-special,)37 +b(char-special,)i(directory,)1594 1731 y(;)218 b(fifo,)41 +b(regular,)f(socket,)h(symlink)p Fu(g)1158 1830 y Fy(device)172 +b(;)43 b(Device)e(file)h(resides)f(on.)1158 1930 y(inode)216 +b(;)43 b(File's)e(inode.)1158 2030 y(mode)260 b(;)43 +b(File's)e(mode)h(bits:)g(permissions,)c(setuid,)j(setgid)1158 +2129 y(nlinks)172 b(;)43 b(Number)e(of)i(hard)f(links)g(to)g(this)g +(file.)1158 2229 y(uid)304 b(;)43 b(Owner)f(of)g(file.)1158 +2328 y(gid)304 b(;)43 b(File's)e(group)h(id.)1158 2428 +y(size)260 b(;)43 b(Size)f(of)h(file,)e(in)i(bytes.)1158 +2528 y(atime)216 b(;)43 b(Time)f(of)h(last)f(access.)1158 +2627 y(mtime)216 b(;)43 b(Time)f(of)h(last)f(mod.)1158 +2727 y(ctime\))172 b(;)43 b(Time)f(of)h(last)f(status)f(change.)888 +2907 y FC(The)21 b(uid)g(\002eld)f(of)h(a)f(\002le-info)h(r)o(ecor)o(d) +e(is)j(accessed)d(with)j(the)f(pr)o(ocedur)o(e)1071 3061 +y Fy(\(file-info:uid)38 b(x\))888 3216 y FC(and)44 b(similarly)h(for)f +(the)h(other)f(\002elds.)97 b(The)44 b Fy(type)f FC(\002eld)h(is)g(a)g +(symbol;)57 b(all)888 3315 y(other)37 b(\002elds)f(ar)o(e)f(integers.) +72 b(A)36 b(\002le-info)g(r)o(ecor)o(d)e(is)j(discriminated)f(with)h +(the)888 3415 y Fy(file-info?)17 b FC(pr)o(edicate.)888 +3555 y(The)35 b(following)i(pr)o(ocedur)o(es)c(all)i(r)o(eturn)g +(selected)f(information)i(about)f(a)g(\002le;)888 3654 +y(they)29 b(ar)o(e)e(built)h(on)h(top)g(of)f Fy(file-info)p +FC(,)e(and)i(ar)o(e)f(called)g(with)i(the)f(same)g(ar)o(gu-)888 +3754 y(ments)22 b(that)e(ar)o(e)g(passed)g(to)h(it.)1121 +3910 y(Pr)o(ocedur)o(e)725 b(r)o(eturns)p 1071 3944 1467 +4 v 1121 4013 a Fy(file-type)706 b FC(type)1121 4113 +y Fy(file-inode)662 b FC(inode)1121 4213 y Fy(file-mode)706 +b FC(mode)1121 4312 y Fy(file-nlinks)618 b FC(nlinks)1121 +4412 y Fy(file-owner)662 b FC(uid)1121 4511 y Fy(file-group)g +FC(gid)1121 4611 y Fy(file-size)706 b FC(size)1121 4711 +y Fy(file-last-access)398 b FC(atime)1121 4810 y Fy(file-last-mod)530 +b FC(mtime)1121 4910 y Fy(file-last-status)o(-c)o(han)o(ge)93 +b FC(ctime)2071 5147 y(42)p eop +%%Page: 43 49 +43 48 bop 573 614 a FC(Example:)756 769 y Fy(;;)42 b(All)h(my)f(files)g +(in)h(/usr/tmp:)756 869 y(\(filter)d(\()p Fz(\025)f Fy(\(f\))j(\(=)h +(\(file-owner)c(f\))k(\(user-uid\)\)\))1104 969 y(\(directory-files)37 +b("/usr/tmp"\)\)\))756 1154 y Fl(Remark:)114 b Fh(file-info)36 +b Fk(was)f(named)g Fh(file-attributes)j Fk(in)d(r)o(eleases)d(of)756 +1246 y(scsh)h(prior)e(to)i(r)o(elease)f(0.4.)66 b(W)-7 +b(e)33 b(changed)h(the)g(name)f(to)h Fh(file-info)h Fk(for)756 +1337 y(consistency)27 b(with)h(the)g(other)g(information-r)o(etrieval)e +(pr)o(ocedur)o(es)f(in)i(scsh:)756 1428 y Fh(user-info)p +Fk(,)k Fh(group-info)p Fk(,)h Fh(host-info)p Fk(,)f Fh(network-info)42 +b Fk(,)29 b Fh(service-info)p Fk(,)756 1520 y(and)19 +b Fh(protocol-info)p Fk(.)756 1622 y(The)f Fh(file-attributes)k +Fk(binding)d(is)f(still)f(supported)h(in)g(the)h(curr)o(ent)g(r)o +(elease)756 1713 y(of)f(scsh,)g(but)i(is)e(depr)o(ecated,)f(and)i(may)g +(go)f(away)h(in)g(a)g(futur)o(e)f(r)o(elease.)365 2043 +y Fy(\(file-directory?)37 b FB(fname/fd/port)19 b([chase?])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(boolean)398 b FC(pr)o(ocedur)o(e)365 +2142 y Fy(\(file-fifo?)39 b FB(fname/fd/port)19 b([chase?])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(boolean)616 b FC(pr)o(ocedur)o(e)365 +2242 y Fy(\(file-regular?)38 b FB(fname/fd/port)19 b([chase?])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(boolean)485 b FC(pr)o(ocedur)o(e)365 +2342 y Fy(\(file-socket?)39 b FB(fname/fd/port)18 b([chase?])p +Fy(\))86 b Fu(\000)-15 b(!)88 b FB(boolean)528 b FC(pr)o(ocedur)o(e)365 +2441 y Fy(\(file-special?)38 b FB(fname/fd/port)19 b([chase?])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(boolean)485 b FC(pr)o(ocedur)o(e)365 +2541 y Fy(\(file-symlink?)38 b FB(fname/fd/port)p Fy(\))85 +b Fu(\000)-14 b(!)87 b FB(boolean)779 b FC(pr)o(ocedur)o(e)573 +2671 y(These)19 b(pr)o(ocedur)o(es)f(ar)o(e)g(\002le-type)h(pr)o +(edicates)f(that)h(test)h(the)f(type)h(of)f(a)g(given)h(\002le.)573 +2771 y(They)j(ar)o(e)f(applied)h(to)h(the)f(same)g(ar)o(guments)g(to)h +(which)g Fy(file-info)c FC(is)k(applied;)573 2870 y(the)30 +b(sole)g(exception)g(is)h Fy(file-symlink?)p FC(,)c(which)j(does)g(not) +h(take)f(the)g(optional)573 2970 y FB(chase?)20 b FC(second)h(ar)o +(gument.)573 3247 y(For)g(example,)756 3386 y Fy(\(file-directory)o(?) +37 b("/usr/dalbertz"\))168 b Fn(=)-14 b Fu(\))218 b Fy(#t)365 +3616 y(\(file-not-readabl)o(e?)37 b FB(fname)p Fy(\))87 +b Fu(\000)-15 b(!)88 b FB(boolean)813 b FC(pr)o(ocedur)o(e)365 +3715 y Fy(\(file-not-writabl)o(e?)37 b FB(fname)p Fy(\))87 +b Fu(\000)-15 b(!)88 b FB(boolean)813 b FC(pr)o(ocedur)o(e)365 +3815 y Fy(\(file-not-executa)o(bl)o(e?)37 b FB(fname)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(boolean)726 b FC(pr)o(ocedur)o(e)573 +3945 y(Returns:)756 4060 y(V)-8 b(alue)501 b(meaning)p +756 4108 1909 4 v 756 4213 a Fy(#f)621 b FC(Access)21 +b(permitted)756 4362 y Fy('search-denied)93 b FC(Can't)21 +b(stat\227a)f(pr)o(otected)g(dir)o(ectory)1465 4462 y(is)h(blocking)h +(access.)756 4596 y Fy('permission)225 b FC(Permission)22 +b(denied.)756 4746 y Fy('no-directory)137 b FC(Some)21 +b(dir)o(ectory)f(doesn't)h(exist.)756 4895 y Fy('nonexistent)181 +b FC(File)21 b(doesn't)h(exist.)1756 5147 y(43)p eop +%%Page: 44 50 +44 49 bop 911 614 a FC(A)22 b(\002le)g(is)h(consider)o(ed)f(writeable)g +(if)g(either)g(\(1\))g(it)g(exists)h(and)f(is)h(writeable)f(or)g(\(2\)) +888 714 y(it)j(doesn't)g(exist)f(and)g(the)g(dir)o(ectory)f(is)i +(writeable.)35 b(Since)24 b(symlink)i(permission)888 +814 y(bits)21 b(ar)o(e)f(ignor)o(ed)g(by)h(the)g(\002lesystem,)g(these) +g(calls)g(do)g(not)g(take)f(a)h FB(chase?)f FC(\003ag.)1071 +989 y Fl(Oops:)103 b Fh(file-not-writeable?)36 b Fk(does)31 +b(not)h(curr)o(ently)f(do)g(the)i(dir)o(ectory)1071 1081 +y(check.)681 1341 y Fy(\(file-readable?)k FB(fname)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(boolean)987 b FC(pr)o(ocedur)o(e)681 +1440 y Fy(\(file-writable?)37 b FB(fname)p Fy(\))87 b +Fu(\000)-14 b(!)87 b FB(boolean)987 b FC(pr)o(ocedur)o(e)681 +1540 y Fy(\(file-executable)o(?)37 b FB(fname)p Fy(\))87 +b Fu(\000)-14 b(!)87 b FB(boolean)900 b FC(pr)o(ocedur)o(e)888 +1681 y(These)86 b(pr)o(ocedur)o(es)e(ar)o(e)h(the)h(logical)g(negation) +g(of)g(the)g(pr)o(eceding)888 1781 y Fy(file-not-...?)16 +b FC(pr)o(ocedur)o(es.)681 1974 y Fy(\(file-not-exists)o(?)37 +b FB(fname)21 b([chase?])p Fy(\))85 b Fu(\000)-14 b(!)87 +b FB(object)664 b FC(pr)o(ocedur)o(e)888 2115 y(Returns:)1071 +2230 y Fy(#f)622 b FC(Exists.)1071 2379 y Fy(#t)g FC(Doesn't)22 +b(exist.)1071 2529 y Fy('search-denied)94 b FC(Some)21 +b(pr)o(otected)e(dir)o(ectory)h(is)1781 2628 y(blocking)i(the)f(sear)o +(ch.)681 2853 y Fy(\(file-exists?)38 b FB(fname)21 b([chase?])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(boolean)780 b FC(pr)o(ocedur)o(e)888 +2994 y(This)22 b(is)f(simply)g Fy(\(not)42 b(\(file-not-exists?)37 +b FB(fname)43 b([chase?])o Fy(\)\))681 3286 y(\(directory-files)37 +b FB([dir)20 b(dot\002les?])p Fy(\))85 b Fu(\000)-14 +b(!)87 b FB(string)21 b(list)615 b FC(pr)o(ocedur)o(e)888 +3428 y(Return)19 b(the)f(list)g(of)g(\002les)g(in)h(dir)o(ectory)e +FB(dir)p FC(,)h(which)h(defaults)e(to)h(the)g(curr)o(ent)f(work-)888 +3528 y(ing)j(dir)o(ectory)-9 b(.)24 b(The)c FB(dot\002les?)e +FC(\003ag)i(\(default)e Fy(#f)p FC(\))g(causes)h(dot)h(\002les)f(to)h +(be)f(included)888 3627 y(in)26 b(the)e(list.)39 b(Regar)o(dless)24 +b(of)g(the)h(value)f(of)h FB(dot\002les?)o FC(,)h(the)e(two)i(\002les)f +Fy(.)f FC(and)h Fy(..)e FC(ar)o(e)888 3727 y FB(never)f +FC(r)o(eturned.)888 3860 y(The)c(dir)o(ectory)f FB(dir)h +FC(is)g(not)g(pr)o(epended)e(to)j(each)e(\002le)h(name)g(in)g(the)g(r)o +(esult)f(list.)25 b(That)888 3960 y(is,)1071 4100 y Fy +(\(directory-files)37 b("/etc"\))888 4240 y FC(r)o(eturns)1071 +4379 y Fy(\("chown")j("exports")g("fstab")h(...\))888 +4519 y FB(not)1071 4659 y Fy(\("/etc/chown")d("/etc/exports")g +("/etc/fstab")h(...\))888 4799 y FC(T)-8 b(o)36 b(use)e(the)h(\002les)h +(in)f(r)o(eturned)e(list,)39 b(the)c(pr)o(ogrammer)f(can)g(either)h +(manually)888 4898 y(pr)o(epend)20 b(the)h(dir)o(ectory:)2071 +5147 y(44)p eop +%%Page: 45 51 +45 50 bop 756 614 a Fy(\(map)41 b(\()p Fz(\025)e Fy(\(f\))k +(\(string-append)37 b(dir)43 b("/")f(f\)\))g(files\))573 +764 y FC(or)21 b(cd)f(to)h(the)g(dir)o(ectory)f(befor)o(e)g(using)h +(the)g(\002le)g(names:)756 940 y Fy(\(with-cwd)39 b(dir)843 +1040 y(\(for-each)h(delete-file)f(\(directory-file)o(s\)\))o(\))573 +1215 y FC(or)21 b(use)g(the)f Fy(glob)g FC(pr)o(ocedur)o(e,)e +(de\002ned)i(below)-8 b(.)573 1353 y(A)20 b(dir)o(ectory)g(list)i(can)e +(be)g(generated)g(by)h Fy(\(run/strings)39 b(\(ls\)\))p +FC(,)18 b(but)j(this)g(is)h(un-)573 1453 y(r)o(eliable,)32 +b(as)e(\002lenames)h(with)g(whitespace)g(in)g(their)g(names)g(will)g +(be)g(split)g(into)573 1552 y(separate)19 b(entries.)26 +b(Using)21 b Fy(directory-files)14 b FC(is)22 b(r)o(eliable.)365 +1758 y Fy(\(glob)42 b FB(pat)733 1785 y Fv(1)791 1758 +y FB(.)12 b(.)g(.)g Fy(\))87 b Fu(\000)-14 b(!)87 b FB(string)21 +b(list)1283 b FC(pr)o(ocedur)o(e)573 1904 y(Glob)27 b(each)f(pattern)g +(against)g(the)g(\002lesystem)h(and)f(r)o(eturn)g(the)h(sorted)f(list.) +43 b(Du-)573 2004 y(plicates)30 b(ar)o(e)g(not)i(r)o(emoved.)55 +b(Patterns)30 b(matching)i(nothing)h(ar)o(e)c(not)j(included)573 +2103 y(literally)-9 b(.)869 2073 y Fv(2)932 2103 y FC(C)21 +b(shell)h Fy({a,b,c})c FC(patterns)j(ar)o(e)e(expanded.)25 +b(Backslash)c(quotes)h(char)o(-)573 2203 y(acters,)e(turning)h(of)o(f)f +(the)h(special)f(meaning)i(of)e Fy({)p FC(,)g Fy(})p +FC(,)h Fy(*)p FC(,)f Fy([)p FC(,)g Fy(])p FC(,)g(and)g +Fy(?)p FC(.)573 2340 y(Note)33 b(that)h(the)f(r)o(ules)h(of)f +(backslash)h(for)f(Scheme)g(strings)h(and)f(glob)h(patterns)573 +2440 y(work)e(together)h(to)f(r)o(equir)o(e)f(four)h(backslashes)g(in)g +(a)g(r)o(ow)g(to)g(specify)g(a)g(single)573 2540 y(literal)20 +b(backslash.)26 b(Fortunately)-9 b(,)20 b(this)i(should)f(be)g(a)f(rar) +o(e)f(occurr)o(ence.)573 2677 y(A)27 b(glob)h(subpattern)f(will)h(not)g +(match)f(against)h(dot)f(\002les)h(unless)g(the)f(\002rst)h(char)o(-) +573 2777 y(acter)k(of)i(the)f(subpattern)h(is)f(a)g(literal)h(\223)p +Fy(.)p FC(\224.)62 b(Further)-6 b(,)36 b(a)d(dot)h(subpattern)f(will) +573 2877 y(not)g(match)f(the)h(\002les)f Fy(.)g FC(or)g +Fy(..)g FC(unless)h(it)f(is)h(a)f(constant)h(pattern,)h(as)e(in)h +Fy(\(glob)573 2976 y("../*/*.c"\))p FC(.)20 b(So)g(a)f(dir)o(ectory's)g +(dot)h(\002les)g(can)f(be)h(r)o(eliably)e(generated)h(with)h(the)573 +3076 y(simple)h(glob)g(pattern)g Fy(".*")p FC(.)573 3214 +y(Some)g(examples:)756 3364 y Fy(\(glob)41 b("*.c")h("*.h"\))930 +3463 y(;;)h(All)f(the)g(C)h(and)g(#include)d(files)i(in)g(my)h +(directory.)756 3662 y(\(glob)e("*.c")h("*/*.c"\))930 +3762 y(;;)h(All)f(the)g(C)h(files)f(in)h(this)f(directory)e(and)930 +3862 y(;;)j(its)f(immediate)e(subdirectories.)756 4061 +y(\(glob)h("lexer/*.c")e("parser/*.c"\))756 4161 y(\(glob)i +("{lexer,parser}/)o(*.c)o("\))930 4260 y(;;)i(All)f(the)g(C)h(files)f +(in)h(the)f(lexer)g(and)g(parser)f(dirs.)756 4459 y(\(glob)g +("\\\\{lexer,parser)o(\\\\})o(/*)o(.c)o("\))930 4559 +y(;;)i(All)f(the)g(C)h(files)f(in)h(the)f(strange)930 +4659 y(;;)h(directory)c("{lexer,parser}".)p 365 4821 +1146 4 v 450 4875 a Fq(2)485 4898 y Ft(Why)16 b(bother)g(to)h(mention)f +(such)g(a)h(silly)h(possibility?)k(Because)17 b(that)f(is)h(what)f(sh)h +(does.)1756 5147 y FC(45)p eop +%%Page: 46 52 +46 51 bop 1071 614 a Fy(\(glob)42 b("*\\\\*"\))1245 714 +y(;;)h(All)f(the)h(files)e(ending)g(in)i("*",)f(e.g.)1245 +814 y(;;)h(\("foo*")e("bar*"\))1071 1013 y(\(glob)h("*lexer*"\))1245 +1112 y(\("mylexer.c")d("lexer1.notes"\))1245 1212 y(;;)k(All)f(files)g +(containing)d(the)k(string)e("lexer".)1071 1411 y(\(glob)h("lexer"\)) +1245 1511 y(;;)h(Either)e(\("lexer"\))f(or)j(\(\).)888 +1650 y FC(If)21 b(the)h(\002rst)g(character)e(of)h(the)h(pattern)f +(\(after)f(expanding)h(braces\))f(is)i(a)f(slash,)h(the)888 +1749 y(sear)o(ch)c(begins)i(at)e(r)o(oot;)i(otherwise,)f(the)h(sear)o +(ch)e(begins)h(in)h(the)f(curr)o(ent)f(working)888 1849 +y(dir)o(ectory)-9 b(.)888 1980 y(If)19 b(the)g(last)g(character)f(of)h +(the)g(pattern)g(\(after)e(expanding)i(braces\))f(is)h(a)g(slash,)h +(then)888 2080 y(the)h(r)o(esult)g(matches)f(must)i(be)e(dir)o +(ectories,)g FB(e.g.)o FC(,)1071 2243 y Fy(\(glob)42 +b("/usr/man/man?/)o("\))37 b Fn(=)-14 b Fu(\))1420 2342 +y Fy(\("/usr/man/man1)o(/")37 b("/usr/man/man2/")g(...\))888 +2537 y FC(Globbing)29 b(can)e(sometimes)i(be)e(useful)g(when)h(we)f +(need)g(a)g(list)h(of)g(a)f(dir)o(ectory's)888 2636 y(\002les)32 +b(wher)o(e)e(each)h(element)g(in)g(the)g(list)h(includes)f(the)g +(pathname)g(for)g(the)g(\002le.)888 2736 y(Compar)o(e:)1071 +2899 y Fy(\(directory-files)37 b("../include"\))h Fn(=)-14 +b Fu(\))1245 2999 y Fy(\("cig.h")41 b("decls.h")e(...\))1071 +3198 y(\(glob)j("../include/*"\))37 b Fn(=)-14 b Fu(\))1245 +3298 y Fy(\("../include/cig.)o(h")37 b("../include/decl)o(s.h)o(")g +(...\))681 3564 y(\(glob-quote)i FB(str)p Fy(\))87 b +Fu(\000)-14 b(!)87 b FB(string)1319 b FC(pr)o(ocedur)o(e)888 +3702 y(Returns)29 b(a)f(constant)h(glob)g(pattern)e(that)i(exactly)e +(matches)h FB(str)q FC(.)48 b(All)28 b(wild-car)o(d)888 +3801 y(characters)20 b(in)h FB(str)g FC(ar)o(e)e(quoted)j(with)f(a)f +(backslash.)1071 3964 y Fy(\(glob-quote)39 b("Any)j(*.c)g(files?"\)) +1245 4064 y Fn(=)-14 b Fu(\))44 b Fy("Any)e(\\*.c)g(files\\?")681 +4330 y(\(file-match)d FB(r)o(oot)20 b(dot-\002les?)f(pat)1790 +4357 y Fv(1)1848 4330 y FB(pat)1954 4357 y Fv(2)2012 +4330 y FB(.)12 b(.)g(.)34 b(pat)2239 4357 y Fo(n)2284 +4330 y Fy(\))87 b Fu(\000)-15 b(!)87 b FB(string)21 b(list)205 +b FC(pr)o(ocedur)o(e)888 4468 y Fy(file-match)26 b FC(pr)o(ovides)j(a)g +(mor)o(e)h(powerful)f(\002le-matching)h(service,)i(at)d(the)h(ex-)888 +4568 y(pense)23 b(of)g(a)f(less)h(convenient)h(notation.)33 +b(It)23 b(is)g(intermediate)f(in)h(power)g(between)888 +4667 y(most)f(shell)f(matching)h(machinery)f(and)f(r)o(ecursive)g +Fy(find\(1\))p FC(.)888 4799 y(Each)g(pattern)g(is)g(a)g(r)o(egexp.)k +(The)c(pr)o(ocedur)o(e)f(sear)o(ches)g(fr)o(om)h FB(r)o(oot)o +FC(,)g(matching)h(the)888 4898 y(\002rst-level)c(\002les)h(against)f +(pattern)g FB(pat)2091 4925 y Fv(1)2128 4898 y FC(,)h(the)f +(second-level)g(\002les)g(against)h FB(pat)3329 4925 +y Fv(2)3366 4898 y FC(,)f(and)2071 5147 y(46)p eop +%%Page: 47 53 +47 52 bop 573 614 a FC(so)23 b(forth.)33 b(The)23 b(list)g(of)g +(\002les)h(matching)f(the)h(whole)f(path)g(pattern)g(is)g(r)o(eturned,) +f(in)573 714 y(sorted)e(or)o(der)-6 b(.)25 b(The)20 b(matcher)h(uses)g +(Spencer)6 b('s)20 b(r)o(egular)g(expr)o(ession)g(package.)573 +839 y(The)h(\002les)h Fy(.)f FC(and)g Fy(..)g FC(ar)o(e)f(never)h +(matched.)27 b(Other)22 b(dot)f(\002les)h(ar)o(e)e(only)j(matched)e(if) +573 939 y(the)g FB(dot-\002les?)e FC(ar)o(gument)h(is)i +Fy(#t)p FC(.)573 1065 y(A)j(given)g FB(pat)999 1092 y +Fo(i)1052 1065 y FC(pattern)f(is)i(matched)f(as)f(a)h(r)o(egexp,)g(so)g +(it)h(is)f(not)h(for)o(ced)e(to)h(match)573 1164 y(the)c(entir)o(e)f +(\002le)h(name.)k FB(E.g.)o FC(,)c(pattern)f Fy("t")f +FC(matches)i(any)g(\002le)g(containing)h(a)e(\223t\224)g(in)573 +1264 y(its)27 b(name,)h(while)g(pattern)e Fy("^t$")f +FC(matches)i(only)h(a)e(\002le)h(whose)h(entir)o(e)e(name)h(is)573 +1363 y(\223)p Fy(t)p FC(\224.)573 1489 y(The)21 b FB(pat)839 +1516 y Fo(i)887 1489 y FC(patterns)f(can)h(be)f(mor)o(e)h(general)f +(than)h(stated)f(above.)672 1640 y Fu(\017)42 b FC(A)c(single)i +(pattern)e(can)h(specify)f(multiple)i(levels)f(of)g(the)g(path)g(by)g +(em-)756 1740 y(bedding)27 b Fy(/)g FC(characters)g(within)i(the)f +(pattern.)46 b(For)28 b(example,)g(the)g(pattern)756 +1839 y Fy("a/b/c")j FC(gives)j(a)g(match)g(equivalent)h(to)f(the)h +(list)f(of)h(patterns)e Fy("a")43 b("b")756 1939 y("c")p +FC(.)672 2057 y Fu(\017)f FC(A)24 b FB(pat)951 2084 y +Fo(i)1004 2057 y FC(pattern)h(can)g(be)g(a)f(pr)o(ocedur)o(e,)g(which)j +(is)e(used)g(as)g(a)g(match)g(pr)o(edi-)756 2157 y(cate.)35 +b(It)25 b(will)g(be)f(r)o(epeatedly)e(called)i(with)h(a)f(candidate)f +(\002le-name)h(to)h(test.)756 2256 y(The)d(\002le-name)g(will)h(be)f +(the)h(entir)o(e)e(path)i(accumulated.)29 b(If)22 b(the)h(pr)o(ocedur)o +(e)756 2356 y(raises)h(an)h(err)o(or)f(condition,)j Fy(file-match)20 +b FC(will)26 b(catch)e(the)i(err)o(or)d(and)i(tr)o(eat)756 +2456 y(it)19 b(as)f(a)h(failed)f(match.)25 b(This)19 +b(keeps)g Fy(file-match)c FC(fr)o(om)j(being)h(blown)h(out)g(of)756 +2555 y(the)j(water)h(by)g(applying)g(tests)g(to)g(dangling)g(symlinks)i +(and)d(other)h(similar)756 2655 y(situations.)573 2806 +y(Some)d(examples:)911 2906 y Fy(\(file-match)39 b("/usr/lib")g(#f)k +("m$")f("^tab"\))f Fn(=)-14 b Fu(\))1085 3005 y Fy(\("/usr/lib/term/)o +(tab)o(30)o(0")37 b("/usr/lib/term/ta)o(b3)o(00)o(-12)o(")g(...\))911 +3205 y(\(file-match)i(".")j(#f)86 b("^lex|parse|codeg)o(en$)o(")37 +b("\\\\.c$"\))k Fn(=)-14 b Fu(\))1085 3304 y Fy(\("lex/lex.c")39 +b("lex/lexinit.c")e("lex/test.c")1129 3404 y("parse/actions.)o(c")g +("parse/error.c")h(parse/test.c")1129 3504 y("codegen/io.c")f +("codegen/walk.c"\))911 3703 y(\(file-match)i(".")j(#f)86 +b("^lex|parse|codeg)o(en$)o(/\\)o(\\.c)o($")o(\))1129 +3802 y(;;)42 b(The)h(same.)911 4002 y(\(file-match)c(".")j(#f)86 +b(file-directory?\))1085 4101 y(;;)43 b(Return)e(all)h(subdirs)f(of)i +(the)f(current)f(directory.)911 4301 y(\(file-match)e("/")j(#f)86 +b(file-directory?\))37 b Fn(=)-14 b Fu(\))1085 4400 y +Fy(\("/bin")41 b("/dev")g("/etc")g("/tmp")g("/usr"\))1085 +4500 y(;;)i(All)f(subdirs)f(of)i(root.)911 4699 y(\(file-match)c(".")j +(#f)86 b("\\\\.c"\))1085 4799 y(;;)43 b(All)f(the)h(C)g(files)e(in)i +(my)g(directory.)1756 5147 y FC(47)p eop +%%Page: 48 54 +48 53 bop 1226 614 a Fy(\(define)41 b(\(ext)h(extension\))1313 +714 y(\()p Fz(\025)d Fy(\(fn\))j(\(string-suffix?)37 +b(fn)43 b(extension\)\)\))1226 913 y(\(define)e(\(true)g(.)j(x\))e +(#t\))1226 1112 y(\(file-match)d(".")k(#f)86 b("./\\\\.c"\))1226 +1212 y(\(file-match)39 b(".")k(#f)86 b("")43 b("\\\\.c"\))1226 +1312 y(\(file-match)c(".")k(#f)86 b(true)42 b("\\\\.c"\))1226 +1411 y(\(file-match)d(".")k(#f)86 b(true)42 b(\(ext)g("c"\)\))1401 +1511 y(;;)g(All)h(the)f(C)h(files)f(of)g(all)h(my)g(immediate)c +(subdirs.)1226 1710 y(\(file-match)g(".")k(#f)f("lexer"\))f +Fn(=)-14 b Fu(\))1401 1810 y Fy(\("mylexer.c")38 b("lexer.notes"\))1401 +1910 y(;;)k(Compare)f(with)h(\(glob)f("lexer"\),)f(above.)888 +2156 y FC(Note)32 b(that)g(when)g FB(r)o(oot)f FC(is)h(the)g(curr)o +(ent)f(working)i(dir)o(ectory)e(\()p Fy(".")p FC(\),)h(when)h(it)f(is) +888 2255 y(converted)26 b(to)g(dir)o(ectory)f(form,)i(it)f(becomes)g +Fy("")p FC(,)f(and)h(doesn't)g(show)h(up)f(in)g(the)888 +2355 y(r)o(esult)21 b(\002le-names.)888 2486 y(It)i(is)h(r)o(egr)o +(ettable)d(that)i(the)g(r)o(egexp)f(wild)h(car)o(d)e(char)-6 +b(,)23 b(\223)p Fy(.)p FC(\224,)f(is)h(such)h(an)f(important)888 +2586 y(\002le)e(name)g(literal,)f(as)g(dot-\002le)h(pr)o(e\002x)f(and)g +(extension)i(delimiter)-6 b(.)681 2872 y Fy(\(create-temp-fil)o(e)37 +b FB([pr)o(e\002x])p Fy(\))85 b Fu(\000)-14 b(!)87 b +FB(string)905 b FC(pr)o(ocedur)o(e)888 3010 y Fy(Create-temp-file)12 +b FC(cr)o(eates)k(a)i(new)g(temporary)g(\002le)g(and)g(r)o(eturn)f(its) +i(name.)24 b(The)888 3110 y(optional)32 b(ar)o(gument)e(speci\002es)h +(the)f(\002lename)h(pr)o(e\002x)f(to)h(use,)i(and)d(defaults)g(to)888 +3209 y Fy("/usr/tmp/)p FB(pid)-5 b Fy(")p FC(,)20 b(wher)o(e)f +FB(pid)h FC(is)g(the)h(curr)o(ent)e(pr)o(ocess')h(id.)25 +b(The)20 b(pr)o(ocedur)o(e)e(gen-)888 3309 y(erates)j(a)h(sequence)g +(of)g(\002lenames)g(that)g(have)f FB(pr)o(e\002x)g FC(as)h(a)f(common)i +(pr)o(e\002x,)e(look-)888 3408 y(ing)28 b(for)e(a)h(\002lename)g(that)g +(doesn't)g(alr)o(eady)e(exist)i(in)g(the)g(\002le)g(system.)45 +b(When)27 b(it)888 3508 y(\002nds)g(one,)h(it)e(cr)o(eates)f(it,)i +(with)g(permission)g Fy(#o600)e FC(and)g(r)o(eturns)h(the)g +(\002lename.)888 3608 y(\(The)33 b(\002le)g(permission)i(can)d(be)h +(changed)g(to)g(a)g(mor)o(e)g(permissive)g(permission)888 +3707 y(with)22 b Fy(set-file-mode)15 b FC(after)20 b(being)h(cr)o +(eated\).)888 3839 y(This)31 b(\002le)e(is)h(guaranteed)f(to)h(be)f +(brand)g(new)-8 b(.)53 b(No)30 b(other)g(pr)o(ocess)f(will)i(have)e(it) +888 3938 y(open.)c(This)18 b(pr)o(ocedur)o(e)d(does)i(not)h(simply)g(r) +o(eturn)e(a)h(\002lename)g(that)g(is)h(very)e(likely)888 +4038 y(to)32 b(be)f(unused.)57 b(It)31 b(r)o(eturns)g(a)g(\002lename)g +(that)g(de\002nitely)h(did)f(not)h(exist)f(at)g(the)888 +4138 y(moment)22 b Fy(create-temp-file)14 b FC(cr)o(eated)19 +b(it.)888 4269 y(It)j(is)g(not)g(necessary)g(for)f(the)h(pr)o(ocess')f +(pid)h(to)g(be)f(a)g(part)g(of)h(the)g(\002lename)f(for)h(the)888 +4368 y(uniqueness)i(guarantees)e(to)h(hold.)31 b(The)23 +b(pid)f(component)i(of)f(the)f(default)g(pr)o(e\002x)888 +4468 y(simply)32 b(serves)e(to)i(scatter)e(the)g(name)h(sear)o(ches)f +(into)h(sparse)g(r)o(egions,)i(so)e(that)888 4568 y(collisions)i(ar)o +(e)d(less)h(likely)h(to)f(occur)-6 b(.)56 b(This)31 b(speeds)g(things)h +(up,)h(but)e(does)g(not)888 4667 y(af)o(fect)19 b(corr)o(ectness.)888 +4799 y(Security)33 b(note:)51 b(doing)34 b(i/o)g(to)f(\002les)h(cr)o +(eated)d(this)j(way)f(in)g Fy(/usr/tmp/)d FC(is)j(not)888 +4898 y(necessarily)18 b(secur)o(e.)23 b(General)17 b(users)g(have)g +(write)g(access)g(to)g Fy(/usr/tmp/)p FC(,)d(so)k(even)2071 +5147 y(48)p eop +%%Page: 49 55 +49 54 bop 573 614 a FC(if)18 b(an)h(attacker)e(cannot)i(access)f(the)h +(new)g(temp)f(\002le,)h(he)g(can)f(delete)g(it)h(and)f(r)o(eplace)573 +714 y(it)32 b(with)h(one)f(of)g(his)h(own.)60 b(A)32 +b(subsequent)g(open)h(of)f(this)g(\002lename)g(will)h(then)573 +814 y(give)21 b(you)g(his)g(\002le,)g(to)g(which)h(he)f(has)g(access)f +(rights.)26 b(Ther)o(e)20 b(ar)o(e)f(several)h(ways)h(to)573 +913 y(defeat)e(this)j(attack,)652 1083 y(1.)41 b(Use)32 +b Fy(temp-file-itera)o(te)p FC(,)d(below)-8 b(,)36 b(to)d(r)o(eturn)f +(the)h(\002le)g(descriptor)f(allo-)756 1182 y(cated)23 +b(when)j(the)f(\002le)g(is)g(opened.)38 b(This)25 b(will)h(work)f(if)g +(the)g(\002le)g(only)h(needs)756 1282 y(to)21 b(be)f(opened)h(once.)652 +1416 y(2.)41 b(If)23 b(the)g(\002le)h(needs)f(to)h(be)f(opened)g(twice) +h(or)f(mor)o(e,)h(cr)o(eate)d(it)j(in)g(a)f(pr)o(otected)756 +1516 y(dir)o(ectory)-9 b(,)19 b FB(e.g.)o FC(,)i Fy($HOME)p +FC(.)652 1651 y(3.)41 b(Ensur)o(e)21 b(that)g Fy(/usr/tmp)e +FC(has)i(its)i(sticky)f(bit)g(set.)28 b(This)22 b(r)o(equir)o(es)f +(system)i(ad-)756 1750 y(ministrator)e(privileges.)573 +1920 y(The)39 b(actual)f(default)f(pr)o(e\002x)h(used)h(is)g(contr)o +(olled)g(by)g(the)g(dynamic)g(variable)573 2019 y Fy(*temp-file-templ)o +(at)o(e*)p FC(,)31 b(and)j(can)g(be)g(overridden)f(for)h(incr)o(eased)f +(security)-9 b(.)573 2119 y(See)20 b Fy(temp-file-iterat)o(e)p +FC(.)365 2363 y Fy(\(temp-file-iterat)o(e)37 b FB(maker)21 +b([template])p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(object)2302 +2333 y Fv(+)2855 2363 y FC(pr)o(ocedur)o(e)365 2463 y +Fy(*temp-file-templa)o(te)o(*)1784 b FB(string)573 2606 +y FC(This)20 b(pr)o(ocedur)o(e)d(can)h(be)h(used)g(to)h(perform)e +(certain)h(atomic)g(transactions)h(on)f(the)573 2705 +y(\002le)i(system)g(involving)h(\002lenames.)k(Some)21 +b(examples:)672 2875 y Fu(\017)42 b FC(Linking)21 b(a)g(\002le)f(to)i +(a)e(fr)o(esh)g(backup)g(temp)h(name.)672 3009 y Fu(\017)42 +b FC(Cr)o(eating)19 b(and)i(opening)g(an)g(unused,)g(secur)o(e)e(temp)i +(\002le.)672 3144 y Fu(\017)42 b FC(Cr)o(eating)19 b(an)i(unused)g +(temporary)f(dir)o(ectory)-9 b(.)573 3313 y(This)41 b(pr)o(ocedur)o(e)d +(uses)j FB(template)f FC(to)g(generate)g(a)g(series)g(of)h(trial)f +(\002le)h(names.)573 3413 y FB(T)-9 b(emplate)19 b FC(is)j(a)e +Fy(format)e FC(contr)o(ol)j(string,)g(and)g(defaults)f(to)756 +3555 y Fy("/usr/tmp/)p FB(pid)-6 b Fy(.~a")573 3698 y +FC(wher)o(e)21 b FB(pid)h FC(is)g(the)g(curr)o(ent)g(pr)o(ocess')f(pr)o +(ocess)h(id.)29 b(File)23 b(names)f(ar)o(e)f(generated)f(by)573 +3797 y(calling)g Fy(format)d FC(to)j(instantiate)f(the)h(template's)f +Fy(~a)g FC(\002eld)g(with)i(a)e(varying)g(string.)573 +3932 y FB(Maker)32 b FC(is)h(a)e(pr)o(ocedur)o(e)f(which)j(is)f +(serially)g(called)f(on)h(each)g(\002le)g(name)g(gener)o(-)573 +4031 y(ated.)k(It)24 b(must)i(r)o(eturn)d(at)h(least)h(one)g(value;)g +(it)g(may)g(r)o(eturn)e(multiple)i(values.)37 b(If)573 +4131 y(the)29 b(\002rst)g(r)o(eturn)f(value)g(is)h Fy(#f)f +FC(or)g(if)h FB(maker)f FC(raises)h(the)g Fy(errno/exist)24 +b FC(errno)k(ex-)573 4231 y(ception,)h Fy(temp-file-itera)o(te)20 +b FC(will)28 b(loop,)h(generating)e(a)g(new)g(\002le)g(name)g(and)573 +4330 y(calling)18 b FB(maker)h FC(again.)24 b(If)18 b(the)g(\002rst)h +(r)o(eturn)e(value)h(is)h(tr)o(ue,)f(the)h(loop)g(is)f(terminated,)573 +4430 y(r)o(eturning)j(whatever)f(value\(s\))f FB(maker)i +FC(r)o(eturned.)573 4565 y(After)j(a)g(number)h(of)g(unsuccessful)h +(trials,)g Fy(temp-file-itera)o(te)19 b FC(may)25 b(give)g(up)573 +4664 y(and)20 b(signal)h(an)g(err)o(or)-6 b(.)573 4799 +y(Thus,)21 b(if)g(we)h(ignor)o(e)f(its)g(optional)h FB(pr)o(e\002x)e +FC(ar)o(gument,)h Fy(create-temp-file)14 b FC(could)573 +4898 y(be)20 b(de\002ned)h(as:)1756 5147 y(49)p eop +%%Page: 50 56 +50 55 bop 1071 614 a Fy(\(define)41 b(\(create-temp-fi)o(le\))1158 +714 y(\(let)h(\(\(flags)f(\(bitwise-ior)d(open/create)h +(open/exclusive\)\)\))1245 814 y(\(temp-file-iterat)o(e)1420 +913 y(\()p Fz(\025)f Fy(\(f\))1507 1013 y(\(close)j(\(open-output-fil)o +(e)d(f)43 b(flags)e(#o600\)\))1507 1112 y(f\)\)\)\))888 +1328 y FC(T)-8 b(o)22 b(r)o(ename)d(a)i(\002le)g(to)g(a)f(temporary)g +(name:)1071 1505 y Fy(\(temp-file-itera)o(te)37 b(\()p +Fz(\025)i Fy(\(backup\))1986 1605 y(\(create-hard-link)e(old-file)j +(backup\))1986 1705 y(backup\))1899 1804 y(".#temp.~a"\))f(;)k(Keep)f +(link)g(in)h(cwd.)1071 1904 y(\(delete-file)c(old-file\))888 +2081 y FC(Recall)26 b(that)f(scsh)h(r)o(eports)f(syscall)g(failur)o(e)f +(by)i(raising)f(an)h(err)o(or)e(exception,)i(not)888 +2181 y(by)i(r)o(eturning)f(an)f(err)o(or)h(code.)44 b(This)27 +b(is)h(critical)f(to)g(to)h(this)f(example\227the)g(pr)o(o-)888 +2280 y(grammer)j(can)g(assume)f(that)h(if)g(the)g Fy(temp-file-iterate) +23 b FC(call)30 b(r)o(eturns,)h(it)f(r)o(e-)888 2380 +y(turns)d(successully)-9 b(.)44 b(So)27 b(the)g(following)h +Fy(delete-file)22 b FC(call)k(can)h(be)f(r)o(eliably)g(in-)888 +2480 y(voked,)34 b(safe)c(in)h(the)h(knowledge)f(that)g(the)g(backup)g +(link)h(has)f(de\002nitely)g(been)888 2579 y(established.)888 +2718 y(T)-8 b(o)22 b(cr)o(eate)d(a)h(unique)i(temporary)e(dir)o +(ectory:)1071 2895 y Fy(\(temp-file-itera)o(te)37 b(\()p +Fz(\025)i Fy(\(dir\))i(\(create-directory)c(dir\))42 +b(dir\))1899 2994 y("/usr/tmp/tempdir)o(.~)o(a")o(\))888 +3171 y FC(Similar)22 b(operations)g(can)f(be)g(used)h(to)g(generate)f +(unique)h(symlinks)i(and)d(\002fos,)h(or)888 3271 y(to)f(r)o(eturn)f +(values)g(other)g(than)h(the)f(new)h(\002lename)f(\()p +FB(e.g.)o FC(,)g(an)g(open)h(\002le)f(descriptor)888 +3371 y(or)h(port\).)888 3509 y(The)i(default)e(template)h(is)g(in)h +(fact)e(taken)h(fr)o(om)g(the)g(value)g(of)g(the)h(dynamic)f(vari-)888 +3609 y(able)17 b Fy(*temp-file-temp)o(lat)o(e*)o FC(,)12 +b(which)18 b(itself)f(defaults)f(to)h Fy("/usr/tmp/)p +FB(pid)-5 b Fy(.~a")p FC(,)888 3708 y(wher)o(e)17 b FB(pid)g +FC(is)h(the)g(scsh)g(pr)o(ocess')g(pid.)24 b(For)18 b(incr)o(eased)e +(security)-9 b(,)18 b(a)f(user)g(may)h(wish)888 3808 +y(to)i(change)f(the)g(template)f(to)i(use)f(a)f(dir)o(ectory)h(not)g +(allowing)h(world)g(write)f(access)888 3908 y(\()p FB(e.g.)o +FC(,)i(his)g(home)h(dir)o(ectory\).)681 4115 y Fy(\(temp-file-chann)o +(el)o(\))81 b Fu(\000)-14 b(!)87 b FB([inp)20 b(outp])1013 +b FC(pr)o(ocedur)o(e)888 4262 y(This)26 b(pr)o(ocedur)o(e)e(can)h(be)g +(used)g(to)h(pr)o(ovide)f(an)g(interpr)o(ocess)g(communications)888 +4361 y(channel)30 b(with)g(arbitrary-sized)d(buf)o(fering.)49 +b(It)29 b(r)o(eturns)g(two)h(values,)h(an)e(input)888 +4461 y(port)17 b(and)f(an)h(output)g(port,)g(both)g(open)g(on)g(a)f +(new)h(temp)g(\002le.)24 b(The)17 b(temp)f(\002le)h(itself)888 +4561 y(is)27 b(deleted)e(fr)o(om)h(the)h(Unix)f(\002le)g(tr)o(ee)f +(befor)o(e)g Fy(temp-file-channel)20 b FC(r)o(eturns,)27 +b(so)888 4660 y(the)d(\002le)g(is)h(essentially)f(unnamed,)g(and)g(its) +g(disk)g(storage)g(is)g(r)o(eclaimed)e(as)i(soon)888 +4760 y(as)d(the)g(two)g(ports)g(ar)o(e)e(closed.)888 +4898 y Fy(Temp-file-channel)14 b FC(is)21 b(analogous)h(to)f +Fy(port-pipe)c FC(with)k(two)h(exceptions:)2071 5147 +y(50)p eop +%%Page: 51 57 +51 56 bop 672 614 a Fu(\017)42 b FC(If)16 b(the)h(writer)f(pr)o(ocess)g +(gets)h(ahead)f(of)g(the)h(r)o(eader)e(pr)o(ocess,)i(it)f(will)i(not)f +(hang)756 714 y(waiting)i(for)f(some)i(small)f(pipe)g(buf)o(fer)e(to)i +(drain.)24 b(It)19 b(will)h(simply)f(buf)o(fer)e(the)756 +814 y(data)i(on)i(disk.)26 b(This)c(is)f(good.)672 949 +y Fu(\017)42 b FC(If)19 b(the)h(r)o(eader)d(pr)o(ocess)i(gets)h(ahead)f +(of)g(the)h(writer)g(pr)o(ocess,)f(it)h(will)g(also)g(not)756 +1049 y(hang)e(waiting)h(for)f(data)f(fr)o(om)g(the)i(writer)f(pr)o +(ocess.)24 b(It)18 b(will)h(simply)g(see)f(and)756 1148 +y(r)o(eport)h(an)i(end)g(of)f(\002le.)26 b(This)21 b(is)g(bad.)756 +1266 y(In)i(or)o(der)e(to)j(ensur)o(e)e(that)h(an)g(end-of-\002le)f(r)o +(eturned)f(to)j(the)f(r)o(eader)d(is)k(legit-)756 1365 +y(imate,)j(the)g(r)o(eader)e(and)i(writer)f(must)i(serialise)e(their)h +(i/o.)45 b(The)27 b(simplest)756 1465 y(way)20 b(to)i(do)f(this)h(is)f +(for)g(the)g(r)o(eader)e(to)i(delay)g(doing)g(input)h(until)g(the)f +(writer)756 1565 y(has)f(completely)i(\002nished)f(doing)g(output,)g +(or)g(exited.)365 1924 y Fw(3.4)99 b(Processes)365 2167 +y Fy(\(exec)42 b FB(pr)o(og)19 b(ar)o(g1)h(.)12 b(.)g(.)g(ar)o(gn)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(no)21 b(r)o(eturn)g(value)759 +b FC(pr)o(ocedur)o(e)365 2266 y Fy(\(exec-path)40 b FB(pr)o(og)19 +b(ar)o(g1)h(.)12 b(.)g(.)g(ar)o(gn)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(no)21 b(r)o(eturn)g(value)541 b FC(pr)o(ocedur)o(e)365 +2366 y Fy(\(exec/env)40 b FB(pr)o(og)20 b(env)g(ar)o(g1)g(.)12 +b(.)g(.)g(ar)o(gn)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(no)21 +b(r)o(eturn)g(value)444 b FC(pr)o(ocedur)o(e)365 2466 +y Fy(\(exec-path/env)38 b FB(pr)o(og)20 b(env)g(ar)o(g1)g(.)12 +b(.)g(.)g(ar)o(gn)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(no)21 +b(r)o(eturn)g(value)226 b FC(pr)o(ocedur)o(e)573 2591 +y(The)27 b Fy(.../env)d FC(variants)i(take)h(an)g(envir)o(onment)g +(speci\002ed)g(as)g(a)f(string)p Fu(!)p FC(string)573 +2691 y(alist.)43 b(An)27 b(envir)o(onment)g(of)f Fy(#t)g +FC(is)h(taken)f(to)h(mean)g(the)g(curr)o(ent)f(pr)o(ocess')g(envi-)573 +2791 y(r)o(onment)21 b(\()p FB(i.e.)p FC(,)f(the)h(value)f(of)h(the)g +(external)f(char)g Fy(**environ)p FC(\).)573 2926 y([Rationale:)33 +b Fy(#f)23 b FC(is)i(a)f(mor)o(e)g(convenient)h(marker)f(for)g(the)g +(curr)o(ent)g(envir)o(onment)573 3026 y(than)f Fy(#t)p +FC(,)g(but)g(would)h(cause)f(an)g(ambiguity)g(on)h(Schemes)f(that)g +(identify)h Fy(#f)e FC(and)573 3125 y Fy(\(\))p FC(.])573 +3261 y(The)h(path-sear)o(ching)e(variants)i(sear)o(ch)e(the)i(dir)o +(ectories)f(in)h(the)g(list)h Fy(exec-path-)573 3360 +y(list)29 b FC(for)i(the)h(pr)o(ogram.)56 b(A)31 b(path-sear)o(ch)e(is) +j(not)g(performed)e(if)h(the)g(pr)o(ogram)573 3460 y(name)26 +b(contains)h(a)f(slash)g(character)o(\227it)f(is)h(used)g(dir)o(ectly) +-9 b(.)41 b(So)26 b(a)g(pr)o(ogram)g(with)573 3560 y(a)j(name)i(like)f +Fy("bin/prog")c FC(always)k(executes)f(the)i(pr)o(ogram)e +Fy(bin/prog)e FC(in)j(the)573 3659 y(curr)o(ent)20 b(working)i(dir)o +(ectory)-9 b(.)24 b(See)c Fy($path)f FC(and)h Fy(exec-path-list)p +FC(,)15 b(below)-8 b(.)573 3795 y(Note)24 b(that)g(ther)o(e)g(is)h(no)f +(analog)h(to)f(the)h(C)f(function)h Fy(execv\(\))p FC(.)33 +b(T)-8 b(o)25 b(get)f(the)g(ef)o(fect)573 3894 y(just)d(do)756 +4039 y Fy(\(apply)41 b(exec)h(prog)f(arglist\))573 4220 +y FC(All)20 b(of)g(these)g(pr)o(ocedur)o(es)f(\003ush)i(buf)o(fer)o(ed) +c(output)k(and)e(close)i(unr)o(evealed)d(ports)573 4319 +y(befor)o(e)23 b(executing)h(the)g(new)g(binary)-9 b(.)35 +b(T)-8 b(o)25 b(avoid)f(\003ushing)h(buf)o(fer)o(ed)d(output,)j(see)573 +4419 y Fy(\045exec)19 b FC(below)-8 b(.)573 4554 y(Note)21 +b(that)h(the)f(C)g Fy(exec\(\))e FC(pr)o(ocedur)o(e)h(allows)h(the)h +(zer)o(oth)f(element)g(of)g(the)h(ar)o(gu-)573 4654 y(ment)f(vector)g +(to)g(be)f(dif)o(fer)o(ent)f(fr)o(om)h(the)h(\002le)g(being)g +(executed,)e FB(e.g.)756 4799 y Fy(char)41 b(*argv[])g(=)i({"-",)f +("-f",)f(0};)756 4898 y(exec\("/bin/csh")o(,)c(argv,)42 +b(envp\);)1756 5147 y FC(51)p eop +%%Page: 52 58 +52 57 bop 888 614 a FC(The)22 b(scsh)g Fy(exec)p FC(,)d +Fy(exec-path)p FC(,)f Fy(exec/env)p FC(,)g(and)i Fy(exec-path/env)c +FC(pr)o(ocedur)o(es)k(do)888 714 y(not)e(give)f(this)h +(functionality\227element)g(0)e(of)h(the)g(ar)o(g)f(vector)h(is)h +(always)e(identical)888 814 y(to)31 b(the)f Fy(prog)e +FC(ar)o(gument.)52 b(In)30 b(the)g(rar)o(e)f(case)g(the)h(user)g +(wishes)g(to)h(dif)o(fer)o(entiate)888 913 y(these)26 +b(two)f(items,)i(he)e(can)g(use)g(the)h(low-level)f Fy(\045exec)e +FC(and)i Fy(exec-path-searc)o(h)888 1013 y FC(pr)o(ocedur)o(es.)f +(These)c(pr)o(ocedur)o(es)e(never)h(r)o(eturn)g(under)h(any)g(cir)o +(cumstances.)k(As)888 1112 y(with)e(any)f(other)g(system)g(call,)f(if)h +(ther)o(e)f(is)h(an)g(err)o(or)-6 b(,)19 b(they)i(raise)f(an)h +(exception.)681 1307 y Fy(\(\045exec)41 b FB(pr)o(og)19 +b(ar)o(glist)h(env)p Fy(\))87 b Fu(\000)-14 b(!)87 b +FB(unde\002ned)975 b FC(pr)o(ocedur)o(e)681 1406 y Fy +(\(exec-path-searc)o(h)37 b FB(fname)21 b(pathlist)p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(string)21 b(or)g Fy(#f)474 +b FC(pr)o(ocedur)o(e)888 1549 y(The)31 b Fy(\045exec)d +FC(pr)o(ocedur)o(e)h(is)i(the)f(low-level)h(interface)f(to)h(the)f +(system)i(call.)54 b(The)888 1648 y FB(ar)o(glist)27 +b FC(parameter)e(is)j(a)e(list)i(of)f(ar)o(guments;)j +FB(env)d FC(is)h(either)f(a)f(string)p Fu(!)p FC(string)j(al-)888 +1748 y(ist)e(or)e Fy(#t)p FC(.)40 b(The)26 b(new)g(pr)o(ogram's)g +Fy(argv[0])c FC(will)27 b(be)e(taken)h(fr)o(om)f Fy(\(car)42 +b FB(ar)o(glist)p Fy(\))p FC(,)888 1848 y FB(not)20 b +FC(fr)o(om)f FB(pr)o(og)o FC(.)25 b(An)20 b(envir)o(onment)g(of)g +Fy(#t)f FC(means)h(the)g(curr)o(ent)f(pr)o(ocess')g(envir)o(on-)888 +1947 y(ment.)26 b Fy(\045exec)19 b FC(does)i(not)g(\003ush)h(buf)o(fer) +o(ed)c(output)j(\(see)f Fy(flush-all-ports)p FC(\).)888 +2081 y(All)33 b(exec)f(pr)o(ocedur)o(es,)i(including)f +Fy(\045exec)p FC(,)h(coer)o(ce)e(the)g Fy(prog)g FC(and)g +Fy(arg)f FC(values)888 2181 y(to)h(strings)h(using)f(the)g(usual)g +(conversion)h(r)o(ules:)47 b(numbers)32 b(ar)o(e)e(converted)i(to)888 +2280 y(decimal)21 b(numerals,)f(and)h(symbols)h(converted)e(to)h(their) +g(print-names.)888 2414 y Fy(exec-path-search)f FC(sear)o(ches)25 +b(the)i(dir)o(ectories)e(of)i FB(pathlist)e FC(looking)j(for)e(an)g +(oc-)888 2514 y(curr)o(ence)32 b(of)g(\002le)h Fy(fname)p +FC(.)58 b(If)33 b(no)g(executable)e(\002le)i(is)f(found,)k(it)c(r)o +(eturns)g Fy(#f)p FC(.)60 b(If)888 2614 y Fy(fname)28 +b FC(contains)i(a)f(slash)h(character)-6 b(,)29 b(the)h(path)f(sear)o +(ch)g(is)g(short-cir)o(cuited,)i(but)888 2713 y(the)19 +b(pr)o(ocedur)o(e)e(still)i(checks)g(to)g(ensur)o(e)f(that)h(the)f +(\002le)h(exists)g(and)f(is)h(executable\227)888 2813 +y(if)30 b(not,)i(it)d(still)i(r)o(eturns)e Fy(#f)p FC(.)51 +b(Users)29 b(of)g(this)h(pr)o(ocedur)o(e)e(should)i(be)f(awar)o(e)f +(that)888 2912 y(it)42 b(invites)f(a)f(potential)i(race)e(condition:)67 +b(between)41 b(checking)g(the)g(\002le)g(with)888 3012 +y Fy(exec-path-search)25 b FC(and)30 b(executing)i(it)f(with)h +Fy(\045exec)p FC(,)f(the)g(\002le's)h(status)f(might)888 +3112 y(change.)k(The)24 b(only)h(atomic)f(way)f(to)i(do)e(the)h(sear)o +(ch)f(is)h(to)h(loop)f(over)g(the)g(candi-)888 3211 y(date)f(\002le)i +(names,)f(exec'ing)h(each)e(one)i(and)e(looping)j(when)e(the)h(exec)e +(operation)888 3311 y(fails.)888 3445 y(See)d Fy($path)f +FC(and)h Fy(exec-path-list)p FC(,)15 b(below)-8 b(.)681 +3639 y Fy(\(exit)41 b FB([status])p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(no)21 b(r)o(eturn)g(value)1098 b FC(pr)o(ocedur)o(e)681 +3739 y Fy(\(\045exit)41 b FB([status])p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(no)21 b(r)o(eturn)g(value)1054 b FC(pr)o(ocedur)o(e)888 +3881 y(These)24 b(pr)o(ocedur)o(es)e(terminate)i(the)f(curr)o(ent)g(pr) +o(ocess)h(with)g(a)g(given)g(exit)f(status.)888 3981 +y(The)h(default)f(exit)g(status)h(is)g(0.)34 b(The)24 +b(low-level)g Fy(\045exit)d FC(pr)o(ocedur)o(e)h(immediately)888 +4080 y(terminates)f(the)g(pr)o(ocess)f(without)i(\003ushing)h(buf)o +(fer)o(ed)18 b(output.)681 4274 y Fy(\(call-terminally)37 +b FB(thunk)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(no)21 +b(r)o(eturn)g(value)678 b FC(pr)o(ocedur)o(e)888 4417 +y Fy(call-terminally)23 b FC(calls)29 b(its)h(thunk.)51 +b(When)30 b(the)f(thunk)h(r)o(eturns,)g(the)f(pr)o(ocess)888 +4516 y(exits.)d(Although)c Fy(call-terminally)14 b FC(could)21 +b(be)f(implemented)h(as)1071 4658 y Fy(\()p Fz(\025)39 +b Fy(\(thunk\))h(\(thunk\))h(\(exit)h(0\)\))888 4799 +y FC(an)34 b(implementation)i(can)d(take)h(advantage)f(of)h(the)g(fact) +f(that)h(this)h(pr)o(ocedur)o(e)888 4898 y(never)23 b(r)o(eturns.)32 +b(For)23 b(example,)g(the)g(r)o(untime)h(can)f(start)g(with)h(a)e(fr)o +(esh)h(stack)f(and)2071 5147 y(52)p eop +%%Page: 53 59 +53 58 bop 573 614 a FC(also)23 b(start)g(with)h(a)e(fr)o(esh)g(dynamic) +h(envir)o(onment,)h(wher)o(e)f(shadowed)g(bindings)573 +714 y(ar)o(e)28 b(discar)o(ded.)49 b(This)30 b(can)f(allow)h(the)g(old) +f(stack)h(and)f(dynamic)g(envir)o(onment)573 814 y(to)i(be)g(collected) +g(\(assuming)h(this)g(data)e(is)h(not)h(r)o(eachable)d(thr)o(ough)j +(some)g(live)573 913 y(continuation\).)365 1240 y Fy(\(suspend\))84 +b Fu(\000)-15 b(!)88 b FB(unde\002ned)1459 b FC(pr)o(ocedur)o(e)573 +1393 y(Suspend)20 b(the)h(curr)o(ent)f(pr)o(ocess)g(with)i(a)e(SIGST)o +(OP)g(signal.)365 1720 y Fy(\(fork)42 b FB([thunk])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(pr)o(oc)20 b(or)h +Fy(#f)1281 b FC(pr)o(ocedur)o(e)365 1820 y Fy(\(\045fork)41 +b FB([thunk])p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(pr)o(oc)19 +b(or)i Fy(#f)1238 b FC(pr)o(ocedur)o(e)573 1973 y Fy(fork)28 +b FC(with)j(no)g(ar)o(guments)f(is)h(like)f(C)g Fy(fork\(\))p +FC(.)52 b(In)30 b(the)g(par)o(ent)g(pr)o(ocess,)h(it)g(r)o(e-)573 +2073 y(turns)19 b(the)g(child's)g FB(pr)o(ocess)g(object)g +FC(\(see)f(below)h(for)f(mor)o(e)h(information)h(on)f(pr)o(ocess)573 +2172 y(objects\).)26 b(In)21 b(the)g(child)f(pr)o(ocess,)h(it)g(r)o +(eturns)f Fy(#f)p FC(.)573 2317 y Fy(fork)h FC(with)j(an)f(ar)o(gument) +g(only)h(r)o(eturns)e(in)i(the)f(par)o(ent)f(pr)o(ocess,)h(r)o +(eturning)g(the)573 2417 y(child's)e(pr)o(ocess)f(object.)26 +b(The)21 b(child)g(pr)o(ocess)f(calls)h FB(thunk)f FC(and)g(then)i +(exits.)573 2562 y Fy(fork)27 b FC(\003ushes)j(buf)o(fer)o(ed)c(output) +k(befor)o(e)d(forking,)k(and)e(sets)g(the)g(child)g(pr)o(ocess)573 +2661 y(to)e(non-interactive.)42 b Fy(\045fork)25 b FC(does)h(not)i +(perform)e(this)h(bookkeeping;)j(it)d(simply)573 2761 +y(forks.)365 2988 y Fy(\(fork/pipe)40 b FB([thunk])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(pr)o(oc)20 b(or)h +Fy(#f)1063 b FC(pr)o(ocedur)o(e)365 3088 y Fy(\(\045fork/pipe)39 +b FB([thunk])p Fy(\))86 b Fu(\000)-15 b(!)88 b FB(pr)o(oc)19 +b(or)i Fy(#f)1020 b FC(pr)o(ocedur)o(e)573 3241 y(Like)27 +b Fy(fork)e FC(and)i Fy(\045fork)p FC(,)f(but)i(the)f(par)o(ent)f(and)g +(child)i(communicate)f(via)g(a)g(pipe)573 3341 y(connecting)17 +b(the)g(par)o(ent's)e(stdin)i(to)g(the)f(child's)h(stdout.)24 +b(These)17 b(pr)o(ocedur)o(es)d(side-)573 3440 y(ef)o(fect)19 +b(the)i(par)o(ent)e(by)i(changing)h(his)f(stdin.)573 +3585 y(In)28 b(ef)o(fect,)f Fy(fork/pipe)d FC(splices)j(a)g(pr)o(ocess) +g(into)i(the)e(data)g(str)o(eam)f(immediately)573 3685 +y(upstr)o(eam)35 b(of)g(the)h(curr)o(ent)e(pr)o(ocess.)70 +b(This)36 b(is)g(the)g(basic)f(function)h(for)f(cr)o(eat-)573 +3784 y(ing)j(pipelines.)75 b(Long)37 b(pipelines)h(ar)o(e)e(built)h(by) +g(performing)h(a)e(sequence)i(of)573 3884 y Fy(fork/pipe)16 +b FC(calls.)25 b(For)20 b(example,)f(to)h(cr)o(eate)e(a)h(backgr)o +(ound)g(two-pr)o(ocess)h(pipe)f Fy(a)573 3984 y(|)43 +b(b)p FC(,)20 b(we)h(write:)756 4174 y Fy(\(fork)41 b(\()p +Fz(\025)e Fy(\(\))k(\(fork/pipe)c(a\))k(\(b\)\)\))573 +4364 y FC(which)22 b(r)o(eturns)e(the)h(pr)o(ocess)f(object)h(for)g +Fy(b)p FC('s)f(pr)o(ocess.)573 4509 y(T)-8 b(o)21 b(cr)o(eate)e(a)h +(backgr)o(ound)h(thr)o(ee-pr)o(ocess)e(pipe)h Fy(a)43 +b(|)h(b)f(|)g(c)p FC(,)20 b(we)h(write:)756 4699 y Fy(\(fork)41 +b(\()p Fz(\025)e Fy(\(\))k(\(fork/pipe)c(a\))1279 4799 +y(\(fork/pipe)g(b\))1279 4898 y(\(c\)\)\))1756 5147 y +FC(53)p eop +%%Page: 54 60 +54 59 bop 888 614 a FC(which)22 b(r)o(eturns)e(the)h(pr)o(ocess)f +(object)i(for)e Fy(c)p FC('s)h(pr)o(ocess.)888 749 y(Note)26 +b(that)f(these)g(pr)o(ocedur)o(es)e(af)o(fect)h(\002le)h(descriptors,)h +(not)g(ports.)39 b(That)25 b(is,)h(the)888 849 y(pipe)18 +b(is)g(allocated)f(connecting)j(the)e(child's)g(\002le)g(descriptor)g +(1)f(to)i(the)f(par)o(ent's)f(\002le)888 948 y(descriptor)i(0.)24 +b FB(Any)19 b(pr)o(evious)g(Scheme)f(port)h(built)g(over)g(these)g +(affected)g(\002le)g(descriptors)888 1048 y(is)h(shifted)e(to)g(a)h +(new)-5 b(,)19 b(unused)h(\002le)f(descriptor)f(with)g +Fy(dup)g FB(befor)o(e)h(allocating)f(the)g(I/O)g(pipe.)888 +1148 y FC(This)h(means,)g(for)g(example,)f(that)g(the)h(ports)g(bound)f +(to)h Fy(\(current-input-po)o(rt)o(\))888 1247 y FC(and)f +Fy(\(current-output)o(-p)o(ort)o(\))11 b FC(in)19 b(either)e(pr)o +(ocess)g(ar)o(e)f(not)j(af)o(fected\227they)c(still)888 +1347 y(r)o(efer)21 b(to)h(the)g(same)g(I/O)h(sour)o(ces)f(and)f(sinks)i +(as)f(befor)o(e.)28 b(Remember)22 b(the)h(simple)888 +1446 y(scsh)17 b(r)o(ule:)23 b(Scheme)15 b(ports)h(ar)o(e)f(bound)h(to) +g(I/O)g(sour)o(ces)g(and)f(sinks,)j FB(not)d FC(particular)888 +1546 y(\002le)21 b(descriptors.)888 1681 y(If)k(the)g(child)h(pr)o +(ocess)e(wishes)i(to)g(r)o(ebind)e(the)h(curr)o(ent)g(output)g(port)h +(to)f(the)g(pipe)888 1780 y(on)40 b(\002le)f(descriptor)f(1,)43 +b(it)c(can)f(do)h(this)g(using)h Fy(with-current-out)o(put)o(-p)o(or)o +(t)888 1880 y FC(or)e(a)e(r)o(elated)f(form.)75 b(Similarly)-9 +b(,)41 b(if)36 b(the)i(par)o(ent)e(wishes)i(to)f(change)g(the)g(cur)o +(-)888 1980 y(r)o(ent)i(input)g(port)g(to)g(the)g(pipe)f(on)i(\002le)f +(descriptor)f(0,)k(it)d(can)g(do)g(this)g(using)888 2079 +y Fy(set-current-input)o(-p)o(ort)o(!)17 b FC(or)23 b(a)f(r)o(elated)f +(form.)32 b(Her)o(e)21 b(is)j(an)e(example)g(show-)888 +2179 y(ing)g(how)f(to)h(set)e(up)h(the)g(I/O)g(ports)g(on)h(both)f +(sides)g(of)g(the)f(pipe:)1071 2349 y Fy(\(fork/pipe)39 +b(\()p Fz(\025)g Fy(\(\))1638 2448 y(\(with-current-o)o(utp)o(ut)o(-po) +o(rt)e(\(fdes->outport)h(1\))1725 2548 y(\(display)i("Hello,)h +(world.\\n"\)\)\)\))1071 2747 y(\(set-current-inp)o(ut-)o(po)o(rt)o(!)d +(\(fdes->inport)g(0\))1071 2847 y(\(read-line\))344 b(;)43 +b(Read)f(the)h(string)e(output)g(by)i(the)f(child.)888 +3017 y FC(None)27 b(of)g(this)g(is)h(necessary)e(when)h(the)g(I/O)g(is) +g(performed)f(by)h(an)f(exec'd)g(pr)o(o-)888 3116 y(gram)17 +b(in)g(the)g(child)g(or)g(par)o(ent)f(pr)o(ocess,)h(only)h(when)f(the)g +(pipe)g(will)g(be)g(r)o(efer)o(enced)888 3216 y(by)k(Scheme)g(code)f +(thr)o(ough)h(one)g(of)g(the)g(default)f(curr)o(ent)g(I/O)h(ports.)681 +3413 y Fy(\(fork/pipe+)39 b FB(conns)21 b([thunk])p Fy(\))85 +b Fu(\000)-14 b(!)87 b FB(pr)o(oc)20 b(or)h Fy(#f)803 +b FC(pr)o(ocedur)o(e)681 3512 y Fy(\(\045fork/pipe+)38 +b FB(conns)21 b([thunk])p Fy(\))86 b Fu(\000)-14 b(!)87 +b FB(pr)o(oc)19 b(or)i Fy(#f)760 b FC(pr)o(ocedur)o(e)888 +3655 y(Like)26 b Fy(fork/pipe)p FC(,)d(but)i(the)h(pipe)g(connections)h +(between)e(the)h(child)g(and)f(par)o(ent)888 3755 y(ar)o(e)20 +b(speci\002ed)g(by)h(the)g(connection)h(list)f FB(conns)p +FC(.)26 b(See)20 b(the)1071 3898 y Fy(\(|+)42 b FB(conns)i(pf)1537 +3925 y Fv(1)1618 3898 y Fy(...)f FB(pf)1846 3925 y Fo(n)1891 +3898 y Fy(\))888 4041 y FC(pr)o(ocess)21 b(form)f(for)h(a)f +(description)h(of)g(connection)h(lists.)681 4317 y FA(3.4.1)81 +b(Process)20 b(objects)f(and)h(process)g(reaping)681 +4503 y FC(Scsh)27 b(uses)g FB(pr)o(ocess)f(objects)i +FC(to)f(r)o(epr)o(esent)e(Unix)i(pr)o(ocesses.)44 b(They)27 +b(ar)o(e)e(cr)o(eated)g(by)i(the)681 4603 y Fy(fork)19 +b FC(pr)o(ocedur)o(e,)f(and)j(have)f(the)h(following)h(exposed)e(str)o +(uctur)o(e:)888 4799 y Fy(\(define-record)38 b(proc)1237 +4898 y(pid\))2071 5147 y FC(54)p eop +%%Page: 55 61 +55 60 bop 393 614 a FC(The)28 b(only)g(exposed)f(slot)i(in)f(a)f(pr)o +(oc)g(r)o(ecor)o(d)f(is)i(the)g(pr)o(ocess')f(pid,)i(the)f(integer)g +(id)f(as-)365 714 y(signed)20 b(by)f(Unix)g(to)g(the)g(pr)o(ocess.)25 +b(The)19 b(only)h(exported)e(primitive)h(pr)o(ocedur)o(es)e(for)i(ma-) +365 814 y(nipulating)j(pr)o(ocess)e(objects)i(ar)o(e)d +Fy(proc?)g FC(and)h Fy(proc:pid)p FC(.)j(Pr)o(ocess)e(objects)g(ar)o(e) +f(cr)o(eated)365 913 y(with)i(the)f Fy(fork)e FC(pr)o(ocedur)o(e.)365 +1065 y Fy(\(pid->proc)40 b FB(pid)20 b([pr)o(obe?])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(pr)o(oc)1111 b FC(pr)o(ocedur)o(e) +573 1208 y(This)24 b(pr)o(ocedur)o(e)e(maps)i(integer)g(Unix)g(pr)o +(ocess)f(ids)i(to)f(scsh)g(pr)o(ocess)g(objects.)36 b(It)573 +1308 y(is)22 b(intended)f(for)h(use)f(in)h(interactive)f(and)h +(debugging)g(code,)f(and)g(is)h(depr)o(ecated)573 1407 +y(for)30 b(use)h(in)g(pr)o(oduction)g(code.)55 b(If)30 +b(ther)o(e)g(is)h(no)h(pr)o(ocess)e(object)h(in)g(the)g(system)573 +1507 y(indexed)19 b(by)g(the)h(given)f(pid,)h Fy(pid->proc)p +FC('s)c(action)j(is)h(determined)f(by)h(the)f FB(pr)o(obe?)573 +1607 y FC(parameter)g(\(default)g Fy(#f)p FC(\):)p 1174 +1677 1455 4 v 1174 1777 4 100 v 1227 1747 a FB(pr)o(obe?)p +1666 1777 V 270 w FC(Return)p 2625 1777 V 1174 1780 1455 +4 v 1174 1796 V 1174 1896 4 100 v 1227 1866 a Fy(#f)p +1666 1896 V 404 w FB(signal)i(err)o(or)g(condition.)p +2625 1896 V 1174 1899 1455 4 v 1174 1999 4 100 v 1227 +1969 a Fy('create)p 1666 1999 V 184 w FC(Cr)o(eate)e(new)i(pr)o(oc)f +(object.)p 2625 1999 V 1174 2002 1455 4 v 1174 2102 4 +100 v 1227 2072 a(T)-7 b(r)o(ue)20 b(value)p 1666 2102 +V 103 w Fy(#f)p 2625 2102 V 1174 2105 1455 4 v 490 2287 +a FC(Sometime)h(after)e(a)h(child)g(pr)o(ocess)g(terminates,)g(scsh)h +(will)g(perform)f(a)g Fy(wait)f FC(system)365 2387 y(call)26 +b(on)g(the)g(child)g(in)g(backgr)o(ound,)g(caching)g(the)g(pr)o(ocess') +f(exit)g(status)h(in)g(the)g(child's)365 2486 y(pr)o(oc)34 +b(object.)65 b(This)34 b(is)g(called)f(\223r)o(eaping\224)f(the)i(pr)o +(ocess.)65 b(Once)34 b(the)g(child)g(has)g(been)365 2586 +y(waited,)g(the)e(Unix)g(kernel)g(can)f(fr)o(ee)g(the)h(storage)g +(allocated)f(for)g(the)h(dead)f(pr)o(ocess')365 2685 +y(exit)21 b(information,)i(so)f(pr)o(ocess)f(r)o(eaping)f(pr)o(events)h +(the)g(pr)o(ocess)g(table)g(fr)o(om)g(becoming)365 2785 +y(clutter)o(ed)h(with)i(un-waited)e(dead)g(child)h(pr)o(ocesses)f +(\(a.k.a.)31 b(\223zombies\224\).)g(This)23 b(can)g(be)365 +2885 y(especially)e(sever)o(e)f(if)h(the)g(scsh)h(pr)o(ocess)f(never)f +(waits)i(on)g(child)f(pr)o(ocesses)g(at)f(all;)h(if)g(the)365 +2984 y(pr)o(ocess)h(table)g(over\003ows)i(with)f(for)o(gotten)f +(zombies,)h(the)g(OS)f(may)g(be)h(unable)f(to)h(fork)365 +3084 y(further)d(pr)o(ocesses.)490 3212 y(Reaping)27 +b(a)g(child)g(pr)o(ocess)f(moves)i(its)f(exit)g(status)g(information)h +(fr)o(om)e(the)i(kernel)365 3311 y(into)j(the)f(scsh)h(pr)o(ocess,)h +(wher)o(e)d(it)i(is)f(cached)f(inside)i(the)f(child's)g(pr)o(ocess)g +(object.)54 b(If)365 3411 y(the)23 b(scsh)f(user)g(dr)o(ops)g(all)g +(pointers)g(to)h(the)f(pr)o(ocess)f(object,)i(it)f(will)h(simply)g(be)f +(garbage)365 3511 y(collected.)35 b(On)24 b(the)g(other)h(hand,)f(if)g +(the)g(scsh)g(pr)o(ogram)f(r)o(etains)g(a)h(pointer)g(to)g(the)g(pr)o +(o-)365 3610 y(cess)d(object,)g(it)f(can)h(use)f(scsh's)i +Fy(wait)c FC(system)k(call)e(to)h(synchr)o(onise)g(with)h(the)e(child)h +(and)365 3710 y(r)o(etrieve)h(its)h(exit)g(status)g(multiple)g(times)g +(\(this)h(is)f(not)g(possible)h(with)f(simple)h(Unix)e(in-)365 +3809 y(teger)f(pids)f(in)i(C\227the)e(pr)o(ogrammer)g(can)h(only)g +(wait)g(on)h(a)e(pid)g(once\).)490 3937 y(Thus,)h(pr)o(ocess)g(objects) +g(allow)g(scsh)h(pr)o(ogrammer)e(to)h(do)g(two)h(things)g(not)g +(allowed)365 4037 y(in)g(other)f(pr)o(ogramming)g(envir)o(onments:)490 +4233 y Fu(\017)41 b FC(Subpr)o(ocesses)30 b(that)g(ar)o(e)f(never)i +(waited)f(on)h(ar)o(e)e(still)j(r)o(emoved)d(fr)o(om)i(the)f(pr)o(o-) +573 4333 y(cess)g(table,)i(and)e(their)g(associated)g(exit)g(status)g +(data)f(is)i(eventually)f(automati-)573 4432 y(cally)20 +b(garbage)g(collected.)490 4602 y Fu(\017)41 b FC(Subpr)o(ocesses)20 +b(can)g(be)h(waited)f(on)h(multiple)h(times.)490 4799 +y(However)-6 b(,)26 b(note)g(that)g(once)g(a)f(child)h(has)g(exited,)g +(if)f(the)h(scsh)g(pr)o(ogrammer)f(dr)o(ops)365 4898 +y(all)e(pointers)g(to)f(the)h(child's)g(pr)o(oc)f(object,)h(the)f +(child's)h(exit)g(status)f(will)h(be)g(r)o(eaped)d(and)1756 +5147 y(55)p eop +%%Page: 56 62 +56 61 bop 681 614 a FC(thr)o(own)17 b(away)-9 b(.)24 +b(This)17 b(is)h(the)f(intended)g(behaviour)-6 b(,)17 +b(and)f(it)h(means)h(that)e(integer)h(pids)g(ar)o(e)681 +714 y(not)24 b(enough)g(to)g(cause)f(a)g(pr)o(ocess's)g(exit)g(status)h +(to)f(be)h(r)o(etained)e(by)h(the)h(scsh)f(r)o(untime.)681 +814 y(\(This)e(is)g(because)f(it)h(is)g(clearly)f(impossible)i(to)f(GC) +g(data)e(r)o(efer)o(enced)f(by)j(integers.\))805 938 +y(As)32 b(a)f(convenience)i(for)f(interactive)f(use)h(and)f(debugging,) +k(all)d(pr)o(ocedur)o(es)e(that)681 1038 y(take)24 b(pr)o(ocess)g +(objects)h(will)g(also)g(accept)e(integer)h(Unix)h(pids)f(as)g(ar)o +(guments,)h(coer)o(cing)681 1137 y(them)k(to)h(the)f(corr)o(esponding)h +(pr)o(ocess)e(objects.)52 b(Since)28 b(integer)i(pr)o(ocess)e(ids)i(ar) +o(e)d(not)681 1237 y(r)o(eliable)c(ways)h(to)h(keep)f(a)g(child's)h +(exit)f(status)g(fr)o(om)g(being)h(r)o(eaped)d(and)i(garbage)f(col-)681 +1337 y(lected,)18 b(pr)o(ogrammers)g(ar)o(e)e(encouraged)i(to)h(use)f +(pr)o(ocess)g(objects)h(in)g(pr)o(oduction)g(code.)681 +1479 y Fy(\(autoreap-policy)37 b FB([policy])p Fy(\))85 +b Fu(\000)-15 b(!)88 b FB(old-policy)810 b FC(pr)o(ocedur)o(e)888 +1614 y(The)20 b(scsh)g(pr)o(ogrammer)f(can)h(choose)g(dif)o(fer)o(ent)e +(policies)i(for)g(automatic)f(pr)o(ocess)888 1714 y(r)o(eaping.)39 +b(The)25 b(policy)h(is)g(determined)e(by)i(applying)f(this)h(pr)o +(ocedur)o(e)e(to)h(one)h(of)888 1813 y(the)21 b(values)g +Fy('early)p FC(,)d Fy('late)p FC(,)g(or)j Fy(#f)f FC(\()p +FB(i.e.)o FC(,)h(no)g(autor)o(eap\).)888 1973 y FA(early)41 +b FC(The)25 b(child)g(is)h(r)o(eaped)d(fr)o(om)i(the)g(Unix)g(kernel's) +g(pr)o(ocess)g(table)f(into)i(scsh)1071 2072 y(as)h(soon)i(as)f(it)g +(dies.)46 b(This)29 b(is)f(done)g(by)f(having)h(a)g(signal)g(handler)f +(for)h(the)1071 2172 y Fy(SIGCHLD)34 b FC(signal)j(r)o(eap)e(the)i(pr)o +(ocess.)147 b FB(If)37 b(a)f(scsh)h(pr)o(ogram)e(sets)i(its)g(own)1071 +2271 y(handler)29 b(for)h(the)f Fy(SIGCHLD)d FB(signal,)32 +b(the)d(handler)g(must)g(r)o(eap)g(dead)f(childr)o(en)h(by)1071 +2371 y(calling)h Fy(wait)p FB(,)g Fy(wait-any)p FB(,)f(or)h +Fy(reap-zombies)p FB(.)48 b FC(W)-8 b(e)30 b(depr)o(ecate)e(interr)o +(upt-)1071 2471 y(driven)17 b(code,)h(and)g(hope)g(to)g(pr)o(ovide)f +(alternative)f(tools)j(in)f(a)g(futur)o(e,)f(multi-)1071 +2570 y(thr)o(eaded)i(r)o(elease)g(of)i(scsh.)888 2688 +y FA(late)40 b FC(The)21 b(child)h(is)f(not)h(autor)o(eaped)d(until)j +(it)f(dies)g FB(and)g FC(the)g(scsh)h(pr)o(ogram)f(dr)o(ops)1071 +2780 y(all)g(pointers)h(to)f(its)g(pr)o(ocess)g(object.)27 +b(That)21 b(is,)g(the)g(pr)o(ocess)g(table)f(is)i(cleaned)1071 +2871 y(out)f(during)g(garbage)f(collection.)1226 2989 +y Fl(Oops:)50 b Fk(The)18 b Fh(late)g Fk(policy)f(is)g(not)h(supported) +e(under)h(the)h(curr)o(ent)f(r)o(elease)1226 3080 y(of)24 +b(scsh.)39 b(It)24 b(r)o(equir)o(es)d(mor)o(e)i(sophisticated)h(gc)f +(hooks)g(than)j(we)e(can)h(get)1226 3171 y(fr)o(om)18 +b(the)h(r)o(elease)e(of)h(Scheme)i(48)f(that)h(we)f(use.)888 +3298 y Fy(#f)41 b FC(If)20 b(autor)o(eaping)e(is)j(turned)e(of)o(f,)g +(pr)o(ocess)h(r)o(eaping)f(is)h(completely)g(under)g(con-)1071 +3397 y(tr)o(ol)30 b(of)f(the)h(pr)o(ogrammer)-6 b(,)31 +b(who)g(can)e(for)o(ce)g(outstanding)h(zombies)g(to)g(be)1071 +3497 y(r)o(eaped)h(by)i(manually)h(calling)f(the)h Fy(reap-zombies)28 +b FC(pr)o(ocedur)o(e)j(\(see)i(be-)1071 3597 y(low\).)888 +3756 y(Note)27 b(that)f(under)f(any)i(of)f(the)g(autor)o(eap)e +(policies,)k(a)e(particular)f(pr)o(ocess)g Fz(p)h FC(can)888 +3856 y(be)i(manually)g(r)o(eaped)e(into)j(scsh)g(by)f(simply)g(calling) +h Fy(\(wait)41 b Fz(p)p Fy(\))p FC(.)47 b FB(All)28 b +FC(zombies)888 3955 y(can)21 b(be)f(manually)h(r)o(eaped)e(with)i +Fy(reap-zombies)p FC(.)888 4085 y(The)40 b Fy(autoreap-policy)34 +b FC(pr)o(ocedur)o(e)k(r)o(eturns)h(the)h(policy's)g(pr)o(evious)g +(value.)888 4184 y(Calling)27 b Fy(autoreap-policy)19 +b FC(with)27 b(no)g(ar)o(guments)f(r)o(eturns)f(the)h(curr)o(ent)f +(policy)888 4284 y(without)d(no)g(change.)681 4565 y +Fy(\(reap-zombies\))81 b Fu(\000)-14 b(!)87 b FB(boolean)1321 +b FC(pr)o(ocedur)o(e)888 4699 y(This)25 b(pr)o(ocedur)o(e)e(r)o(eaps)g +(all)i(outstanding)g(exited)f(child)h(pr)o(ocesses)f(into)h(scsh.)38 +b(It)888 4799 y(r)o(eturns)26 b(tr)o(ue)g(if)g(ther)o(e)f(ar)o(e)g(no)i +(mor)o(e)f(child)g(pr)o(ocesses)g(to)g(wait)g(on,)i(and)e(false)f(if) +888 4898 y(ther)o(e)20 b(ar)o(e)g(outstanding)h(pr)o(ocesses)g(still)g +(r)o(unning)h(or)f(suspended.)2071 5147 y(56)p eop +%%Page: 57 63 +57 62 bop 365 906 a FA(Issues)20 b(with)g(process)g(reaping)365 +1110 y FC(Reaping)26 b(a)f(pr)o(ocess)h(does)f(not)i(r)o(eveal)d(its)i +(pr)o(ocess)f(gr)o(oup)h(at)f(the)h(time)g(of)g(death;)h(this)365 +1210 y(information)g(is)g(lost)f(when)h(the)f(pr)o(ocess)g(r)o(eaped.) +39 b(This)26 b(means)g(that)g(a)g(dead,)g(r)o(eaped)365 +1309 y(pr)o(ocess)h(is)h FB(not)f(eligible)h FC(as)f(a)g(r)o(eturn)g +(value)g(for)g(a)g(futur)o(e)f Fy(wait-process-grou)o(p)21 +b FC(call.)365 1409 y(This)f(is)f(not)h(likely)f(to)g(be)g(a)f(pr)o +(oblem)h(for)f(most)i(code,)f(as)f(pr)o(ograms)h(almost)g(never)g(wait) +365 1509 y(on)g(exited)d(pr)o(ocesses)i(by)f(pr)o(ocess)g(gr)o(oup.)25 +b(Pr)o(ocess)17 b(gr)o(oup)g(waiting)i(is)f(usually)f(applied)365 +1608 y(to)24 b FB(stopped)e FC(pr)o(ocesses,)i(which)g(ar)o(e)e(never)h +(r)o(eaped.)32 b(So)23 b(it)h(is)g(unlikely)g(that)f(this)i(will)f(be) +365 1708 y(a)d(pr)o(oblem)f(for)h(most)g(pr)o(ograms.)490 +1848 y(Automatic)30 b(pr)o(ocess)g(r)o(eaping)g(is)h(a)f(useful)g(pr)o +(ogramming)h(convenience.)55 b(How-)365 1948 y(ever)-6 +b(,)28 b(if)f(a)g(pr)o(ogram)f(is)i(car)o(eful)d(to)j(wait)f(for)g(all) +g(childr)o(en,)h(and)f(does)g(not)h(wish)g(auto-)365 +2047 y(matic)17 b(r)o(eaping)f(to)i(happen,)f(the)g(pr)o(ogrammer)g +(can)g(simply)h(turn)f(pr)o(ocess)f(autor)o(eaping)365 +2147 y(of)o(f.)490 2287 y(Pr)o(ograms)35 b(that)g(do)g(not)h(wish)h(to) +e(use)g(automatic)h(pr)o(ocess)e(r)o(eaping)h(should)h(be)365 +2387 y(awar)o(e)17 b(that)i(some)g(scsh)g(r)o(outines)g(cr)o(eate)e +(subpr)o(ocesses)i(but)f(do)h(not)g(r)o(eturn)f(the)h(child's)365 +2487 y(pid:)27 b Fy(run/port*)p FC(,)17 b(and)k(its)h(r)o(elated)e(pr)o +(ocedur)o(es)g(and)h(special)g(forms)g(\()p Fy(run/strings)p +FC(,)c FB(et)365 2586 y(al.)p FC(\).)32 b(Automatic)22 +b(pr)o(ocess)h(r)o(eaping)f(will)h(clean)g(the)g(child)g(pr)o(ocesses)g +(cr)o(eated)d(by)j(these)365 2686 y(pr)o(ocedur)o(es)f(out)i(of)g(the)g +(kernel's)g(pr)o(ocess)f(table.)34 b(If)24 b(a)f(pr)o(ogram)g(doesn't)h +(use)g(pr)o(ocess)365 2786 y(r)o(eaping,)32 b(it)f(should)h(either)e +(avoid)h(these)g(forms,)i(or)e(use)g Fy(wait-any)c FC(to)k(wait)g(for)f +(the)365 2885 y(childr)o(en)21 b(to)g(exit.)365 3177 +y FA(3.4.2)81 b(Process)20 b(waiting)365 3401 y Fy(\(wait)42 +b FB(pr)o(oc/pid)18 b([\003ags])p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(status)1168 b FC(pr)o(ocedur)o(e)573 3530 +y(This)21 b(pr)o(ocedur)o(e)d(waits)j(until)g(a)f(child)g(pr)o(ocess)g +(exits,)g(and)g(r)o(eturns)g(its)h(exit)f(code.)573 3630 +y(The)28 b FB(pr)o(oc/pid)e FC(ar)o(gument)i(is)h(either)f(a)g(pr)o +(ocess)f(object)i(\(section)g(3.4.1\))d(or)i(an)g(in-)573 +3730 y(teger)23 b(pr)o(ocess)f(id.)33 b Fy(Wait)22 b +FC(r)o(eturns)h(the)g(child's)h(exit)f(status)g(code)g(\(or)g +(suspension)573 3829 y(code,)29 b(if)e(the)h Fy(wait/stopped-chil)o +(dre)o(n)22 b FC(option)29 b(is)f(used,)h(see)e(below\).)47 +b(Status)573 3929 y(values)20 b(can)h(be)f(queried)h(with)g(the)g(pr)o +(ocedur)o(es)e(in)i(section)h(3.4.3.)573 4072 y(The)f +FB(\003ags)g FC(ar)o(gument)g(is)g(an)g(integer)g(whose)h(bits)g +(specify)f(additional)g(options.)28 b(It)573 4172 y(is)21 +b(composed)g(by)g(or)6 b('ing)22 b(together)f(the)g(following)h +(\003ags:)p 573 4327 2662 4 v 573 4427 4 100 v 626 4397 +a(Flag)p 1591 4427 V 860 w(Meaning)p 3231 4427 V 573 +4430 2662 4 v 573 4447 V 573 4546 4 100 v 626 4516 a +Fy(wait/poll)p 1591 4546 V 622 w FC(Return)f Fy(#f)f +FC(immediately)h(if)g(child)g(still)g(active.)p 3231 +4546 V 573 4549 2662 4 v 573 4649 4 100 v 626 4619 a +Fy(wait/stopped-chi)o(ldr)o(en)p 1591 4649 V 96 w FC(W)-8 +b(ait)21 b(for)g(suspend)g(as)f(well)h(as)g(exit.)p 3231 +4649 V 573 4652 2662 4 v 365 4845 a Fy(\(wait-any)40 +b FB([\003ags])p Fy(\))86 b Fu(\000)-14 b(!)87 b FB([pr)o(oc)19 +b(status])1069 b FC(pr)o(ocedur)o(e)1756 5147 y(57)p +eop +%%Page: 58 64 +58 63 bop 888 614 a FC(The)24 b(optional)g FB(\003ags)f +FC(ar)o(gument)g(is)g(as)g(for)g Fy(wait)p FC(.)31 b(This)24 +b(pr)o(ocedur)o(e)e(waits)h(for)g(any)888 714 y(child)e(pr)o(ocess)f +(to)h(exit)f(\(or)h(stop,)f(if)h(the)f Fy(wait/stopped-chil)o(dr)o(en) +14 b FC(\003ag)21 b(is)g(used\))888 814 y(It)g(r)o(eturns)g(the)g(pr)o +(ocess')g(pr)o(ocess)f(object)h(and)g(status)g(code.)26 +b(If)21 b(ther)o(e)f(ar)o(e)f(no)j(chil-)888 913 y(dr)o(en)k(left)f +(for)h(which)h(to)g(wait,)g(the)f(two)h(values)f Fy([#f)42 +b(#t])25 b FC(ar)o(e)g(r)o(eturned.)40 b(If)26 b(the)888 +1013 y Fy(wait/poll)18 b FC(\003ag)k(is)f(used,)g(and)g(none)i(of)e +(the)g(childr)o(en)g(ar)o(e)f(immediately)i(eligble)888 +1112 y(for)f(waiting,)g(then)g(the)g(values)f Fy([#f)43 +b(#f])19 b FC(ar)o(e)h(r)o(eturned:)p 1688 1181 1057 +4 v 1688 1281 4 100 v 1741 1251 a([)p Fy(#f)g(#f)p FC(])p +2042 1281 V 102 w(Poll,)h(none)h(r)o(eady)p 2742 1281 +V 1688 1284 1057 4 v 1688 1384 4 100 v 1741 1354 a([)p +Fy(#f)e(#t)p FC(])p 2042 1384 V 102 w(No)h(childr)o(en)p +2742 1384 V 1688 1387 1057 4 v 888 1490 a Fy(Wait-any)71 +b FC(will)k(not)f(r)o(eturn)g(a)f(pr)o(ocess)h(that)f(has)h(been)g(pr)o +(eviously)888 1589 y(waited)49 b(by)h(any)g(other)g(pr)o(ocess-wait)f +(pr)o(ocedur)o(e)e(\()p Fy(wait)p FC(,)55 b Fy(wait-any)p +FC(,)e(and)888 1689 y Fy(wait-process-grou)o(p)p FC(\).)47 +b(It)30 b(will)h(r)o(eturn)e(r)o(eaped)f(pr)o(ocesses)i(that)g(haven't) +g(yet)888 1789 y(been)21 b(waited.)888 1922 y(The)g(use)g(of)g +Fy(wait-any)c FC(is)k(depr)o(ecated.)681 2214 y Fy(\(wait-process-gr)o +(ou)o(p)38 b FB(pr)o(oc/pid)18 b([\003ags])p Fy(\))86 +b Fu(\000)-14 b(!)87 b FB([pr)o(oc)19 b(status])338 b +FC(pr)o(ocedur)o(e)888 2356 y(This)18 b(pr)o(ocedur)o(e)e(waits)i(for)f +(any)h(child)g(whose)g(pr)o(ocess)f(gr)o(oup)g(is)h FB(pr)o(oc/pid)e +FC(\(either)888 2455 y(a)21 b(pr)o(ocess)f(object)h(or)g(a)f(pid\).)25 +b(The)c FB(\003ags)f FC(ar)o(gument)h(is)g(as)f(for)h +Fy(wait)p FC(.)888 2589 y(Note)j(that)g(if)g(the)g(pr)o(ogrammer)f +(wishes)i(to)f(wait)g(for)g(exited)f(pr)o(ocesses)h(by)g(pr)o(o-)888 +2688 y(cess)36 b(gr)o(oup,)k(the)c(pr)o(ogram)f(should)i(take)f(car)o +(e)e(not)j(to)f(use)g(pr)o(ocess)g(r)o(eaping)888 2788 +y(\(section)29 b(3.4.1\),)e(as)g(this)i(loses)f(pr)o(ocess)g(gr)o(oup)f +(information.)48 b(However)-6 b(,)29 b(most)888 2888 +y(pr)o(ocess-gr)o(oup)h(waiting)g(is)h(for)f(stopped)g(pr)o(ocesses)g +(\(to)g(implement)h(job)g(con-)888 2987 y(tr)o(ol\),)j(so)d(this)h(is)g +(rar)o(ely)e(an)h(issue,)j(as)d(stopped)g(pr)o(ocesses)g(ar)o(e)f(not)i +(subject)g(to)888 3087 y(r)o(eaping.)681 3482 y FA(3.4.3)81 +b(Analysing)19 b(process)h(status)f(codes)681 3666 y +FC(When)26 b(a)f(child)h(pr)o(ocess)f(dies)h(\(or)f(is)h(suspended\),)g +(its)h(par)o(ent)d(can)i(call)f(the)h Fy(wait)e FC(pr)o(o-)681 +3766 y(cedur)o(e)d(to)h(r)o(ecover)f(the)h(exit)h(\(or)f(suspension\))h +(status)f(of)g(the)h(child.)30 b(The)22 b(exit)g(status)h(is)681 +3866 y(a)e(small)h(integer)g(that)f(encodes)h(information)h(describing) +e(how)i(the)f(child)g(terminated.)681 3965 y(The)27 b(bit-level)h +(format)f(of)h(the)f(exit)h(status)g(is)g(not)g(de\002ned)f(by)j(P)t +Ft(O)t(S)t(I)t(X)r FC(;)i(you)d(must)f(use)681 4065 y(the)i(following)h +(thr)o(ee)e(functions)h(to)g(decode)f(one.)53 b(However)-6 +b(,)31 b(if)f(a)f(child)h(terminates)681 4164 y(normally)20 +b(with)g(exit)g(code)f(0,)i(P)t Ft(O)t(S)t(I)t(X)i FC(does)c(r)o(equir) +o(e)f Fy(wait)g FC(to)i(r)o(eturn)f(an)g(exit)h(status)f(that)681 +4264 y(is)i(exactly)g(zer)o(o.)k(So)c Fy(\(zero?)42 b +FB(status)o Fy(\))21 b FC(is)h(a)e(corr)o(ect)g(way)h(to)h(test)f(for)g +(non-err)o(or)-6 b(,)21 b(normal)681 4364 y(termination,)g +FB(e.g.)o FC(,)888 4556 y Fy(\(if)43 b(\(zero?)e(\(run)h(\(rcp)g +(scsh.tar.gz)d(lambda.csd.hku.)o(hk:)o(\)\))o(\))1063 +4656 y(\(delete-file)f("scsh.tar.gz"\)\))681 4898 y(\(status:exit-val)f +FB(status)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(integer)21 +b(or)g Fy(#f)760 b FC(pr)o(ocedur)o(e)2071 5147 y(58)p +eop +%%Page: 59 65 +59 64 bop 365 614 a Fy(\(status:stop-sig)37 b FB(status)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(integer)21 b(or)g +Fy(#f)760 b FC(pr)o(ocedur)o(e)365 714 y Fy(\(status:term-sig)37 +b FB(status)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(integer)21 +b(or)g Fy(#f)760 b FC(pr)o(ocedur)o(e)573 850 y(For)27 +b(a)g(given)g(status)g(value)f(pr)o(oduced)g(by)h(calling)g +Fy(wait)p FC(,)g(exactly)f(one)i(of)e(these)573 950 y(r)o(outines)21 +b(will)g(r)o(eturn)f(a)h(tr)o(ue)f(value.)573 1081 y(If)31 +b(the)h(child)g(pr)o(ocess)g(exited)f(normally)-9 b(,)35 +b Fy(status:exit-val)25 b FC(r)o(eturns)32 b(the)g(exit)573 +1180 y(code)26 b(for)g(the)g(child)g(pr)o(ocess)g(\()p +FB(i.e.)o FC(,)i(the)e(value)f(the)i(child)f(passed)g(to)g +Fy(exit)f FC(or)h(r)o(e-)573 1280 y(turned)20 b(fr)o(om)h +Fy(main)p FC(\).)i(Otherwise,)e(this)h(function)f(r)o(eturns)g(false.) +573 1410 y(If)d(the)i(child)f(pr)o(ocess)f(was)h(suspended)g(by)g(a)g +(signal,)g Fy(status:stop-sig)13 b FC(r)o(eturns)573 +1510 y(the)35 b(signal)g(that)g(suspended)f(the)h(child.)68 +b(Otherwise,)38 b(this)e(function)f(r)o(eturns)573 1610 +y(false.)573 1740 y(If)19 b(the)g(child)h(pr)o(ocess)f(terminated)g +(abnormally)-9 b(,)19 b Fy(status:term-sig)13 b FC(r)o(eturns)19 +b(the)573 1840 y(signal)i(that)g(terminated)f(the)h(child.)26 +b(Otherwise,)21 b(this)g(function)h(r)o(eturns)e(false.)365 +2129 y Fw(3.5)99 b(Process)26 b(state)365 2364 y Fy(\(umask\))85 +b Fu(\000)-15 b(!)88 b FB(\002xnum)1633 b FC(pr)o(ocedur)o(e)365 +2463 y Fy(\(set-umask)40 b FB(perms)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(unde\002ned)1126 b FC(pr)o(ocedur)o(e)365 +2563 y Fy(\(with-umask*)39 b FB(perms)21 b(thunk)p Fy(\))86 +b Fu(\000)-14 b(!)87 b FB(value\(s\))20 b(of)h(thunk)581 +b FC(pr)o(ocedur)o(e)365 2662 y Fy(\(with-umask)39 b +FB(perms)21 b(.)g(body)p Fy(\))86 b Fu(\000)-15 b(!)88 +b FB(value\(s\))20 b(of)h(body)796 b FC(syntax)573 2785 +y(The)49 b(pr)o(ocess')g(curr)o(ent)f(umask)h(is)h(r)o(etrieved)d(with) +j Fy(umask)p FC(,)k(and)49 b(set)g(with)573 2884 y Fy(\(set-umask)39 +b FB(perms)p Fy(\))p FC(.)52 b(Calling)30 b Fy(with-umask*)25 +b FC(changes)30 b(the)g(umask)g(to)g FB(perms)573 2984 +y FC(for)25 b(the)g(duration)h(of)f(the)g(call)g(to)h +FB(thunk)o FC(.)39 b(If)25 b(the)h(pr)o(ogram)e(thr)o(ows)i(out)g(of)f +FB(thunk)573 3083 y FC(by)k(invoking)i(a)e(continuation,)k(the)d(umask) +g(is)g(r)o(eset)e(to)i(its)g(external)f(value.)51 b(If)573 +3183 y(the)22 b(pr)o(ogram)f(thr)o(ows)h(back)g(into)g +FB(thunk)f FC(by)h(calling)g(a)g(stor)o(ed)f(continuation,)i(the)573 +3283 y(umask)32 b(is)f(r)o(estor)o(ed)f(to)i(the)g FB(perms)f +FC(value.)57 b(The)31 b(special)g(form)h Fy(with-umask)27 +b FC(is)573 3382 y(equivalent)f(in)g(ef)o(fect)e(to)i(the)g(pr)o +(ocedur)o(e)e Fy(with-umask*)p FC(,)e(but)k(does)f(not)i(r)o(equir)o(e) +573 3482 y(the)21 b(pr)o(ogrammer)g(to)g(explicitly)h(wrap)f(a)g +Fy(\()p Fz(\025)38 b Fy(\(\))43 b(...\))20 b FC(ar)o(ound)g(the)i(body) +f(of)g(the)573 3582 y(code)f(to)h(be)g(executed.)365 +3766 y Fy(\(chdir)41 b FB([fname])p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(unde\002ned)1245 b FC(pr)o(ocedur)o(e)365 +3865 y Fy(\(cwd\))85 b Fu(\000)-14 b(!)87 b FB(string)1761 +b FC(pr)o(ocedur)o(e)365 3965 y Fy(\(with-cwd*)40 b FB(fname)20 +b(thunk)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(value\(s\))20 +b(of)h(thunk)668 b FC(pr)o(ocedur)o(e)365 4064 y Fy(\(with-cwd)40 +b FB(fname)21 b(.)f(body)p Fy(\))86 b Fu(\000)-14 b(!)87 +b FB(value\(s\))21 b(of)f(body)884 b FC(syntax)573 4201 +y(These)25 b(forms)g(manipulate)f(the)h(curr)o(ent)f(working)i(dir)o +(ectory)-9 b(.)37 b(The)25 b(cwd)f(can)h(be)573 4301 +y(changed)c(with)h Fy(chdir)d FC(\(although)j(in)g(most)g(cases,)f +Fy(with-cwd)d FC(is)k(pr)o(eferrable\).)i(If)573 4400 +y Fy(chdir)17 b FC(is)j(called)e(with)i(no)g(ar)o(guments,)f(it)g +(changes)h(the)f(cwd)g(to)h(the)f(user)6 b('s)20 b(home)573 +4500 y(dir)o(ectory)-9 b(.)31 b(The)23 b Fy(with-cwd*)c +FC(pr)o(ocedur)o(e)i(calls)i Fy(thunk)d FC(with)k(the)f(cwd)g(temporar) +o(-)573 4599 y(ily)30 b(set)f(to)h FB(fname)p FC(;)j(when)d +FB(thunk)e FC(r)o(eturns,)j(or)e(is)h(exited)f(in)g(a)g(non-local)h +(fashion)573 4699 y(\()p FB(e.g.)o FC(,)d(by)f(raising)h(an)f +(exception)g(or)h(by)f(invoking)i(a)d(continuation\),)k(the)d(cwd)g(is) +573 4799 y(r)o(eturned)d(to)i(its)g(original)g(value.)35 +b(The)25 b(special)f(form)g Fy(with-cwd)d FC(is)k(simply)g(syn-)573 +4898 y(tactic)20 b(sugar)h(for)f Fy(with-cwd*)p FC(.)1756 +5147 y(59)p eop +%%Page: 60 66 +60 65 bop 681 614 a Fy(\(pid\))85 b Fu(\000)-14 b(!)87 +b FB(\002xnum)1720 b FC(pr)o(ocedur)o(e)681 714 y Fy(\(parent-pid\))82 +b Fu(\000)-14 b(!)87 b FB(\002xnum)1415 b FC(pr)o(ocedur)o(e)681 +814 y Fy(\(process-group\))81 b Fu(\000)-15 b(!)88 b +FB(\002xnum)1284 b FC(pr)o(ocedur)o(e)681 913 y Fy(\(set-process-gro)o +(up)37 b FB([pr)o(oc/pid])18 b(pgrp)p Fy(\))85 b Fu(\000)-14 +b(!)87 b FB(unde\002ned)473 b FC(pr)o(ocedur)o(e)888 +1063 y Fy(\(pid\))25 b FC(and)i Fy(\(parent-pid\))22 +b FC(r)o(etrieve)j(the)i(pr)o(ocess)g(id)g(for)f(the)h(curr)o(ent)f(pr) +o(ocess)888 1162 y(and)18 b(its)g(par)o(ent.)24 b Fy(\(process-group\)) +12 b FC(r)o(eturns)17 b(the)h(pr)o(ocess)g(gr)o(oup)g(of)g(the)g(curr)o +(ent)888 1262 y(pr)o(ocess.)44 b(A)26 b(pr)o(ocess')h(pr)o(ocess-gr)o +(oup)f(can)g(be)h(set)g(with)g Fy(set-process-group)o +FC(;)888 1361 y(the)19 b(value)f FB(pr)o(oc/pid)e FC(speci\002es)i(the) +h(af)o(fected)c(pr)o(ocess.)25 b(It)18 b(may)g(be)g(either)h(a)e(pr)o +(ocess)888 1461 y(object)k(or)g(an)g(integer)g(pr)o(ocess)f(id,)g(and)h +(defaults)f(to)h(the)g(curr)o(ent)f(pr)o(ocess.)681 1676 +y Fy(\(set-priority)38 b FB(which)20 b(who)g(priority)p +Fy(\))86 b Fu(\000)-15 b(!)88 b FB(unde\002ned)559 b +FC(pr)o(ocedur)o(e)681 1776 y Fy(\(priority)40 b FB(which)19 +b(who)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(\002xnum)1100 +b FC(pr)o(ocedur)o(e)681 1876 y Fy(\(nice)41 b FB([pr)o(oc/pid)18 +b(delta])p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(unde\002ned)1035 +b FC(pr)o(ocedur)o(e)888 2025 y(These)21 b(pr)o(ocedur)o(es)e(set)i +(and)g(access)f(the)h(priority)g(of)g(pr)o(ocesses.)k(I)c(can't)g(r)o +(emem-)888 2125 y(ber)28 b(how)h Fy(set-priority)23 b +FC(and)k Fy(priority)e FC(work,)30 b(so)e(no)h(documentation,)h(and)888 +2224 y(besides,)21 b(they)g(ar)o(en't)e(implemented)i(yet,)g(anyway)-9 +b(.)681 2382 y Fy(\(user-login-name)o(\))81 b Fu(\000)-14 +b(!)87 b FB(string)1237 b FC(pr)o(ocedur)o(e)681 2481 +y Fy(\(user-uid\))83 b Fu(\000)-14 b(!)87 b FB(\002xnum)1502 +b FC(pr)o(ocedur)o(e)681 2581 y Fy(\(user-effective-)o(ui)o(d\))81 +b Fu(\000)-15 b(!)88 b FB(\002xnum)1066 b FC(pr)o(ocedur)o(e)681 +2680 y Fy(\(user-gid\))83 b Fu(\000)-14 b(!)87 b FB(\002xnum)1502 +b FC(pr)o(ocedur)o(e)681 2780 y Fy(\(user-effective-)o(gi)o(d\))81 +b Fu(\000)-15 b(!)88 b FB(\002xnum)1066 b FC(pr)o(ocedur)o(e)681 +2880 y Fy(\(user-supplement)o(ar)o(y-g)o(id)o(s\))81 +b Fu(\000)-15 b(!)88 b FB(\002xnum)20 b(list)722 b FC(pr)o(ocedur)o(e) +681 2979 y Fy(\(set-uid)40 b FB(uid)p Fy(\))87 b Fu(\000)-15 +b(!)87 b FB(unde\002ned)1305 b FC(pr)o(ocedur)o(e)681 +3079 y Fy(\(set-gid)40 b FB(gid)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(unde\002ned)1309 b FC(pr)o(ocedur)o(e)888 +3228 y(These)22 b(r)o(outines)h(get)f(and)f(set)h(the)h(ef)o(fective)d +(and)h(r)o(eal)g(user)h(and)g(gr)o(oup)g(ids.)29 b(The)888 +3328 y Fy(set-uid)g FC(and)j Fy(set-gid)d FC(r)o(outines)j(corr)o +(espond)g(to)g(the)i(P)t Ft(O)t(S)t(I)t(X)i Fy(setuid\(\))28 +b FC(and)888 3428 y Fy(setgid\(\))18 b FC(pr)o(ocedur)o(es.)681 +3643 y Fy(\(process-times\))81 b Fu(\000)-15 b(!)88 b +FB([\002xnum)19 b(\002xnum)h(\002xnum)g(\002xnum])440 +b FC(pr)o(ocedur)o(e)888 3792 y(Returns)22 b(four)e(values:)1071 +3892 y(user)h(CPU)f(time)h(in)g(clock-ticks)1071 3991 +y(system)g(CPU)g(time)g(in)g(clock-ticks)1071 4091 y(user)g(CPU)f(time) +h(of)g(all)f(descendant)g(pr)o(ocesses)1071 4191 y(system)h(CPU)g(time) +g(of)g(all)f(descendant)g(pr)o(ocesses)888 4290 y(Note)f(that)f(CPU)g +(time)h(clock)g(r)o(esolution)g(is)f(not)h(the)g(same)f(as)g(the)h(r)o +(eal-time)e(clock)888 4390 y(r)o(esolution)22 b(pr)o(ovided)d(by)i +Fy(time+ticks)p FC(.)h(That's)e(Unix.)681 4605 y Fy(\(cpu-ticks/sec\)) +81 b Fu(\000)-15 b(!)88 b FB(integer)1292 b FC(pr)o(ocedur)o(e)888 +4755 y(Returns)27 b(the)g(r)o(esolution)g(of)g(the)f(CPU)g(timer)h(in)g +(clock)g(ticks)g(per)f(second.)42 b(This)888 4854 y(can)21 +b(be)f(used)h(to)g(convert)g(the)g(times)g(r)o(eported)e(by)i +Fy(process-times)15 b FC(to)22 b(seconds.)2071 5147 y(60)p +eop +%%Page: 61 67 +61 66 bop 365 614 a Fw(3.6)99 b(User)25 b(and)f(group)h(database)g +(access)365 829 y FC(These)32 b(pr)o(ocedur)o(es)d(ar)o(e)h(used)i(to)g +(access)e(the)i(user)f(and)g(gr)o(oup)h(databases)e(\()p +FB(e.g.)n FC(,)k(the)365 928 y(ones)22 b(traditionally)f(stor)o(ed)f +(in)h Fy(/etc/passwd)16 b FC(and)k Fy(/etc/group)p FC(.\))365 +1078 y Fy(\(user-info)40 b FB(uid/name)p Fy(\))86 b Fu(\000)-15 +b(!)88 b FB(r)o(ecord)1135 b FC(pr)o(ocedur)o(e)573 1219 +y(Return)24 b(a)e Fy(user-info)e FC(r)o(ecor)o(d)h(giving)j(the)g(r)o +(ecor)o(ded)d(information)j(for)f(a)g(partic-)573 1319 +y(ular)d(user:)756 1485 y Fy(\(define-record)37 b(user-info)843 +1585 y(name)42 b(uid)g(gid)g(home-dir)f(shell\))573 1751 +y FC(The)21 b FB(uid/name)f FC(ar)o(gument)g(is)h(either)g(an)f +(integer)h(uid)g(or)g(a)f(string)h(user)o(-name.)365 +1942 y Fy(\(->uid)41 b FB(uid/name)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(\002xnum)1275 b FC(pr)o(ocedur)o(e)365 2042 +y Fy(\(->username)39 b FB(uid/name)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(string)1097 b FC(pr)o(ocedur)o(e)573 2183 +y(These)19 b(two)g(pr)o(ocedur)o(es)f(coer)o(ce)f(integer)i(uid's)h +(and)e(user)h(names)g(to)g(a)g(particular)573 2283 y(form.)365 +2474 y Fy(\(group-info)39 b FB(gid/name)p Fy(\))86 b +Fu(\000)-15 b(!)88 b FB(r)o(ecord)1096 b FC(pr)o(ocedur)o(e)573 +2615 y(Return)19 b(a)g Fy(group-info)14 b FC(r)o(ecor)o(d)j(giving)j +(the)f(r)o(ecor)o(ded)e(information)j(for)e(a)h(partic-)573 +2715 y(ular)h(gr)o(oup:)756 2881 y Fy(\(define-record)37 +b(group-info)843 2981 y(name)42 b(gid)g(members\))573 +3147 y FC(The)21 b FB(gid/name)e FC(ar)o(gument)h(is)h(either)g(an)f +(integer)h(gid)g(or)g(a)f(string)i(gr)o(oup-name.)365 +3442 y Fw(3.7)99 b(Accessing)26 b(command-line)e(arguments)365 +3681 y Fy(command-line-argu)o(me)o(nts)1564 b FB(string)21 +b FC(list)365 3781 y Fy(\(command-line\))82 b Fu(\000)-15 +b(!)88 b FB(string)20 b(list)1242 b FC(pr)o(ocedur)o(e)573 +3905 y(The)44 b(list)h(of)g(strings)g Fy(command-line-argu)o(men)o(ts) +38 b FC(contains)45 b(the)g(ar)o(guments)573 4005 y(passed)16 +b(to)h(the)g(scsh)g(pr)o(ocess)f(on)i(the)f(command)g(line.)24 +b(Calling)17 b Fy(\(command-line\))573 4104 y FC(r)o(eturns)h(the)h +(complete)g Fy(argv)e FC(string)j(list,)f(including)h(the)f(pr)o +(ogram.)24 b(So)19 b(if)f(we)h(r)o(un)573 4204 y(a)h(scsh)h(pr)o(ogram) +756 4343 y Fy(/usr/shivers/bi)o(n/)o(myl)o(s)37 b(-CF)43 +b(src)573 4482 y FC(then)21 b Fy(command-line-arg)o(ume)o(nt)o(s)15 +b FC(is)756 4621 y Fy(\("-CF")41 b("src"\))573 4759 y +FC(and)20 b Fy(\(command-line\))15 b FC(r)o(eturns)756 +4898 y Fy(\("/usr/shivers/)o(bi)o(n/m)o(yl)o(s")37 b("-CF")42 +b("src"\))1756 5147 y FC(61)p eop +%%Page: 62 68 +62 67 bop 888 614 a Fy(command-line)32 b FC(r)o(eturns)k(a)g(fr)o(esh)g +(list)h(each)f(time)h(it)g(is)g(called.)72 b(In)37 b(this)h(way)-9 +b(,)888 714 y(the)37 b(pr)o(ogrammer)f(can)g(get)h(a)f(fr)o(esh)g(copy) +g(of)h(the)g(original)g(ar)o(gument)f(list)h(if)888 814 +y Fy(command-line-argu)o(me)o(nts)14 b FC(has)21 b(been)f(modi\002ed)h +(or)g(is)g(lexically)g(shadowed.)681 1003 y Fy(\(arg)42 +b FB(ar)o(glist)20 b(n)h([default])p Fy(\))85 b Fu(\000)-14 +b(!)87 b FB(string)1128 b FC(pr)o(ocedur)o(e)681 1102 +y Fy(\(arg*)41 b FB(ar)o(glist)20 b(n)h([default-thunk])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(string)858 b FC(pr)o(ocedur)o(e)681 +1202 y Fy(\(argv)41 b FB(n)21 b([default])p Fy(\))86 +b Fu(\000)-14 b(!)87 b FB(string)1320 b FC(pr)o(ocedur)o(e)888 +1342 y(These)17 b(pr)o(ocedur)o(es)e(ar)o(e)g(useful)h(for)g(accessing) +h(ar)o(guments)f(fr)o(om)g(ar)o(gument)h(lists.)888 1442 +y Fy(arg)28 b FC(r)o(eturns)g(the)h Fz(n)1535 1412 y +Fv(th)1630 1442 y FC(element)g(of)f FB(ar)o(glist)p FC(.)49 +b(The)28 b(index)h(is)g(1-based.)47 b(If)29 b FB(n)f +FC(is)h(too)888 1541 y(lar)o(ge,)20 b FB(default)g FC(is)h(r)o +(eturned;)f(if)g(no)i FB(default)o FC(,)f(then)g(an)f(err)o(or)g(is)h +(signaled.)888 1674 y Fy(arg*)j FC(is)h(similar)-6 b(,)27 +b(except)d(that)h(the)h FB(default-thunk)e FC(is)h(called)g(to)g +(generate)g(the)g(de-)888 1773 y(fault)c(value.)888 1905 +y Fy(\(argv)42 b FB(n)p Fy(\))26 b FC(is)h(simply)g Fy(\(arg)42 +b(\(command-line\))c(\(+)43 b FB(n)h Fy(1\)\))p FC(.)d(The)26 +b(+1)h(of)o(fset)e(en-)888 2005 y(sur)o(es)c(that)f(the)h(two)h(forms) +1071 2170 y Fy(\(arg)42 b(command-line-arg)o(um)o(ent)o(s)37 +b FB(n)q Fy(\))1071 2270 y(\(argv)42 b FB(n)p Fy(\))888 +2435 y FC(r)o(eturn)23 b(the)g(same)g(ar)o(gument)f(\(assuming)i(the)f +(user)g(has)g(not)h(r)o(ebound)f(or)g(modi-)888 2534 +y(\002ed)e Fy(command-line-arg)o(um)o(ent)o(s)p FC(\))o(.)888 +2666 y(Example:)1071 2831 y Fy(\(if)42 b(\(null?)f(command-line-argu)o +(men)o(ts)o(\))1245 2931 y(\(&)i(\(xterm)e(-n)i(,host)e(-title)h(,host) +1681 3031 y(-name)g(,\(string-append)37 b("xterm_")j(host\)\)\))1245 +3130 y(\(let*)i(\(\(progname)d(\(file-name-nondir)o(ec)o(tor)o(y)e +(\(argv)42 b(1\)\)\))1550 3230 y(\(title)g(\(string-append)37 +b(host)42 b(":")h(progname\)\)\))1333 3329 y(\(&)f(\(xterm)f(-n)217 +b(,title)1768 3429 y(-title)41 b(,title)1768 3529 y(-e)217 +b(,@command-line-ar)o(gum)o(en)o(ts\))o(\)\))o(\))888 +3694 y FC(A)23 b(subtlety:)31 b(when)24 b(the)f(scsh)h(interpr)o(eter)d +(is)j(used)f(to)g(execute)g(a)f(scsh)i(pr)o(ogram,)888 +3793 y(the)d(pr)o(ogram)g(name)f(r)o(eported)g(in)h(the)g(head)f(of)h +(the)g Fy(\(command-line\))15 b FC(list)22 b(is)f(the)888 +3893 y(scsh)26 b(pr)o(ogram,)f FB(not)f FC(the)h(interpr)o(eter)-6 +b(.)37 b(For)25 b(example,)g(if)g(we)g(have)f(a)h(shell)g(script)888 +3992 y(in)d(\002le)e Fy(fullecho)p FC(:)1071 4157 y Fy +(#!/usr/local/bin)o(/sc)o(sh)37 b(-s)1071 4257 y(!#)1071 +4357 y(\(for-each)j(\()p Fz(\025)f Fy(\(arg\))i(\(display)f(arg\))i +(\(display)f(")i("\)\))1507 4456 y(\(command-line\)\))888 +4621 y FC(and)21 b(we)f(r)o(un)i(the)f(pr)o(ogram)1071 +4760 y Fy(fullecho)40 b(hello)i(world)888 4898 y FC(the)21 +b(pr)o(ogram)f(will)i(print)f(out)2071 5147 y(62)p eop +%%Page: 63 69 +63 68 bop 756 614 a Fy(fullecho)40 b(hello)h(world)573 +767 y FC(not)756 919 y Fy(/usr/local/bin/)o(sc)o(sh)c(-s)43 +b(fullecho)d(hello)i(world)573 1110 y FC(This)37 b(ar)o(gument)f(line)h +(pr)o(ocessing)f(ensur)o(es)g(that)h(if)f(a)g(scsh)h(pr)o(ogram)f(is)h +(sub-)573 1210 y(sequently)29 b(compiled)g(into)g(a)g(standalone)f +(executable)f(or)i(byte-compiled)f(to)h(a)573 1309 y(heap-image)c +(executable)g(by)h(the)h(Scheme)f(48)f(virtual)h(machine,)h(its)g +(semantics)573 1409 y(will)21 b(be)g(unchanged\227the)g(ar)o(glist)f +(pr)o(ocessing)h(is)g(invariant.)k(In)c(ef)o(fect,)e(the)756 +1561 y Fy(/usr/local/bin/)o(sc)o(sh)37 b(-s)573 1713 +y FC(is)24 b(not)g(part)e(of)h(the)h(pr)o(ogram;)f(it's)h(a)f +(speci\002cation)h(for)f(the)g(machine)h(to)f(execute)573 +1813 y(the)e(pr)o(ogram)f(on,)h(so)g(it)g(is)g(not)g(pr)o(operly)f +(part)g(of)h(the)g(pr)o(ogram's)f(ar)o(gument)g(list.)365 +2132 y Fw(3.8)99 b(System)25 b(parameters)365 2380 y +Fy(\(system-name\))82 b Fu(\000)-14 b(!)87 b FB(string)1412 +b FC(pr)o(ocedur)o(e)573 2507 y(Returns)24 b(the)g(name)f(of)h(the)g +(host)g(on)h(which)f(we)g(ar)o(e)e(executing.)34 b(This)24 +b(may)g(be)f(a)573 2607 y(local)d(name,)f(such)h(as)g(\223solar)-6 +b(,\224)18 b(as)i(opposed)g(to)g(a)f(fully-quali\002ed)h(domain)g(name) +573 2706 y(such)h(as)g(\223solar)-6 b(.csie.ntu.edu.tw)e(.\224)365 +3026 y Fw(3.9)99 b(Signal)26 b(system)365 3251 y FC(Signal)g(numbers)h +(ar)o(e)e(bound)i(to)f(the)h(variables)e Fy(signal/hup)p +FC(,)e Fy(signal/int)p FC(,)h(.)12 b(.)g(.)g(.)42 b(See)365 +3351 y(tables)21 b(3.9)e(and)i(3.3)e(for)i(the)f(full)h(list.)365 +3506 y Fy(\(signal-process)38 b FB(pr)o(oc)19 b(sig)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(unde\002ned)850 b +FC(pr)o(ocedur)o(e)365 3606 y Fy(\(signal-process-g)o(ro)o(up)37 +b FB(pr)o(grp)20 b(sig)p Fy(\))86 b Fu(\000)-14 b(!)87 +b FB(unde\002ned)544 b FC(pr)o(ocedur)o(e)573 3753 y(These)23 +b(two)h(pr)o(ocedur)o(es)e(send)h(signals)h(to)g(a)f(speci\002c)g(pr)o +(ocess,)h(and)f(all)g(the)g(pr)o(o-)573 3852 y(cesses)g(in)i(a)e +(speci\002c)g(pr)o(ocess)h(gr)o(oup,)f(r)o(espectively)-9 +b(.)33 b(The)24 b FB(pr)o(oc)e FC(and)i FB(pr)o(grp)e +FC(ar)o(gu-)573 3952 y(ments)f(ar)o(e)f(either)g(pr)o(ocesses)h(or)f +(integer)h(pr)o(ocess)f(ids.)365 4160 y Fy(\(itimer)41 +b FB(???)p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(unde\002ned)1335 +b FC(pr)o(ocedur)o(e)365 4260 y Fy(\(pause-until-inte)o(rr)o(upt)o(\)) +81 b Fu(\000)-14 b(!)87 b FB(unde\002ned)849 b FC(pr)o(ocedur)o(e)365 +4415 y Fy(\(sleep)41 b FB(secs)p Fy(\))88 b Fu(\000)-14 +b(!)87 b FB(unde\002ned)1372 b FC(pr)o(ocedur)o(e)365 +4515 y Fy(\(sleep-until)39 b FB(time)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(unde\002ned)1094 b FC(pr)o(ocedur)o(e)573 +4662 y(The)29 b Fy(sleep)f FC(pr)o(ocedur)o(e)g(causes)h(the)h(pr)o +(ocess)f(to)h(sleep)f(for)h FB(secs)g FC(seconds.)53 +b(The)573 4761 y Fy(sleep-until)26 b FC(pr)o(ocedur)o(e)j(causes)i(the) +g(pr)o(ocess)g(to)g(sleep)g(until)h FB(time)f FC(\(see)f(sec-)573 +4861 y(tion)21 b(3.10\).)1756 5147 y(63)p eop +%%Page: 64 70 +64 69 bop 910 535 2407 4 v 960 604 a FC(Interr)o(upt)854 +b(Unix)21 b(signal)246 b(OS)21 b(V)-8 b(ariant)p 910 +638 V 910 654 V 960 724 a Fy(interrupt/alrm)1576 694 +y Fo(a)2149 724 y Fy(signal/alrm)184 b FC(P)t Ft(O)t(S)t(I)t(X)960 +824 y Fy(interrupt/int)1532 794 y Fo(b)2149 824 y Fy(signal/int)228 +b FC(P)t Ft(O)t(S)t(I)t(X)960 924 y Fy(interrupt/memor)o(y-s)o(ho)o +(rta)o(ge)93 b FC(N/A)960 1024 y Fy(interrupt/chld)573 +b(signal/chld)184 b FC(P)t Ft(O)t(S)t(I)t(X)960 1123 +y Fy(interrupt/cont)573 b(signal/cont)184 b FC(P)t Ft(O)t(S)t(I)t(X)960 +1223 y Fy(interrupt/hup)617 b(signal/hup)228 b FC(P)t +Ft(O)t(S)t(I)t(X)960 1322 y Fy(interrupt/quit)573 b(signal/quit)184 +b FC(P)t Ft(O)t(S)t(I)t(X)960 1422 y Fy(interrupt/term)573 +b(signal/term)184 b FC(P)t Ft(O)t(S)t(I)t(X)960 1522 +y Fy(interrupt/tstp)573 b(signal/tstp)184 b FC(P)t Ft(O)t(S)t(I)t(X)960 +1621 y Fy(interrupt/usr1)573 b(signal/usr1)184 b FC(P)t +Ft(O)t(S)t(I)t(X)960 1721 y Fy(interrupt/usr2)573 b(signal/usr2)184 +b FC(P)t Ft(O)t(S)t(I)t(X)960 1920 y Fy(interrupt/info)573 +b(signal/info)182 b FC(BSD)21 b(only)960 2020 y Fy(interrupt/io)661 +b(signal/io)270 b FC(BSD)21 b(+)g(SVR4)960 2119 y Fy(interrupt/poll)573 +b(signal/poll)182 b FC(SVR4)20 b(only)960 2219 y Fy(interrupt/prof)573 +b(signal/prof)182 b FC(BSD)21 b(+)g(SVR4)960 2319 y Fy(interrupt/pwr) +617 b(signal/pwr)226 b FC(SVR4)20 b(only)960 2418 y Fy(interrupt/urg) +617 b(signal/urg)226 b FC(BSD)21 b(+)g(SVR4)960 2518 +y Fy(interrupt/vtalr)o(m)486 b(signal/vtalrm)94 b FC(BSD)21 +b(+)g(SVR4)960 2618 y Fy(interrupt/winch)529 b(signal/winch)138 +b FC(BSD)21 b(+)g(SVR4)960 2717 y Fy(interrupt/xcpu)573 +b(signal/xcpu)182 b FC(BSD)21 b(+)g(SVR4)960 2817 y Fy(interrupt/xfsz) +573 b(signal/xfsz)182 b FC(BSD)21 b(+)g(SVR4)681 3082 +y(T)-8 b(able)17 b(3.2:)23 b(Scheme)18 b(48)f(virtual-machine)h(interr) +o(upts)g(and)g(r)o(elated)e(Unix)i(signals.)25 b(Only)681 +3181 y(the)20 b(P)t Ft(O)t(S)t(I)t(X)i FC(signals)d(ar)o(e)e +(guaranteed)g(to)h(be)g(de\002ned;)h(however)-6 b(,)18 +b(your)h(implementation)681 3281 y(and)h(OS)h(may)f(de\002ne)h(other)g +(signals)g(and)g(interr)o(upts)g(not)g(listed)g(her)o(e.)p +681 3357 1146 4 v 763 3411 a Ff(a)800 3434 y Ft(Also)c(bound)f(to)h +(Scheme)f(48)h(interr)o(upt)f Fj(interrupt/alarm)p Ft(.)769 +3492 y Ff(b)800 3516 y Ft(Also)h(bound)f(to)h(Scheme)f(48)h(interr)o +(upt)f Fj(interrupt/keyboard)p Ft(.)681 3818 y FA(Interrupt)j(handlers) +681 4044 y FC(Scsh)27 b(interr)o(upt)g(handlers)g(ar)o(e)e(complicated) +i(by)g(the)g(fact)f(that)h(scsh)g(is)h(implemented)681 +4144 y(on)c(top)g(of)f(the)h(Scheme)f(48)f(virtual)i(machine,)g(which)g +(has)g(its)f(own)i(interr)o(upt)f(system,)681 4243 y(independent)i(of)f +(the)i(Unix)e(signal)i(system.)42 b(This)26 b(means)g(that)g(Unix)g +(signals)g(ar)o(e)f(de-)681 4343 y(liver)o(ed)h(in)j(two)f(stages:)39 +b(\002rst,)30 b(Unix)e(delivers)f(the)h(signal)g(to)g(the)g(Scheme)g +(48)e(virtual)681 4442 y(machine,)21 b(then)g(the)g(Scheme)f(48)g +(virtual)g(machine)h(delivers)g(the)g(signal)g(to)g(the)g(execut-)681 +4542 y(ing)c(Scheme)e(pr)o(ogram)h(as)g(a)g(Scheme)g(48)f(interr)o +(upt.)24 b(This)17 b(ensur)o(es)f(that)g(signal)h(delivery)681 +4642 y(happens)g(between)h(two)h(vm)f(instr)o(uctions,)i(keeping)e +(individual)f(instr)o(uctions)j(atomic.)805 4799 y(The)28 +b(Scheme)g(48)e(machine)j(has)e(its)i(own)f(set)g(of)g(interr)o(upts,)i +(which)f(includes)f(the)681 4898 y(asynchr)o(onous)23 +b(Unix)g(signals)g(\(table)e(3.9\).)61 b(Note)22 b(that)h(scsh)g(does)g +FB(not)f FC(support)h(signal)2071 5147 y(64)p eop +%%Page: 65 71 +65 70 bop 943 1542 1709 4 v 993 1612 a FC(Unix)21 b(signal)159 +b(T)-7 b(ype)399 b(OS)20 b(V)-8 b(ariant)p 943 1645 V +943 1662 V 993 1731 a Fy(signal/stop)95 b FC(Uncatchable)125 +b(P)t Ft(O)t(S)t(I)t(X)993 1831 y Fy(signal/kill)95 b +FC(Uncatchable)125 b(P)t Ft(O)t(S)t(I)t(X)993 2030 y +Fy(signal/abrt)95 b FC(Synchr)o(onous)103 b(P)t Ft(O)t(S)t(I)t(X)993 +2130 y Fy(signal/fpe)139 b FC(Synchr)o(onous)103 b(P)t +Ft(O)t(S)t(I)t(X)993 2230 y Fy(signal/ill)139 b FC(Synchr)o(onous)103 +b(P)t Ft(O)t(S)t(I)t(X)993 2329 y Fy(signal/pipe)95 b +FC(Synchr)o(onous)103 b(P)t Ft(O)t(S)t(I)t(X)993 2429 +y Fy(signal/segv)95 b FC(Synchr)o(onous)103 b(P)t Ft(O)t(S)t(I)t(X)993 +2528 y Fy(signal/ttin)95 b FC(Synchr)o(onous)103 b(P)t +Ft(O)t(S)t(I)t(X)993 2628 y Fy(signal/ttou)95 b FC(Synchr)o(onous)103 +b(P)t Ft(O)t(S)t(I)t(X)993 2827 y Fy(signal/bus)139 b +FC(Synchr)o(onous)101 b(BSD)20 b(+)h(SVR4)993 2927 y +Fy(signal/emt)139 b FC(Synchr)o(onous)101 b(BSD)20 b(+)h(SVR4)993 +3027 y Fy(signal/iot)139 b FC(Synchr)o(onous)101 b(BSD)20 +b(+)h(SVR4)993 3126 y Fy(signal/sys)139 b FC(Synchr)o(onous)101 +b(BSD)20 b(+)h(SVR4)993 3226 y Fy(signal/trap)95 b FC(Synchr)o(onous) +101 b(BSD)20 b(+)h(SVR4)365 3491 y(T)-8 b(able)19 b(3.3:)k(Uncatchable) +17 b(and)h(synchr)o(onous)i(Unix)f(signals.)25 b(While)20 +b(these)e(signals)i(may)365 3590 y(be)30 b(sent)g(with)h +Fy(signal-process)24 b FC(or)31 b Fy(signal-process-)o(gro)o(up)o +FC(,)26 b(ther)o(e)k(ar)o(e)e(no)j(corr)o(e-)365 3690 +y(sponding)21 b(scsh)f(interr)o(upt)g(handlers.)25 b(Only)20 +b(the)i(P)t Ft(O)t(S)t(I)t(X)h FC(signals)d(ar)o(e)f(guaranteed)f(to)i +(be)365 3789 y(de\002ned;)28 b(however)-6 b(,)26 b(your)g +(implementation)g(and)g(OS)f(may)g(de\002ne)h(other)g(signals)g(not)365 +3889 y(listed)21 b(her)o(e.)1756 5147 y(65)p eop +%%Page: 66 72 +66 71 bop 681 614 a FC(handlers)20 b(for)h(\223synchr)o(onous\224)h +(Unix)e(signals,)i(such)f(as)g Fy(signal/ill)c FC(or)k +Fy(signal/pipe)681 714 y FC(\(see)g(table)f(3.3\).)26 +b(Synchr)o(onous)c(occurr)o(ences)f(of)g(these)g(signals)h(ar)o(e)e +(better)h(handled)g(by)681 814 y(raising)k(a)g(Scheme)g(exception.)39 +b(W)-8 b(e)25 b(r)o(ecommend)g(you)h(avoid)e(using)j(signal)e(handlers) +681 913 y(unless)19 b(you)h(absolutely)f(have)f(to;)h(we)g(intend)g(to) +g(pr)o(ovide)f(a)g(better)-6 b(,)19 b(higher)o(-level)f(inter)o(-)681 +1013 y(face)h(to)i(Unix)g(signals)h(after)d(scsh)i(has)g(been)g(ported) +f(to)h(a)g(multi-thr)o(eaded)e(platform.)681 1167 y Fy +(\(signal->interru)o(pt)37 b FB(integer)p Fy(\))87 b +Fu(\000)-14 b(!)87 b FB(integer)839 b FC(pr)o(ocedur)o(e)888 +1314 y(The)27 b(pr)o(ogrammer)f(maps)h(fr)o(om)f(Unix)g(signals)i(to)f +(Scheme)f(48)g(interr)o(upts)h(with)888 1413 y(the)22 +b Fy(signal->interrupt)15 b FC(pr)o(ocedur)o(e.)27 b(If)21 +b(the)h(signal)g(does)g(not)h(have)e(a)h(de\002ned)888 +1513 y(Scheme)f(48)e(interr)o(upt,)i(an)g(errr)o(or)e(is)i(signaled.) +681 1819 y Fy(\(interrupt-set)38 b FB(integer)1570 1831 +y Fv(1)1628 1819 y FB(.)12 b(.)g(.)g(integer)1962 1831 +y Fo(n)2008 1819 y Fy(\))87 b Fu(\000)-15 b(!)88 b FB(integer)575 +b FC(pr)o(ocedur)o(e)888 1966 y(This)25 b(pr)o(ocedur)o(e)d(builds)i +(interr)o(upt)g(sets)g(fr)o(om)f(its)h(interr)o(upt)g(ar)o(guments.)35 +b(A)23 b(set)888 2065 y(is)h(r)o(epr)o(esented)d(as)h(an)h(integer)g +(using)h(a)f(two's-complement)h(r)o(epr)o(esentation)e(of)888 +2165 y(the)f(bit)g(set.)681 2471 y Fy(\(enabled-interru)o(pt)o(s\))81 +b Fu(\000)-15 b(!)88 b FB(interrupt-set)880 b FC(pr)o(ocedur)o(e)681 +2571 y Fy(\(set-enabled-int)o(er)o(rup)o(ts)37 b FB(interrupt-set)p +Fy(\))87 b Fu(\000)-15 b(!)88 b FB(interrupt-set)233 +b FC(pr)o(ocedur)o(e)888 2717 y(Get)21 b(and)f(set)g(the)g(value)g(of)g +(the)h(enabled-interr)o(upt)e(set.)26 b(Only)21 b(interr)o(upts)g(in)f +(this)888 2816 y(set)f(have)f(their)g(handlers)g(called)g(when)h +(deliver)o(ed.)k(When)18 b(a)g(disabled)g(interr)o(upt)888 +2916 y(is)h(deliver)o(ed)e(to)i(the)g(Scheme)f(48)g(machine,)h(it)g(is) +g(held)g(pending)g(until)g(it)g(becomes)888 3016 y(enabled,)h(at)g +(which)i(time)f(its)g(handler)g(is)g(invoked.)888 3154 +y(Interr)o(upt)33 b(sets)g(ar)o(e)f(r)o(epr)o(esented)f(as)h(integer)h +(bit)g(sets)g(\(constr)o(ucted)g(with)h(the)888 3253 +y Fy(interrupt-set)23 b FC(function\).)49 b(The)29 b +Fy(set-enabled-int)o(err)o(up)o(ts)22 b FC(pr)o(ocedur)o(e)k(r)o(e-)888 +3353 y(turns)c(the)e(pr)o(evious)h(value)f(of)h(the)g(enabled-interr)o +(upt)e(set.)681 3560 y Fy(\(with-enabled-in)o(te)o(rru)o(pt)o(s)37 +b FB(interrupt-set)17 b(.)g(body)p Fy(\))53 b Fu(\000)-15 +b(!)54 b FB(value\(s\))17 b(of)f(body)87 b FC(syntax)681 +3659 y Fy(\(with-enabled-in)o(te)o(rru)o(pt)o(s*)37 b +FB(interrupt-set)16 b(thunk)p Fy(\))43 b Fu(\000)-15 +b(!)44 b FB(value\(s\))15 b(of)h(thunk)87 b FC(pr)o(ocedur)o(e)888 +3805 y(Run)30 b(code)e(with)i(a)e(given)h(set)f(of)h(interr)o(upts)g +(enabled.)48 b(Note)29 b(that)g(\223enabling\224)888 +3905 y(an)21 b(interr)o(upt)h(means)f(enabling)h(delivery)e(fr)o(om)h +(the)g(Scheme)g(48)f(vm)i(to)f(the)g(scsh)888 4005 y(pr)o(ogram.)62 +b(Using)34 b(the)f(Scheme)g(48)f(interr)o(upt)i(system)g(is)f(fairly)g +(lightweight,)888 4104 y(and)25 b(does)g(not)h(involve)f(actually)g +(making)g(a)g(system)h(call.)38 b(Note)25 b(that)g(enabling)888 +4204 y(an)d(interr)o(upt)h(means)f(that)g(the)g(assigned)g(interr)o +(upt)h(handler)f(is)g(allowed)g(to)h(r)o(un)888 4304 +y(when)f(the)f(interr)o(upt)g(is)g(deliver)o(ed.)j(Interr)o(upts)d(not) +h(enabled)e(ar)o(e)f(held)i(pending)888 4403 y(when)h(deliver)o(ed.)888 +4541 y(Interr)o(upt)33 b(sets)g(ar)o(e)f(r)o(epr)o(esented)f(as)h +(integer)h(bit)g(sets)g(\(constr)o(ucted)g(with)h(the)888 +4641 y Fy(interrupt-set)16 b FC(function\).)681 4847 +y Fy(\(set-interrupt-h)o(an)o(dle)o(r)37 b FB(interrupt)21 +b(handler)p Fy(\))87 b Fu(\000)-15 b(!)88 b FB(old-handler)167 +b FC(pr)o(ocedur)o(e)2071 5147 y(66)p eop +%%Page: 67 73 +67 72 bop 573 614 a FC(Assigns)28 b(a)g(handler)f(for)g(a)g(given)h +(interr)o(upt,)i(and)d(r)o(eturns)g(the)h(interr)o(upt's)g(old)573 +714 y(handler)-6 b(.)25 b(The)20 b FB(handler)g FC(ar)o(gument)g(is)h +Fy(#f)e FC(\(ignor)o(e\),)h Fy(#t)g FC(\(default\),)e(or)j(a)f(pr)o +(ocedur)o(e)573 814 y(taking)28 b(an)g(integer)f(ar)o(gument;)k(the)d +(r)o(eturn)f(value)g(follows)i(the)f(same)f(conven-)573 +913 y(tions.)h(Note)22 b(that)f(the)h FB(interrupt)g +FC(ar)o(gument)e(is)i(an)g(interr)o(upt)f(value,)g(not)h(a)f(signal)573 +1013 y(value.)35 b(An)25 b(interr)o(upt)f(is)h(deliver)o(ed)d(to)j(the) +f(Scheme)g(48)g(machine)g(by)g(\(1\))f(block-)573 1112 +y(ing)30 b(all)f(interr)o(upts,)j(and)d(\(2\))f(applying)i(the)f +(handler)g(pr)o(ocedur)o(e)f(to)i(the)f(set)h(of)573 +1212 y(interr)o(upts)f(that)f(wer)o(e)f(enabled)h(prior)g(to)h(the)f +(interr)o(upt)h(delivery)-9 b(.)47 b(If)28 b(the)g(pr)o(o-)573 +1312 y(cedur)o(e)23 b(r)o(eturns)h(normally)i(\()p FB(i.e.)o +FC(,)g(it)f(doesn't)g(thr)o(ow)g(to)h(a)e(continuation\),)j(the)e(set) +573 1411 y(of)h(enabled)g(interr)o(upts)h(will)h(be)e(r)o(eturned)f(to) +i(its)g(pr)o(evious)g(value.)42 b(\(T)-8 b(o)27 b(r)o(estor)o(e)573 +1511 y(the)19 b(enabled-interr)o(upt)f(set)h(befor)o(e)e(thr)o(owing)j +(out)g(of)e(an)h(interr)o(upt)g(handler)-6 b(,)19 b(see)573 +1611 y Fy(set-enabled-inte)o(rr)o(upt)o(s)p FC(\))573 +1740 y Fu(f)p FC(Note)29 b(If)f(you)i(set)f(a)g(handler)f(for)h(the)g +Fy(interrupt/chld)24 b FC(interr)o(upt,)31 b(you)f(may)573 +1840 y(br)o(eak)f(scsh's)j(autor)o(eaping)e(pr)o(ocess)g(machinery)-9 +b(.)55 b(See)30 b(the)h(discussion)h(of)e(au-)573 1940 +y(tor)o(eaping)20 b(in)h(section)h(3.4.1.)p Fu(g)365 +2221 y Fy(\(interrupt-handle)o(r)37 b FB(interrupt)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(handler)747 b FC(pr)o(ocedur)o(e)573 +2356 y(Return)28 b(the)g(handler)f(for)h(a)f(given)h(interr)o(upt.)46 +b(Note)28 b(that)g(the)g(ar)o(gument)f(is)h(an)573 2455 +y(interr)o(upt)i(value,)i(not)f(a)f(signal)g(value.)53 +b(A)30 b(handler)g(is)g(either)g Fy(#f)g FC(\(ignor)o(e\),)h +Fy(#t)573 2555 y FC(\(default\),)19 b(or)h(a)h(pr)o(ocedur)o(e)d +(taking)k(an)e(integer)h(ar)o(gument.)365 2967 y Fw(3.10)99 +b(T)-5 b(ime)365 3181 y FC(Scsh's)18 b(time)f(system)h(is)f(fairly)g +(sophisticated,)h(particularly)e(with)i(r)o(espect)e(to)i(its)f(car)o +(eful)365 3281 y(tr)o(eatment)h(of)g(time)g(zones.)25 +b(However)-6 b(,)18 b(casual)g(users)g(shouldn't)i(be)e(intimidated;)h +(all)f(of)365 3381 y(the)25 b(complexity)g(is)g(optional,)h(and)e +(defaulting)g(all)h(the)f(optional)i(ar)o(guments)e(r)o(educes)365 +3480 y(the)d(system)h(to)f(a)f(simple)h(interface.)573 +3637 y Fl(Remark:)66 b Fk(This)22 b(time)g(package)g(does)g(not)h(curr) +o(ently)e(work)h(with)h(NeXTSTEP)-10 b(,)22 b(as)573 +3728 y(NeXTSTEP)17 b(does)f(not)i(pr)o(ovide)e(a)k(P)t +Fg(O)t(S)t(I)t(X)r Fk(-compliant)d(time)g(library)g(that)i(will)e(even) +573 3820 y(link.)365 4068 y FA(3.10.1)81 b(T)-9 b(erminology)365 +4251 y FC(\223UTC\224)17 b(and)g(\223UCT\224)g(stand)g(for)h +(\223universal)g(coor)o(dinated)f(time,\224)h(which)h(is)f(the)g(of)o +(\002cial)365 4350 y(name)j(for)f(what)h(is)g(colloquially)i(r)o(eferr) +o(ed)18 b(to)j(as)f(\223Gr)o(eenwich)h(Mean)e(T)-5 b(ime.\224)492 +4475 y(P)t Ft(O)t(S)t(I)t(X)28 b FC(allows)d(a)g(single)g(time)g(zone)g +(to)g(specify)f FB(two)g FC(dif)o(fer)o(ent)f(of)o(fsets)h(fr)o(om)g +(UTC:)365 4575 y(one)33 b(standar)o(d)d(one,)35 b(and)c(one)h(for)g +(\223summer)g(time.\224)59 b(Summer)31 b(time)i(is)f(fr)o(equently)365 +4674 y(some)22 b(sort)f(of)g(daylight)g(savings)g(time.)490 +4799 y(The)32 b(scsh)g(time)g(package)f(consistently)i(uses)f(this)h +(terminology:)49 b(we)31 b(never)h(say)365 4898 y(\223gmt\224)21 +b(or)f(\223dst;\224)g(we)h(always)f(say)h(\223utc\224)f(and)g +(\223summer)h(time.\224)1756 5147 y(67)p eop +%%Page: 68 74 +68 73 bop 681 614 a FA(3.10.2)80 b(Basic)20 b(data)g(types)681 +810 y FC(W)-8 b(e)21 b(have)f(two)h(types:)26 b FB(time)20 +b FC(and)h FB(date)p FC(.)805 945 y(A)j FB(time)g FC(speci\002es)h(an)f +(instant)h(in)g(the)g(history)g(of)g(the)f(universe.)37 +b(It)24 b(is)h(location)g(and)681 1044 y(time-zone)f(independent.)1560 +1014 y Fv(3)1635 1044 y FC(A)g(time)h(is)g(a)f(r)o(eal)f(value)h +(giving)i(the)f(number)f(of)h(elapsed)681 1144 y(seconds)c(since)h(the) +f(Unix)h(\223epoch\224)e(\(Midnight,)h(January)g(1,)f(1970)g(UTC\).)g +(T)-5 b(ime)21 b(values)681 1244 y(pr)o(ovide)28 b(arbitrary)g(time)i +(r)o(esolution,)i(limited)e(only)h(by)e(the)h(number)f(system)h(of)g +(the)681 1343 y(underlying)21 b(Scheme)g(system.)805 +1478 y(A)32 b FB(date)f FC(is)h(a)g(name)f(for)h(an)g(instant)g(in)h +(time)f(that)g(is)g(speci\002ed)g(r)o(elative)e(to)i(some)681 +1577 y(location/time-zone)21 b(in)h(the)f(world,)f FB(e.g.)p +FC(:)888 1677 y(Friday)h(October)f(31,)g(1994)f(3:47:21)e(pm)k(EST)-6 +b(.)681 1777 y(Dates)33 b(pr)o(ovide)f(one-second)i(r)o(esolution,)j +(and)c(ar)o(e)f(expr)o(essed)g(with)i(the)g(following)681 +1876 y(r)o(ecor)o(d)19 b(type:)888 2084 y Fy(\(define-record)38 +b(date)216 b(;)44 b(A)f(Posix)e(tm)i(struct)976 2183 +y(seconds)302 b(;)43 b(Seconds)e(after)g(the)h(minute)g([0-59])976 +2283 y(minute)346 b(;)43 b(Minutes)e(after)g(the)h(hour)g([0-59])976 +2383 y(hour)434 b(;)43 b(Hours)e(since)h(midnight)e([0-23])976 +2482 y(month-day)214 b(;)43 b(Day)f(of)h(the)f(month)g([1-31])976 +2582 y(month)390 b(;)43 b(Months)e(since)h(January)e([0-11])976 +2682 y(year)434 b(;)43 b(Years)e(since)h(1900)976 2781 +y(tz-name)302 b(;)43 b(Time-zone)d(name:)h(#f)i(or)g(a)g(string.)976 +2881 y(tz-secs)302 b(;)43 b(Time-zone)d(offset:)g(#f)j(or)g(an)g +(integer.)976 2980 y(summer?)302 b(;)43 b(Summer)e(\(Daylight)f +(Savings\))g(time)i(in)h(effect?)976 3080 y(week-day)258 +b(;)43 b(Days)f(since)f(Sunday)g([0-6])976 3180 y(year-day\))214 +b(;)43 b(Days)f(since)f(Jan.)h(1)h([0-365])681 3387 y +FC(If)31 b(the)g Fy(tz-secs)e FC(\002eld)i(is)h(given,)i(it)d +(speci\002es)h(the)f(time-zone's)g(of)o(fset)g(fr)o(om)g(UTC)g(in)681 +3487 y(seconds.)50 b(If)28 b(it)h(is)g(speci\002ed,)i(the)d +Fy(tz-name)e FC(and)j Fy(summer?)d FC(\002elds)i(ar)o(e)g(ignor)o(ed)g +(when)681 3587 y(using)21 b(the)g(date)f(str)o(uctur)o(e)g(to)i +(determine)e(a)g(speci\002c)h(instant)g(in)h(time.)805 +3721 y(If)38 b(the)g Fy(tz-name)d FC(\002eld)j(is)h(given,)j(it)d(is)f +(a)g(time-zone)g(string)h(such)f(as)g Fy("EST")e FC(or)681 +3821 y Fy("HKT")25 b FC(understood)i(by)g(the)h(OS.)e(Since)j(P)t +Ft(O)t(S)t(I)t(X)i FC(time-zone)c(strings)h(can)f(specify)g(dual)681 +3920 y(standar)o(d/summer)33 b(time-zones)i(\(e.g.,)i(\224EST5EDT\224) +32 b(speci\002es)j(U.S.)e(Eastern)h(Stan-)681 4020 y(dar)o(d/Eastern)20 +b(Daylight)j(T)-5 b(ime\),)22 b(the)g(value)g(of)g(the)g +Fy(summer?)d FC(\002eld)j(is)g(used)g(to)h(r)o(esolve)681 +4120 y(the)k(amiguous)g(boundary)g(cases.)43 b(For)27 +b(example,)g(on)h(the)e(morning)j(of)d(the)h(Fall)g(day-)681 +4219 y(light)22 b(savings)h(change-over)-6 b(,)21 b(1:00am\2262:00am)c +(happens)22 b(twice.)28 b(Hence)22 b(the)g(date)f(1:30)681 +4319 y(am)27 b(on)h(this)g(morning)h(can)e(specify)g(two)h(dif)o(fer)o +(ent)d(seconds;)31 b(the)c Fy(summer?)d FC(\003ag)k(says)681 +4418 y(which)21 b(one.)805 4553 y(A)i(date)e(with)j Fy(tz-name)f +Fn(=)j Fy(tz-secs)e Fn(=)i Fy(#f)c FC(is)h(a)f(date)f(that)i(is)g +(speci\002ed)f(in)h(terms)g(of)681 4652 y(the)e(system's)g(curr)o(ent)f +(time)h(zone.)p 681 4742 1146 4 v 766 4796 a Fq(3)800 +4819 y Ft(Physics)26 b(pedants)f(please)g(note:)37 b(The)24 +b(scsh)i(authors)f(live)g(in)g(a)h(Newtonian)f(universe.)46 +b(W)-6 b(e)25 b(disclaim)681 4898 y(r)o(esponsibility)17 +b(for)g(calculations)i(performed)d(in)h(non-ANSI)f(standar)o(d)g +(light-cones.)2071 5147 y FC(68)p eop +%%Page: 69 75 +69 74 bop 490 614 a FC(Ther)o(e)20 b(is)h(r)o(edundancy)e(in)j(the)e +Fy(date)g FC(data)f(str)o(uctur)o(e.)25 b(For)c(example,)f(the)h +Fy(year-day)365 714 y FC(\002eld)f(is)g(r)o(edundant)e(with)i(the)g +Fy(month-day)c FC(and)j Fy(month)e FC(\002elds.)25 b(Either)20 +b(of)f(these)h(implies)365 814 y(the)27 b(values)g(of)f(the)h +Fy(week-day)d FC(\002eld.)43 b(The)27 b Fy(summer?)d +FC(and)j Fy(tz-name)c FC(\002elds)k(ar)o(e)f(r)o(edun-)365 +913 y(dant)33 b(with)g(the)g Fy(tz-secs)d FC(\002eld)i(in)h(terms)g(of) +g(specifying)g(an)f(instant)h(in)h(time.)61 b(This)365 +1013 y(r)o(edundancy)26 b(is)g(pr)o(ovided)g(because)f(consumers)j(of)e +(dates)g(may)g(want)h(it)g(br)o(oken)f(out)365 1112 y(in)d(dif)o(fer)o +(ent)d(ways.)29 b(The)22 b(scsh)h(pr)o(ocedur)o(es)d(that)i(pr)o(oduce) +f(date)g(r)o(ecor)o(ds)g(\002ll)i(them)f(out)365 1212 +y(completely)-9 b(.)58 b(However)-6 b(,)34 b(when)e(date)f(r)o(ecor)o +(ds)f(pr)o(oduced)g(by)i(the)f(pr)o(ogrammer)g(ar)o(e)365 +1312 y(passed)19 b(to)h(scsh)g(pr)o(ocedur)o(es,)d(the)j(r)o(edundancy) +e(is)h(r)o(esolved)g(by)g(ignoring)i(some)f(of)f(the)365 +1411 y(secondary)i(\002elds.)k(This)d(is)f(described)e(for)i(each)f(pr) +o(ocedur)o(e)f(below)-8 b(.)365 1563 y Fy(\(make-date)40 +b FB(s)16 b(min)f(h)h(mday)e(mon)h(y)h([tzn)f(tzs)g(summ?)g(wday)g +(yday])p Fy(\))41 b Fu(\000)-14 b(!)43 b FB(date)87 b +FC(pr)o(ocedur)o(e)573 1707 y(When)25 b(making)g(a)f +Fy(date)f FC(r)o(ecor)o(d,)g(the)i(last)f(\002ve)h(elements)g(of)f(the) +h(r)o(ecor)o(d)e(ar)o(e)g(op-)573 1807 y(tional,)d(and)f(default)f(to)i +Fy(#f)p FC(,)f Fy(#f)p FC(,)g Fy(#f)p FC(,)f(0,)i(and)f(0)g(r)o +(espectively)-9 b(.)24 b(This)c(is)f(useful)h(when)573 +1906 y(cr)o(eating)g(a)g Fy(date)f FC(r)o(ecor)o(d)g(to)i(pass)g(as)f +(an)h(ar)o(gument)f(to)h Fy(time)p FC(.)365 2185 y FA(3.10.3)81 +b(T)-5 b(ime)20 b(zones)365 2373 y FC(Several)30 b(time)i(pr)o(ocedur)o +(es)d(take)i(time)g(zones)h(as)f(ar)o(guments.)56 b(When)32 +b(optional,)i(the)365 2473 y(time)21 b(zone)g(defaults)f(to)h(local)g +(time)g(zone.)k(Otherwise)d(the)f(time)g(zone)f(can)h(be)f(one)h(of:) +623 2597 y Fy(#f)273 b FC(Local)20 b(time)623 2697 y(Integer)99 +b(Seconds)19 b(of)g(of)o(fset)f(fr)o(om)h(UTC.)f(For)h(example,)g(New) +984 2797 y(Y)-8 b(ork)25 b(City)g(is)f(-18000)e(\(-5)h(hours\),)i(San)f +(Francisco)g(is)984 2896 y(-28800)18 b(\(-8)i(hours\).)623 +2996 y(String)139 b(A)18 b(P)t Ft(O)t(S)t(I)t(X)i FC(time)d(zone)f +(string)h(understood)g(by)f(the)h(OS)984 3096 y(\()p +FB(i.e.)p FC(.,)27 b(the)g(sort)g(of)g(time)g(zone)f(assigned)h(to)g +(the)g Fy($TZ)984 3195 y FC(envir)o(onment)21 b(variable\).)365 +3339 y(An)f(integer)f(time)h(zone)f(gives)g(the)h(number)f(of)h +(seconds)f(you)h(must)g(add)e(to)i(UTC)f(to)h(get)365 +3438 y(time)h(in)h(that)e(zone.)26 b(It)21 b(is)g FB(not)f +FC(\223seconds)h(west\224)f(of)h(UTC\227that)f(\003ips)i(the)e(sign.) +490 3567 y(T)-8 b(o)21 b(get)g(UTC)f(time,)h(use)g(a)f(time)h(zone)g +(of)f(either)h(0)f(or)h Fy("UCT0")p FC(.)365 3828 y FA(3.10.4)81 +b(Procedures)365 4039 y Fy(\(time+ticks\))i Fu(\000)-15 +b(!)87 b FB([secs)22 b(ticks])1297 b FC(pr)o(ocedur)o(e)365 +4139 y Fy(\(ticks/sec\))83 b Fu(\000)-14 b(!)87 b FB(r)o(eal)1579 +b FC(pr)o(ocedur)o(e)573 4265 y(The)27 b(curr)o(ent)g(time,)h(with)h +(sub-second)e(r)o(esolution.)46 b(Sub-second)26 b(r)o(esolution)i(is) +573 4364 y(not)h(pr)o(ovided)f(by)j(P)t Ft(O)t(S)t(I)t(X)r +FC(,)h(but)d(is)g(available)f(on)h(many)g(systems.)51 +b(The)29 b(time)g(is)573 4464 y(r)o(eturned)19 b(as)h(elapsed)g +(seconds)g(since)h(the)g(Unix)f(epoch,)g(plus)h(a)f(number)g(of)h(sub-) +573 4564 y(second)29 b(\223ticks.\224)50 b(The)29 b(length)h(of)f(a)g +(tick)g(may)g(vary)f(fr)o(om)h(implementation)h(to)573 +4663 y(implementation;)21 b(it)g(can)g(be)f(determined)g(fr)o(om)h +Fy(\(ticks/sec\))p FC(.)573 4799 y(The)c(system)i(clock)f(is)g(not)g(r) +o(equir)o(ed)e(to)i(r)o(eport)f(time)h(at)f(the)h(full)g(r)o(esolution) +g(given)573 4898 y(by)g Fy(\(ticks/sec\))p FC(.)i(For)f(example,)f(on)h +(BSD,)e(time)i(is)f(r)o(eported)f(at)h Fn(1)p Fz(\026)p +FC(s)g(r)o(esolution,)1756 5147 y(69)p eop +%%Page: 70 76 +70 75 bop 888 614 a FC(so)34 b Fy(\(ticks/sec\))28 b +FC(is)33 b(1,000,000.)58 b(That)33 b(doesn't)g(mean)g(the)g(system)h +(clock)f(has)888 714 y(micr)o(o-second)21 b(r)o(esolution.)888 +849 y(If)c(the)f(OS)h(does)f(not)i(support)f(sub-second)f(r)o +(esolution,)i(the)f FB(ticks)f FC(value)g(is)h(always)888 +949 y(0,)j(and)h Fy(\(ticks/sec\))16 b FC(r)o(eturns)k(1.)1071 +1129 y Fl(Remark:)93 b Fk(I)29 b(chose)g(to)g(r)o(epr)o(esent)e(system) +i(clock)f(r)o(esolution)g(as)h(ticks/sec)1071 1221 y(instead)20 +b(of)g(sec/tick)g(to)g(incr)o(ease)g(the)h(odds)e(that)j(the)e(value)h +(could)e(be)i(r)o(epr)o(e-)1071 1312 y(sented)j(as)g(an)h(exact)f +(integer)-6 b(,)25 b(incr)o(easing)e(ef)o(\002ciency)h(and)h(making)e +(it)i(easier)1071 1403 y(for)k(Scheme)h(implementations)g(that)i(don't) +d(have)i(sophisticated)f(numeric)1071 1494 y(support)18 +b(to)h(deal)f(with)i(the)f(quantity)-8 b(.)1071 1604 +y(Y)h(ou)18 b(can)i(convert)f(seconds)f(and)h(ticks)g(to)f(seconds)g +(with)i(the)f(expr)o(ession)1226 1735 y Fh(\(+)40 b Fi(secs)g +Fh(\(/)f Fi(ticks)h Fh(\(ticks/sec\)\)\))1071 1866 y +Fk(Given)23 b(that,)i(why)f(not)f(have)h(the)g(\002ne-grain)f(time)g +(pr)o(ocedur)o(e)d(just)k(r)o(eturn)e(a)1071 1958 y(non-integer)g(r)o +(eal)g(for)g(time?)35 b(Following)21 b(Common)i(Lisp,)f(I)h(chose)g(to) +f(allow)1071 2049 y(the)i(system)f(clock)g(to)h(r)o(eport)f(sub-second) +g(time)g(in)h(its)g(own)g(units)g(to)g(lower)1071 2140 +y(the)d(over)o(head)f(of)g(determining)f(the)j(time.)28 +b(This)20 b(would)g(be)g(important)h(for)f(a)1071 2232 +y(system)15 b(that)i(wanted)f(to)g(pr)o(ecisely)d(time)i(the)h +(duration)g(of)f(some)g(event.)22 b(T)l(ime)1071 2323 +y(stamps)16 b(could)g(be)h(collected)f(with)h(little)g(over)o(head,)e +(deferring)g(the)i(over)o(head)1071 2414 y(of)h(pr)o(ecisely)f +(calculating)i(with)h(them)f(until)g(after)g(collection.)1071 +2524 y(This)e(is)f(all)h(a)g(bit)g(academic)g(for)f(the)i(Scheme)f(48)g +(implementation,)h(wher)o(e)e(we)1071 2615 y(determine)23 +b(time)h(with)h(a)g(heavyweight)f(system)g(call,)h(but)g(it's)e(nice)i +(to)f(plan)1071 2706 y(for)18 b(the)h(futur)o(e.)681 +2976 y Fy(\(date\))84 b Fu(\000)-14 b(!)87 b FB(date-r)o(ecord)1545 +b FC(pr)o(ocedur)o(e)681 3075 y Fy(\(date)41 b FB([time)20 +b(tz])p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(date-r)o(ecord)1213 +b FC(pr)o(ocedur)o(e)888 3219 y(Simple)21 b Fy(\(date\))d +FC(r)o(eturns)i(the)h(curr)o(ent)f(date,)g(in)h(the)g(local)g(time)g +(zone.)888 3354 y(W)-5 b(ith)23 b(the)g(optional)g(ar)o(guments,)e +Fy(date)g FC(converts)h(the)h(time)f(to)g(the)h(date)e(as)h(spec-)888 +3454 y(i\002ed)h(by)f(the)h(time)g(zone)g FB(tz)o FC(.)31 +b FB(T)-5 b(ime)23 b FC(defaults)f(to)h(the)f(curr)o(ent)g(time;)i +FB(tz)e FC(defaults)g(to)888 3553 y(local)f(time,)g(and)f(is)h(as)g +(described)e(in)j(the)f(time-zone)f(section.)888 3688 +y(If)25 b(the)g FB(tz)f FC(ar)o(gument)h(is)g(an)g(integer)-6 +b(,)25 b(the)h(date's)e Fy(tz-name)e FC(\002eld)j(is)g(a)h(P)t +Ft(O)t(S)t(I)t(X)j FC(time)888 3788 y(zone)17 b(of)f(the)h(form)f(\223) +p Fy(UTC+)p Fs(hh)c Fy(:)p Fs(mm)h Fy(:)p Fs(ss)g FC(\224;)k(the)g +(trailing)g Fy(:)p Fs(mm)c Fy(:)p Fs(ss)30 b FC(portion)17 +b(is)g(deleted)888 3888 y(if)k(it)g(is)g(zer)o(oes.)681 +4086 y Fy(\(time\))84 b Fu(\000)-14 b(!)87 b FB(integer)1685 +b FC(pr)o(ocedur)o(e)681 4185 y Fy(\(time)41 b FB([date])p +Fy(\))86 b Fu(\000)-15 b(!)88 b FB(integer)1447 b FC(pr)o(ocedur)o(e) +888 4329 y(Simple)21 b Fy(\(time\))d FC(r)o(eturns)i(the)h(curr)o(ent)f +(time.)888 4464 y(W)-5 b(ith)30 b(the)g(optional)g(date)e(ar)o(gument,) +i Fy(time)e FC(converts)h(a)g(date)f(to)h(a)g(time.)51 +b FB(Date)888 4564 y FC(defaults)20 b(to)h(the)g(curr)o(ent)f(date.)888 +4699 y(Note)31 b(that)f(the)h(input)g FB(date)f FC(r)o(ecor)o(d)e(is)j +(over)o(constrained.)54 b Fy(time)29 b FC(ignor)o(es)h +FB(date)p FC('s)888 4799 y Fy(week-day)k FC(and)i Fy(year-day)d +FC(\002elds.)73 b(If)36 b(the)h(date's)f Fy(tz-secs)d +FC(\002eld)k(is)g(set,)j(the)888 4898 y Fy(tz-name)18 +b FC(and)j Fy(summer?)c FC(\002elds)k(ar)o(e)f(ignor)o(ed.)2071 +5147 y(70)p eop +%%Page: 71 77 +71 76 bop 573 614 a FC(If)26 b(the)g Fy(tz-secs)e FC(\002eld)i(is)g +Fy(#f)p FC(,)h(then)g(the)f(time-zone)g(is)h(taken)f(fr)o(om)g(the)g +Fy(tz-name)573 714 y FC(\002eld.)35 b(A)24 b(false)g +Fy(tz-name)d FC(means)j(the)g(system's)h(curr)o(ent)f(time)g(zone.)36 +b(When)24 b(cal-)573 814 y(culating)f(with)h(time-zones,)f(the)g +(date's)f Fy(summer?)e FC(\002eld)j(is)g(used)g(to)g(r)o(esolve)f(am-) +573 913 y(biguities:)805 1015 y Fy(#f)161 b FC(Resolve)21 +b(an)g(ambiguous)g(time)g(in)h(favor)e(of)g(non-summer)i(time.)805 +1114 y(tr)o(ue)100 b(Resolve)21 b(an)g(ambiguous)g(time)g(in)h(favor)e +(of)g(summer)h(time.)573 1213 y(This)f(is)h(useful)f(in)g(boundary)g +(cases)g(during)g(the)g(change-over)-6 b(.)25 b(For)20 +b(example,)f(in)573 1313 y(the)g(Fall,)g(when)h(US)f(daylight)g +(savings)h(time)f(changes)h(over)f(at)g(2:00)e(am,)i(1:30)f(am)573 +1412 y(happens)j(twice\227it)g(names)f(two)i(instants)f(in)h(time,)e +(an)h(hour)g(apart.)573 1539 y(Outside)31 b(of)h(these)f(boundary)g +(cases,)i(the)f Fy(summer?)c FC(\003ag)j(is)h(ignor)o(ed.)57 +b(For)31 b(ex-)573 1638 y(ample,)21 b(if)g(the)g(standar)o(d/summer)g +(change-overs)g(happen)g(in)h(the)f(Fall)h(and)e(the)573 +1738 y(Spring,)f(then)h(the)g(value)f(of)h Fy(summer?)d +FC(is)j(ignor)o(ed)f(for)h(a)f(January)f(or)i(July)g(date.)k(A)573 +1838 y(January)18 b(date)h(would)h(be)f(r)o(esolved)f(with)i(standar)o +(d)e(time,)i(and)f(a)g(July)g(date)g(with)573 1937 y(summer)i(time,)g +(r)o(egar)o(dless)e(of)h(the)h Fy(summer?)d FC(value.)573 +2064 y(The)k Fy(summer?)d FC(\003ag)j(is)g(also)g(ignor)o(ed)g(if)g +(the)g(time)g(zone)g(doesn't)g(have)g(a)f(summer)573 +2163 y(time\227for)g(example,)e(simple)j(UTC.)365 2335 +y Fy(\(date->string)39 b FB(date)p Fy(\))86 b Fu(\000)-15 +b(!)88 b FB(string)1186 b FC(pr)o(ocedur)o(e)365 2435 +y Fy(\(format-date)39 b FB(fmt)20 b(date)p Fy(\))86 b +Fu(\000)-14 b(!)87 b FB(string)1094 b FC(pr)o(ocedur)o(e)573 +2563 y Fy(Date->string)16 b FC(formats)k(the)h(date)f(as)g(a)h +(24-character)d(string)j(of)g(the)g(form:)756 2663 y(Sun)f(Sep)g(16)g +(01:03:52)d(1973)573 2789 y Fy(Format-date)26 b FC(formats)31 +b(the)g(date)f(accor)o(ding)g(to)i(the)f(format)f(string)i +FB(fmt)o FC(.)57 b(The)573 2889 y(format)16 b(string)i(is)f(copied)f +(verbatim,)h(except)f(that)g(tilde)h(characters)e(indicate)h(con-)573 +2989 y(version)21 b(speci\002ers)g(that)f(ar)o(e)f(r)o(eplaced)g(by)i +(\002elds)f(fr)o(om)h(the)f(date)g(r)o(ecor)o(d.)k(Figur)o(e)573 +3088 y(3.1)19 b(gives)i(the)g(full)g(set)g(of)g(conversion)g +(speci\002ers)g(supported)f(by)h Fy(format-date)p FC(.)365 +3260 y Fy(\(fill-in-date!)38 b FB(date)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(date)1207 b FC(pr)o(ocedur)o(e)573 3388 y(This)27 +b(pr)o(ocedur)o(e)d(\002lls)j(in)f(missing,)j(r)o(edundant)c(slots)i +(in)g(a)f(date)f(r)o(ecor)o(d.)40 b(In)26 b(de-)573 3488 +y(cr)o(easing)20 b(or)o(der)g(of)g(priority:)672 3641 +y Fu(\017)42 b FA(year)-5 b(,)20 b(month,)f(month-day)g +Fu(\))i FA(year)o(-day)756 3741 y FC(If)g(the)g Fy(year)p +FC(,)f Fy(month)p FC(,)f(and)i Fy(month-day)d FC(\002elds)j(ar)o(e)f +(all)i(de\002ned)f(\(ar)o(e)e(all)j(inte-)756 3841 y(gers\),)e(the)g +Fy(year-day)e FC(\002eld)j(is)g(set)f(to)i(the)f(corr)o(esponding)f +(value.)672 3961 y Fu(\017)42 b FA(year)-5 b(,)20 b(year)o(-day)f +Fu(\))h FA(month,)g(month-day)756 4060 y FC(If)41 b(the)h +Fy(month)e FC(and)h Fy(month-day)d FC(\002elds)k(ar)o(en't)f(set,)47 +b(but)42 b(the)g Fy(year)e FC(and)756 4160 y Fy(year-day)17 +b FC(\002elds)k(ar)o(e)e(set,)i(then)g Fy(month)e FC(and)h +Fy(month-day)d FC(ar)o(e)i(calculated.)672 4280 y Fu(\017)42 +b FA(year)-5 b(,)20 b(month,)f(month-day)-8 b(,)19 b(year)o(-day)g +Fu(\))i FA(week-day)756 4380 y FC(If)27 b(either)g(of)h(the)f(above)g +(r)o(ules)h(is)g(able)f(to)h(determine)f(what)h(day)f(it)h(is,)h(the) +756 4479 y Fy(week-day)17 b FC(\002eld)k(is)g(then)g(set.)672 +4599 y Fu(\017)42 b FA(tz-secs)18 b Fu(\))j FA(tz-name)756 +4699 y FC(If)i Fy(tz-secs)d FC(is)k(de\002ned,)g(but)g +Fy(tz-name)c FC(is)k(not,)h(it)f(is)g(assigned)g(a)f(time-zone)756 +4799 y(name)h(of)i(the)f(form)g(\223)p Fy(UTC+)p Fs(hh)11 +b Fy(:)p Fs(mm)j Fy(:)p Fs(ss)f FC(\224;)26 b(the)f(trailing)h +Fy(:)p Fs(mm)13 b Fy(:)p Fs(ss)38 b FC(portion)26 b(is)756 +4898 y(deleted)19 b(if)i(it)g(is)g(zer)o(oes.)1756 5147 +y(71)p eop +%%Page: 72 78 +72 77 bop 681 1129 2865 4 v 681 4301 4 3173 v 759 1274 +a Fy(~~)99 b FC(Converted)20 b(to)h(the)g Fy(~)f FC(character)-6 +b(.)759 1399 y Fy(~a)99 b FC(abbr)o(eviated)18 b(weekday)i(name)759 +1523 y Fy(~A)99 b FC(full)20 b(weekday)g(name)759 1648 +y Fy(~b)99 b FC(abbr)o(eviated)18 b(month)k(name)759 +1772 y Fy(~B)99 b FC(full)20 b(month)i(name)759 1897 +y Fy(~c)99 b FC(time)21 b(and)f(date)g(using)h(the)g(time)g(and)g(date) +f(r)o(epr)o(esentation)f(for)i(the)g(locale)946 1996 +y(\()p Fy(~X)42 b(~x)p FC(\))759 2121 y Fy(~d)99 b FC(day)20 +b(of)h(the)f(month)j(as)d(a)g(decimal)g(number)h(\(01-31\))759 +2245 y Fy(~H)99 b FC(hour)21 b(based)f(on)h(a)f(24-hour)g(clock)h(as)g +(a)f(decimal)g(number)h(\(00-23\))759 2370 y Fy(~I)99 +b FC(hour)21 b(based)f(on)h(a)f(12-hour)g(clock)h(as)g(a)f(decimal)g +(number)h(\(01-12\))759 2495 y Fy(~j)99 b FC(day)20 b(of)h(the)f(year)g +(as)h(a)f(decimal)g(number)h(\(001-366\))759 2619 y Fy(~m)99 +b FC(month)22 b(as)e(a)g(decimal)h(number)g(\(01-12\))759 +2744 y Fy(~M)99 b FC(minute)21 b(as)g(a)f(decimal)g(number)h(\(00-59\)) +759 2868 y Fy(~p)99 b FC(AM/PM)19 b(designation)j(associated)e(with)i +(a)e(12-hour)g(clock)759 2993 y Fy(~S)99 b FC(second)21 +b(as)f(a)g(decimal)h(number)f(\(00-61\))759 3117 y Fy(~U)99 +b FC(week)20 b(number)h(of)g(the)g(year;)f(Sunday)g(is)h(\002rst)g(day) +f(of)h(week)f(\(00-53\))759 3242 y Fy(~w)99 b FC(weekday)20 +b(as)g(a)g(decimal)h(number)g(\(0-6\),)d(wher)o(e)i(Sunday)g(is)h(0)759 +3366 y Fy(~W)99 b FC(week)20 b(number)h(of)g(the)g(year;)f(Monday)g(is) +h(\002rst)g(day)f(of)h(week)g(\(00-53\))759 3491 y Fy(~x)99 +b FC(date)19 b(using)j(the)f(date)f(r)o(epr)o(esentation)f(for)i(the)g +(locale)759 3615 y Fy(~X)99 b FC(time)21 b(using)g(the)g(time)g(r)o +(epr)o(esentation)f(for)g(the)h(locale)759 3740 y Fy(~y)99 +b FC(year)20 b(without)i(century)e(\(00-99\))759 3864 +y Fy(~Y)99 b FC(year)20 b(with)h(century)g(\()p FB(e.g.)o +FC(1990\))759 3989 y Fy(~Z)99 b FC(time)21 b(zone)f(name)h(or)g(abbr)o +(eviation,)e(or)i(no)h(characters)d(if)i(no)g(time)g(zone)g(is)946 +4089 y(determinable)1275 4278 y(Figur)o(e)f(3.1:)k Fy(format-date)17 +b FC(conversion)k(speci\002ers)p 3542 4301 V 681 4304 +2865 4 v 2071 5147 a(72)p eop +%%Page: 73 79 +73 78 bop 672 614 a Fu(\017)42 b FA(tz-name,)17 b(date,)i(summer?)25 +b Fu(\))c FA(tz-secs,)d(summer?)756 714 y FC(If)f(the)i(date)e +(information)i(is)g(pr)o(ovided)e(up)h(to)h(second)f(r)o(esolution,)h +Fy(tz-name)756 814 y FC(is)j(also)h(pr)o(ovided,)e(and)h +Fy(tz-secs)d FC(is)k(not)g(set,)f(then)h Fy(tz-secs)d +FC(and)h Fy(summer?)756 913 y FC(ar)o(e)34 b(set)i(to)h(their)f(corr)o +(ect)f(values.)71 b(Summer)o(-time)36 b(ambiguities)g(ar)o(e)f(r)o(e-) +756 1013 y(solved)21 b(using)i(the)f(original)g(value)f(of)h +Fy(summer?)p FC(.)j(If)d(the)f(time)h(zone)g(doesn't)756 +1112 y(have)e(a)g(summer)h(time)g(variant,)f(then)h Fy(summer?)d +FC(is)j(set)g(to)g Fy(#f)p FC(.)672 1256 y Fu(\017)42 +b FA(local)19 b(time,)g(date,)g(summer?)25 b Fu(\))20 +b FA(tz-name,)e(tz-secs,)h(summer?)756 1356 y FC(If)24 +b(the)g(date)g(information)i(is)f(pr)o(ovided)e(up)i(to)g(second)f(r)o +(esolution,)i(but)f(no)756 1455 y(time)16 b(zone)f(information)i(is)f +(pr)o(ovided)f(\(both)h Fy(tz-name)d FC(and)j Fy(tz-secs)d +FC(ar)o(en't)756 1555 y(set\),)24 b(then)g(we)g(pr)o(oceed)e(as)i(in)g +(the)g(above)f(case,)h(except)f(the)h(system's)h(cur)o(-)756 +1654 y(r)o(ent)20 b(time)h(zone)f(is)i(used.)573 1842 +y(These)31 b(r)o(ules)g(allow)g(one)h(particular)d(ambiguity)j(to)f +(escape:)45 b(if)31 b(both)g Fy(tz-name)573 1941 y FC(and)c +Fy(tz-secs)d FC(ar)o(e)i(set,)i(they)g(ar)o(e)e(not)i(br)o(ought)f +(into)h(agr)o(eement.)44 b(It)27 b(isn't)h(clear)573 +2041 y(how)21 b(to)h(do)e(this,)i(nor)f(is)g(it)g(clear)f(which)h(one)h +(should)f(take)f(pr)o(ecedence.)756 2242 y Fl(Oops:)50 +b Fh(fill-in-date!)22 b Fk(isn't)d(implemented)f(yet.)365 +2670 y Fw(3.1)l(1)100 b(Environment)24 b(variables)365 +2924 y Fy(\(setenv)41 b FB(var)20 b(val)p Fy(\))87 b +Fu(\000)-15 b(!)88 b FB(unde\002ned)1226 b FC(pr)o(ocedur)o(e)365 +3024 y Fy(\(getenv)41 b FB(var)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(string)1476 b FC(pr)o(ocedur)o(e)573 3154 +y(These)21 b(functions)i(get)e(and)g(set)h(the)g(pr)o(ocess)f(envir)o +(onment,)h(stor)o(ed)f(in)h(the)f(exter)o(-)573 3253 +y(nal)h(C)g(variable)f Fy(char)41 b(**environ)p FC(.)26 +b(An)c(envir)o(onment)h(variable)d FB(var)i FC(is)h(a)e(string.)573 +3353 y(If)k(an)g(envir)o(onment)g(variable)f(is)i(set)f(to)h(a)e +(string)i FB(val)p FC(,)g(then)f(the)h(pr)o(ocess')e(global)573 +3452 y(envir)o(onment)i(str)o(uctur)o(e)g(is)g(alter)o(ed)f(with)h(an)g +(entry)g(of)g(the)h(form)f Fy(")p FB(var)o Fy(=)p FB(val)o +Fy(")p FC(.)41 b(If)573 3552 y FB(val)20 b FC(is)h Fy(#f)p +FC(,)f(then)h(any)g(entry)g(for)f FB(var)h FC(is)g(deleted.)365 +3775 y Fy(\(env->alist\))83 b Fu(\000)-15 b(!)87 b FB(string)p +Fu(!)p FB(string)21 b(alist)1006 b FC(pr)o(ocedur)o(e)573 +3927 y(The)21 b Fy(env->alist)c FC(pr)o(ocedur)o(e)i(converts)i(the)g +(entir)o(e)f(envir)o(onment)i(into)g(an)f(alist,)573 +4026 y FB(e.g.)o FC(,)756 4213 y Fy(\(\("TERM")40 b(.)j("vt100"\))799 +4313 y(\("SHELL")d(.)k("/bin/csh"\))799 4413 y(\("EDITOR")c(.)j +("emacs"\))799 4512 y(...\))365 4845 y(\(alist->env)c +FB(alist)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(unde\002ned)1142 +b FC(pr)o(ocedur)o(e)1756 5147 y(73)p eop +%%Page: 74 80 +74 79 bop 888 614 a FB(Alist)29 b FC(must)g(be)f(an)g(alist)h(whose)g +(keys)g(ar)o(e)e(all)h(strings,)j(and)d(whose)h(values)f(ar)o(e)888 +714 y(all)i(either)g(strings)h(or)f(string)g(lists.)54 +b(String)30 b(lists)g(ar)o(e)f(converted)g(to)h(colon)h(lists)888 +814 y(\(see)c(below\).)46 b(The)27 b(alist)h(is)g(installed)f(as)g(the) +h(curr)o(ent)e(Unix)i(envir)o(onment)g(\()p FB(i.e.)o +FC(,)888 913 y(converted)23 b(to)g(a)g(null-terminated)g(C)g(vector)f +(of)h Fy(")p FB(var)p Fy(=)p FB(val)o Fy(")f FC(strings)i(which)g(is)g +(as-)888 1013 y(signed)d(to)h(the)e(global)h Fy(char)42 +b(**environ)p FC(\).)805 1175 y(The)21 b(following)i(thr)o(ee)d +(functions)i(help)f(the)g(pr)o(ogrammer)f(manipulate)g(alist)h(tables) +681 1275 y(in)f(some)g(generally)g(useful)f(ways.)26 +b(They)20 b(ar)o(e)e(all)h(de\002ned)h(using)g Fy(equal?)e +FC(for)h(key)h(com-)681 1375 y(parison.)681 1517 y Fy(\(alist-delete)38 +b FB(key)20 b(alist)p Fy(\))87 b Fu(\000)-14 b(!)87 b +FB(alist)1110 b FC(pr)o(ocedur)o(e)888 1651 y(Delete)21 +b(any)g(entry)f(labelled)g(by)h(value)f FB(key)p FC(.)681 +1931 y Fy(\(alist-update)38 b FB(key)20 b(val)h(alist)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(alist)988 b FC(pr)o(ocedur)o(e)888 +2066 y(Delete)21 b FB(key)f FC(fr)o(om)h FB(alist)p FC(,)f(then)h(cons) +h(on)f(a)f Fy(\()p FB(key)43 b Fy(.)g FB(val)p Fy(\))20 +b FC(entry)-9 b(.)681 2346 y Fy(\(alist-compress)37 b +FB(alist)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(alist)1154 +b FC(pr)o(ocedur)o(e)888 2480 y(Compr)o(esses)21 b FB(alist)g +FC(by)f(r)o(emoving)h(shadowed)g(entries.)26 b(Example:)1071 +2639 y Fy(;;;)42 b(Shadowed)f(\(1)h(.)i(c\))e(entry)g(removed.)1071 +2739 y(\(alist-compress)37 b('\()43 b(\(1)g(.)g(a\))g(\(2)g(.)g(b\))g +(\(1)f(.)h(c\))g(\(3)g(.)g(d\))g(\)\))1245 2838 y Fn(=)-14 +b Fu(\))87 b Fy(\(\(1)43 b(.)g(a\))g(\(2)f(.)h(b\))g(\(3)g(.)g(d\)\)) +681 3095 y(\(with-env*)c FB(env-alist-delta)20 b(thunk)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(value\(s\))20 b(of)h(thunk)391 +b FC(pr)o(ocedur)o(e)681 3194 y Fy(\(with-total-env*)37 +b FB(env-alist)20 b(thunk)p Fy(\))87 b Fu(\000)-15 b(!)88 +b FB(value\(s\))20 b(of)g(thunk)319 b FC(pr)o(ocedur)o(e)888 +3329 y(These)35 b(pr)o(ocedur)o(es)d(call)i FB(thunk)f +FC(in)i(the)f(context)h(of)f(an)g(alter)o(ed)f(envir)o(onment.)888 +3428 y(They)20 b(r)o(eturn)f(whatever)h(values)f FB(thunk)g +FC(r)o(eturns.)25 b(Non-local)20 b(r)o(eturns)f(r)o(estor)o(e)g(the)888 +3528 y(envir)o(onment)g(to)f(its)g(outer)f(value;)h(thr)o(owing)h(back) +e(into)h(the)g(thunk)h(by)f(invoking)888 3628 y(a)j(stor)o(ed)f +(continuation)i(r)o(estor)o(es)e(the)h(envir)o(onment)g(back)f(to)h +(its)g(inner)h(value.)888 3757 y(The)17 b FB(env-alist-delta)e +FC(ar)o(gument)h(speci\002es)g(a)g FB(modi\002cation)f +FC(to)i(the)g(curr)o(ent)e(envir)o(on-)888 3857 y(ment\227)p +FB(thunk)p FC('s)21 b(envir)o(onment)g(is)f(the)h(original)g(envir)o +(onment)g(overridden)e(with)888 3956 y(the)i(bindings)h(speci\002ed)e +(by)h(the)g(alist)g(delta.)888 4085 y(The)g FB(env-alist)g +FC(ar)o(gument)g(speci\002es)g(a)g(complete)g(envir)o(onment)g(that)h +(is)f(installed)888 4185 y(for)g FB(thunk)o FC(.)681 +4366 y Fy(\(with-env)40 b FB(env-alist-delta)19 b(.)i(body)p +Fy(\))86 b Fu(\000)-15 b(!)88 b FB(value\(s\))20 b(of)g(body)608 +b FC(syntax)681 4465 y Fy(\(with-total-env)37 b FB(env-alist)20 +b(.)h(body)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(value\(s\))20 +b(of)h(body)535 b FC(syntax)888 4599 y(These)34 b(special)f(forms)h(pr) +o(ovide)f(syntactic)h(sugar)f(for)h Fy(with-env*)c FC(and)j +Fy(with-)888 4699 y(total-env*)p FC(.)21 b(The)e(env)h(alists)f(ar)o(e) +f(not)i(evaluated)e(positions,)j(but)e(ar)o(e)f(implicitly)888 +4799 y(backquoted.)33 b(In)23 b(this)h(way)-9 b(,)23 +b(they)g(tend)g(to)h(r)o(esemble)e(binding)i(lists)g(for)f +Fy(let)e FC(and)888 4898 y Fy(let*)e FC(forms.)2071 5147 +y(74)p eop +%%Page: 75 81 +75 80 bop 490 614 a FC(Example:)39 b(These)28 b(four)f(pieces)h(of)f +(code)h(all)g(r)o(un)g(the)g(mailer)g(with)g(special)g +Fy($TERM)365 706 y FC(and)21 b Fy($EDITOR)c FC(values.)573 +841 y Fh(\(with-env)41 b(\(\("TERM")g(.)f("xterm"\))h(\("EDITOR")g(.)e +(,my-editor\)\))651 933 y(\(run)h(\(mail)h(shivers@lcs.mit.edu\)\)\)) +573 1115 y(\(with-env*)g(`\(\("TERM")h(.)d("xterm"\))i(\("EDITOR")g(.)f +(,my-editor\)\))651 1207 y(\()n Fe(\025)c Fh(\(\))k(\(run)g(\(mail)g +(shivers@csd.hku.hk\)\)\)\))573 1389 y(\(run)g(\(begin)h(\(setenv)f +("TERM")h("xterm"\))237 b(;)40 b(Env)g(mutation)h(happens)1044 +1481 y(\(setenv)f("EDITOR")h(my-editor\))h(;)d(in)h(the)g(subshell.) +1044 1572 y(\(exec-epf)h(\(mail)f(shivers@research.att.com\)\)\)\))573 +1755 y(;;)g(In)f(this)h(example,)h(we)f(compute)h(an)f(alternate)h +(environment)h(ENV2)573 1846 y(;;)e(as)f(an)h(alist,)g(and)g(install)h +(it)f(with)g(an)g(explicit)h(call)f(to)g(the)573 1937 +y(;;)g(EXEC-PATH/ENV)i(procedure.)573 2029 y(\(let*)e(\(\(env)h +(\(env->alist\)\))434 b(;)39 b(Get)h(the)g(current)h(environment,)847 +2120 y(\(env1)g(\(alist-update)h(env)79 b("TERM")41 b("xterm"\)\))237 +b(;)40 b(and)f(compute)847 2211 y(\(env2)i(\(alist-update)h(env1)e +("EDITOR")h(my-editor\)\)\))h(;)e(the)f(new)h(env.)651 +2302 y(\(run)g(\(begin)h(\(exec-path/env)h("mail")f(env2)f +("shivers@cs.cmu.edu"\)\)\)\))365 2691 y FA(3.1)m(1.1)81 +b(Path)19 b(lists)h(and)f(colon)i(lists)365 2866 y FC(Envir)o(onment)h +(variables)e(such)i(as)f Fy($PATH)e FC(encode)i(a)g(list)h(of)f +(strings)h(by)g(separating)e(the)365 2957 y(list)g(elements)f(with)h +(colon)f(delimiters.)25 b(Once)19 b(parsed)f(into)i(actual)e(lists,)i +(these)f(or)o(der)o(ed)365 3048 y(lists)h(can)f(be)g(manipulated)f +(with)i(the)g(following)g(two)g(functions.)26 b(T)-8 +b(o)20 b(convert)f(between)365 3140 y(the)26 b(colon-separated)e +(string)h(encoding)h(and)f(the)g(list-of-strings)h(r)o(epr)o +(esentation,)f(see)365 3231 y(the)c Fy(field-reader)16 +b FC(and)k Fy(join-strings)c FC(functions)22 b(in)f(section)g(7.1.)573 +3367 y Fl(Remark:)71 b Fk(An)24 b(earlier)f(r)o(elease)f(of)h(scsh)h +(pr)o(ovided)e(the)i Fh(split-colon-list)k Fk(and)573 +3458 y Fh(string-list->colon-list)41 b Fk(functions.)77 +b(These)36 b(have)h(been)f(r)o(emoved)f(fr)o(om)573 3549 +y(scsh,)27 b(and)g(ar)o(e)e(r)o(eplaced)f(by)i(the)h(mor)o(e)d(general) +h(parsers)g(and)h(unparsers)f(of)g(the)573 3640 y(\002eld-r)o(eader)16 +b(module.)365 3795 y Fy(\(add-before)39 b FB(elt)21 b(befor)o(e)h(list) +p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(list)1085 b FC(pr)o(ocedur)o(e)365 +3895 y Fy(\(add-after)40 b FB(elt)21 b(after)f(list)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(list)1170 b FC(pr)o(ocedur)o(e)573 +4022 y(These)20 b(functions)h(ar)o(e)e(for)h(modifying)h(sear)o +(ch-path)d(lists,)j(wher)o(e)e(element)i(or)o(der)573 +4122 y(is)g(signi\002cant.)573 4248 y Fy(add-before)c +FC(adds)k FB(elt)g FC(to)h(the)g(list)g(immediately)g(befor)o(e)e(the)h +(\002rst)h(occurr)o(ence)f(of)573 4348 y FB(befor)o(e)f +FC(in)g(the)f(list.)26 b(If)19 b FB(befor)o(e)h FC(is)g(not)g(in)g(the) +f(list,)h FB(elt)f FC(is)h(added)e(to)i(the)f(end)g(of)h(the)f(list.) +573 4474 y Fy(add-after)f FC(is)j(similar:)27 b FB(elt)22 +b FC(is)f(added)f(after)g(the)i(last)f(occurr)o(ence)g(of)g +FB(after)p FC(.)27 b(If)21 b FB(after)573 4573 y FC(is)g(not)g(found,)g +FB(elt)g FC(is)g(added)e(to)i(the)g(beginning)h(of)f(the)g(list.)573 +4699 y(Neither)16 b(function)h(destr)o(uctively)f(alters)f(the)h +(original)h(path-list.)24 b(The)16 b(r)o(esult)g(may)573 +4799 y(shar)o(e)k(str)o(uctur)o(e)h(with)h(the)f(original)h(list.)28 +b(Both)21 b(functions)h(use)g Fy(equal?)c FC(for)j(com-)573 +4898 y(paring)f(elements.)1756 5147 y(75)p eop +%%Page: 76 82 +76 81 bop 681 614 a FA(3.1)m(1.2)80 b Fy($USER)p FA(,)19 +b Fy($HOME)p FA(,)f(and)i Fy($PATH)681 797 y FC(Like)25 +b(sh)i(and)e(unlike)h(csh,)h(scsh)g(has)e FB(no)h FC(interactive)f +(dependencies)g(on)h(envir)o(onment)681 897 y(variables.)56 +b(It)31 b(does,)j(however)-6 b(,)34 b(initialise)e(certain)f(internal)g +(values)g(at)g(startup)g(time)681 997 y(fr)o(om)39 b(the)g(initial)h +(pr)o(ocess)e(envir)o(onment,)45 b(in)39 b(particular)f +Fy($HOME)f FC(and)i Fy($PATH)p FC(.)e(Scsh)681 1096 y(never)23 +b(uses)h Fy($USER)d FC(at)i(all.)34 b(It)24 b(computes)g +Fy(\(user-login-nam)o(e\))17 b FC(fr)o(om)23 b(the)h(system)g(call)681 +1196 y Fy(\(user-uid\))p FC(.)681 1344 y Fy(home-directory)2045 +b FB(string)681 1444 y Fy(exec-path-list)1914 b FB(string)20 +b FC(list)888 1584 y(Scsh)29 b(accesses)e Fy($HOME)g +FC(at)h(start-up)f(time,)k(and)d(stor)o(es)g(the)h(value)e(in)i(the)g +(global)888 1683 y(variable)19 b Fy(home-directory)p +FC(.)h(It)g(uses)h(this)g(value)e(for)h Fy(~)g FC(lookups)h(and)f(for)g +(r)o(eturn-)888 1783 y(ing)i(to)f(home)g(on)h Fy(\(chdir\))p +FC(.)888 1915 y(Scsh)g(accesses)f Fy($PATH)f FC(at)h(start-up)g(time,)h +(colon-splits)h(the)e(path)h(list,)g(and)f(stor)o(es)888 +2015 y(the)33 b(value)f(in)h(the)g(global)f(variable)g +Fy(exec-path-list)p FC(.)55 b(This)33 b(list)g(is)g(used)f(for)888 +2115 y Fy(exec-path)17 b FC(and)k Fy(exec-path/env)15 +b FC(sear)o(ches.)681 2408 y Fw(3.12)99 b(T)-11 b(erminal)24 +b(device)h(control)681 2622 y FC(Scsh)g(pr)o(ovides)f(a)h(complete)g +(set)g(of)g(r)o(outines)h(for)f(manipulating)g(terminal)h(devices\227) +681 2721 y(putting)f(them)f(in)h(\223raw\224)e(mode,)i(changing)g(and)e +(querying)j(their)e(special)g(characters,)681 2821 y(modifying)i(their) +f(i/o)i(speeds,)e(and)g(so)h(forth.)39 b(The)26 b(scsh)f(interface)g +(is)g(designed)g(both)681 2921 y(for)34 b(generality)g(and)g +(portability)g(acr)o(oss)g(dif)o(fer)o(ent)e(Unix)i(platforms,)j(so)e +(you)g(don't)681 3020 y(have)29 b(to)h(r)o(ewrite)e(your)i(pr)o(ogram)f +(each)g(time)g(you)h(move)g(to)g(a)f(new)h(system.)52 +b(W)-8 b(e've)681 3120 y(also)30 b(made)f(an)h(ef)o(fort)f(to)h(use)g +(r)o(easonable,)h(Scheme-like)f(names)g(for)f(the)i(multitudi-)681 +3219 y(nous)g(named)e(constants)i(involved,)i(so)d(when)h(you)f(ar)o(e) +f(r)o(eading)g(code,)j(you'll)f(have)681 3319 y(less)26 +b(likelihood)i(of)e(getting)h(lost)f(in)h(a)f(bewildering)g(maze)f(of)h +(obfuscatory)g(constants)681 3419 y(named)20 b Fy(ICRNL)p +FC(,)f Fy(INPCK)p FC(,)f Fy(IUCLC)p FC(,)g(and)j Fy(ONOCR)p +FC(.)805 3543 y(This)k(section)g(can)f(only)i(lay)e(out)h(the)f(basic)g +(functionality)i(of)e(the)g(terminal)h(device)681 3643 +y(interface.)36 b(For)25 b(further)f(details,)h(see)g(the)f +(termios\(3\))h(man)f(page)g(on)i(your)f(system,)h(or)681 +3742 y(consult)c(one)f(of)f(the)h(standar)o(d)e(Unix)i(texts.)681 +3993 y FA(3.12.1)80 b(Portability)19 b(across)h(OS)h(variants)681 +4176 y FC(T)-8 b(erminal-contr)o(ol)28 b(softwar)o(e)f(is)i +(inescapably)e(complex,)j(ugly)-9 b(,)30 b(and)e(low-level.)47 +b(Unix)681 4276 y(variants)25 b(each)h(pr)o(ovide)f(their)h(own)h(way)f +(of)g(contr)o(olling)h(terminal)f(devices,)g(making)681 +4375 y(it)19 b(dif)o(\002cult)g(to)h(pr)o(ovide)f(interfaces)f(that)i +(ar)o(e)e(portable)h(acr)o(oss)g(dif)o(fer)o(ent)e(Unix)i(systems.)681 +4475 y(Scsh's)27 b(terminal)g(support)g(is)h(based)e(primarily)h(upon)g +(the)i(P)t Ft(O)t(S)t(I)t(X)i FC(termios)c(interface.)681 +4575 y(Pr)o(ograms)i(that)g(can)h(be)f(written)h(using)g(only)g(the)i +(P)t Ft(O)t(S)t(I)t(X)h FC(interface)28 b(ar)o(e)g(likely)i(to)g(be)681 +4674 y(widely)21 b(portable.)805 4799 y(The)f(bulk)g(of)g(the)g +(documentation)h(that)e(follows)i(consists)g(of)f(several)f(pages)g +(worth)681 4898 y(of)25 b(tables)h(de\002ning)g(dif)o(fer)o(ent)d +(named)j(constants)g(that)g(enable)f(and)g(disable)g(dif)o(fer)o(ent) +2071 5147 y(76)p eop +%%Page: 77 83 +77 82 bop 365 614 a FC(featur)o(es)20 b(of)i(the)g(terminal)g(driver)-6 +b(.)28 b(Some)21 b(of)h(these)g(\003ags)g(ar)o(e)h(P)t +Ft(O)t(S)t(I)t(X)r FC(;)g(others)f(ar)o(e)f(taken)365 +714 y(fr)o(om)c(the)h(two)g(common)h(branches)f(of)f(Unix)h +(development,)g(SVR4)f(and)g(4.3+)g(Berkeley)-9 b(.)365 +814 y(Scsh)21 b(guarantees)f(that)h(the)g(non-)r(P)t +Ft(O)t(S)t(I)t(X)j FC(constants)e(will)f(be)g(bound)g(identi\002ers.) +490 988 y Fu(\017)41 b FC(If)22 b(your)g(OS)h(supports)f(a)g +(particular)f(non-)r(P)t Ft(O)t(S)t(I)t(X)27 b FC(\003ag,)22 +b(its)h(named)f(constant)h(will)573 1087 y(be)d(bound)h(to)h(the)e +(\003ag's)i(value.)490 1245 y Fu(\017)41 b FC(If)26 b(your)g(OS)g +(doesn't)h(support)f(the)g(\003ag,)i(its)e(named)g(constant)h(will)g +(be)e(pr)o(esent,)573 1344 y(but)c(bound)g(to)g Fy(#f)p +FC(.)365 1518 y(This)30 b(means)e(that)h(if)f(you)i(want)e(to)i(use)e +(SVR4)g(or)h(Berkeley)f(featur)o(es)f(in)i(a)g(pr)o(ogram,)365 +1618 y(your)23 b(pr)o(ogram)e(can)h(portably)g(test)h(the)f(values)g +(of)g(the)g(\003ags)h(befor)o(e)e(using)i(them\227the)365 +1718 y(\003ags)30 b(can)e(r)o(eliably)g(be)h(r)o(efer)o(enced)d +(without)k(pr)o(oducing)f(OS-dependent)e(\223unbound)365 +1817 y(variable\224)19 b(err)o(ors.)490 1942 y(Finally)-9 +b(,)18 b(note)h(that)f(although)j(P)t Ft(O)t(S)t(I)t(X)r +FC(,)e(SVR4,)f(and)f(Berkeley)h(cover)f(the)h(lion's)h(shar)o(e)365 +2041 y(of)i(the)g(terminal-driver)f(functionality)-9 +b(,)21 b(each)f(operating)h(system)g(inevitably)g(has)g(non-)365 +2141 y(standar)o(d)34 b(extensions.)71 b(While)36 b(a)f(particular)f +(scsh)i(implementation)h(may)e(pr)o(ovide)365 2241 y(these)21 +b(extensions,)h(they)f(ar)o(e)e(not)j(portable,)d(and)i(so)g(ar)o(e)e +(not)j(documented)f(her)o(e.)365 2488 y FA(3.12.2)81 +b(Miscellaneous)17 b(procedures)365 2687 y Fy(\(tty?)42 +b FB(fd/port)p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(boolean)1399 +b FC(pr)o(ocedur)o(e)573 2807 y(Return)21 b(tr)o(ue)g(if)f(the)h(ar)o +(gument)g(is)g(a)f(tty)-9 b(.)365 2986 y Fy(\(tty-file-name)38 +b FB(fd/port)p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(string)1054 +b FC(pr)o(ocedur)o(e)573 3118 y(The)24 b(ar)o(gument)f +FB(fd/port)f FC(must)j(be)e(a)h(\002le)g(descriptor)f(or)h(port)g(open) +g(on)h(a)e(tty)-9 b(.)35 b(Re-)573 3218 y(turn)21 b(the)g(\002le-name)f +(of)h(the)g(tty)-9 b(.)365 3477 y FA(3.12.3)81 b(The)20 +b(tty-info)g(record)h(type)365 3660 y FC(The)36 b(primary)e(data-str)o +(uctur)o(e)g(that)h(describes)g(a)f(terminal's)i(mode)f(is)h(a)f +Fy(tty-info)365 3760 y FC(r)o(ecor)o(d,)19 b(de\002ned)h(as)h(follows:) +573 3934 y Fy(\(define-record)38 b(tty-info)660 4033 +y(control-chars)82 b(;)43 b(String:)e(Magic)g(input)h(chars)660 +4133 y(input-flags)170 b(;)43 b(Int:)f(Input)f(processing)660 +4233 y(output-flags)126 b(;)43 b(Int:)f(Output)f(processing)660 +4332 y(control-flags)82 b(;)43 b(Int:)f(Serial-line)d(control)660 +4432 y(local-flags)170 b(;)43 b(Int:)f(Line-editting)c(UI)660 +4532 y(input-speed)170 b(;)43 b(Int:)f(Code)g(for)g(input)g(speed)660 +4631 y(output-speed)126 b(;)43 b(Int:)f(Code)g(for)g(output)f(speed)660 +4731 y(min)522 b(;)43 b(Int:)f(Raw-mode)e(input)i(policy)660 +4830 y(time\))434 b(;)43 b(Int:)f(Raw-mode)e(input)i(policy)1756 +5147 y FC(77)p eop +%%Page: 78 84 +78 83 bop 681 614 a FA(The)20 b(control-characters)e(string)681 +822 y FC(The)h Fy(control-chars)13 b FC(\002eld)19 b(is)g(a)f +(character)g(string;)i(its)f(characters)e(may)i(be)g(indexed)f(by)681 +921 y(integer)j(values)f(taken)h(fr)o(om)f(table)g(3.4.)805 +1064 y(As)28 b(discussed)f(above,)i(only)g(the)g(P)t +Ft(O)t(S)t(I)t(X)j FC(entries)27 b(in)h(table)g(3.4)e(ar)o(e)g +(guaranteed)h(to)681 1164 y(be)d(legal,)h(integer)f(indices.)37 +b(A)23 b(pr)o(ogram)h(can)g(r)o(eliably)g(test)g(the)h(OS)f(to)h(see)f +(if)g(the)g(non-)683 1263 y(P)t Ft(O)t(S)t(I)t(X)e FC(characters)17 +b(ar)o(e)h(supported)g(by)h(checking)g(the)g(index)f(constants.)26 +b(If)18 b(the)h(contr)o(ol-)681 1363 y(character)g(function)i(is)g +(supported)g(by)f(the)h(terminal)g(driver)-6 b(,)19 b(then)i(the)g +(corr)o(esponding)681 1463 y(index)c(will)h(be)e(bound)i(to)g(an)e +(integer;)j(if)e(it)g(is)g(not)h(supported,)g(the)f(index)g(will)h(be)f +(bound)681 1562 y(to)k Fy(#f)p FC(.)805 1705 y(T)-8 b(o)58 +b(disable)f(a)g(given)h(contr)o(ol-character)e(function,)67 +b(set)57 b(its)h(corr)o(esponding)681 1805 y(entry)67 +b(in)g(the)g Fy(tty-info:contro)o(l-)o(cha)o(rs)60 b +FC(string)67 b(to)h(the)e(special)h(character)681 1905 +y Fy(disable-tty-char)21 b FC(\(and)27 b(then)h(use)g(the)f +Fy(\(set-tty-info)39 b FB(fd/port)j(info)p Fy(\))27 b +FC(pr)o(ocedur)o(e)681 2004 y(to)21 b(update)f(the)h(terminal's)g +(state\).)681 2303 y FA(The)f(\003ag)g(\002elds)681 2510 +y FC(The)48 b Fy(tty-info)d FC(r)o(ecor)o(d's)i Fy(input-flags)p +FC(,)k Fy(output-flags)p FC(,)f Fy(control-flags)p FC(,)f(and)681 +2610 y Fy(local-flags)22 b FC(\002elds)k(ar)o(e)g(all)g(bit)h(sets)f(r) +o(epr)o(esented)f(as)h(two's-complement)i(integers.)681 +2709 y(Their)i(values)f(ar)o(e)g(composed)i(by)f(or)6 +b('ing)31 b(together)f(values)g(taken)g(fr)o(om)f(the)h(named)681 +2809 y(constants)21 b(listed)g(in)g(tables)g(3.5)e(thr)o(ough)j(3.9.) +805 2952 y(As)j(discussed)h(above,)f(only)h(the)i(P)t +Ft(O)t(S)t(I)t(X)h FC(entries)c(listed)g(in)h(these)g(tables)e(ar)o(e)g +(guar)o(-)681 3052 y(anteed)17 b(to)i(be)e(legal,)i(integer)f(\003ag)g +(values.)24 b(A)18 b(pr)o(ogram)f(can)h(r)o(eliably)f(test)i(the)f(OS)g +(to)g(see)681 3151 y(if)25 b(the)g(non-)r(P)t Ft(O)t(S)t(I)t(X)k +FC(\003ags)c(ar)o(e)e(supported)i(by)g(checking)h(the)f(named)f +(constants.)39 b(If)25 b(the)681 3251 y(featur)o(e)17 +b(is)i(supported)g(by)g(the)g(terminal)g(driver)-6 b(,)19 +b(then)g(the)g(corr)o(esponding)g(\003ag)h(will)f(be)681 +3350 y(bound)i(to)g(an)g(integer;)f(if)h(it)g(is)g(not)g(supported,)g +(the)f(\003ag)h(will)h(be)e(bound)h(to)g Fy(#f)p FC(.)681 +3649 y FA(The)f(speed)f(\002elds)681 3856 y FC(The)26 +b Fy(input-speed)c FC(and)27 b Fy(output-speed)21 b FC(\002elds)27 +b(determine)f(the)h(I/O)g(rate)f(of)g(the)h(ter)o(-)681 +3956 y(minal's)20 b(line.)25 b(The)20 b(value)f(of)g(these)h(\002elds)f +(is)h(an)f(integer)h(giving)g(the)g(speed)f(in)g(bits-per)o(-)681 +4055 y(second.)25 b(The)c(following)h(speeds)f(ar)o(e)e(supported)i(by) +h(P)t Ft(O)t(S)t(I)t(X)r FC(:)1733 4279 y(0)99 b(134)140 +b(600)f(4800)1691 4379 y(50)99 b(150)f(1200)139 b(9600)1691 +4478 y(75)99 b(200)f(1800)g(19200)1654 4578 y(1)-5 b(10)99 +b(300)f(2400)g(38400)681 4799 y(Y)-8 b(our)27 b(OS)f(may)g(accept)g +(others;)j(it)d(may)g(also)h(allow)g(the)f(special)g(symbols)h +Fy('exta)d FC(and)681 4898 y Fy('extb)p FC(.)2071 5147 +y(78)p eop +%%Page: 79 85 +79 84 bop 365 614 a FA(The)21 b(min)f(and)f(time)h(\002elds)365 +807 y FC(The)31 b(integer)f Fy(min)f FC(and)h Fy(time)e +FC(\002elds)i(determine)g(input)h(blocking)g(behaviour)f(during)365 +907 y(non-canonical)19 b(\(raw\))e(input;)i(otherwise,)h(they)e(ar)o(e) +f(ignor)o(ed.)24 b(See)17 b(the)i(termios\(3\))e(man)365 +1006 y(page)j(for)h(further)f(details.)490 1138 y(Be)29 +b(warned)f(that)k(P)t Ft(O)t(S)t(I)t(X)g FC(allows)e(the)g(base)f +(system)h(call's)f(r)o(epr)o(esentation)f(of)h(the)365 +1238 y Fy(tty-info)14 b FC(r)o(ecor)o(d)h(to)i(shar)o(e)e(storage)i +(for)f(the)h Fy(min)f FC(\002eld)g(and)g(the)h Fy(ttychar/eof)12 +b FC(element)365 1337 y(of)32 b(the)f(contr)o(ol-characters)f(string,)k +(and)d(for)g(the)h Fy(time)e FC(\002eld)h(and)g(the)g +Fy(ttychar/eol)365 1437 y FC(element)20 b(of)f(the)g(contr)o +(ol-characters)f(string.)26 b(Many)18 b(implementations)j(in)f(fact)e +(do)h(this.)490 1569 y(T)-8 b(o)19 b(stay)g(out)g(of)g(tr)o(ouble,)f +(set)h(the)g Fy(min)f FC(and)g Fy(time)f FC(\002elds)i(only)h(if)e(you) +i(ar)o(e)d(putting)i(the)365 1669 y(terminal)25 b(into)h(raw)f(mode;)i +(set)e(the)g(eof)f(and)h(eol)g(contr)o(ol-characters)f(only)i(if)e(you) +i(ar)o(e)365 1768 y(putting)c(the)f(terminal)g(into)g(canonical)g +(mode.)26 b(It's)21 b(ugly)-9 b(,)20 b(but)h(it's)h(Unix.)365 +2038 y FA(3.12.4)81 b(Using)20 b(tty-info)f(records)365 +2253 y Fy(\(make-tty-info)38 b FB(if)16 b(of)g(cf)f(lf)h(ispeed)g +(ospeed)g(min)f(time)p Fy(\))43 b Fu(\000)-14 b(!)43 +b FB(tty-info-r)o(ecord)85 b FC(pr)o(ocedur)o(e)365 2353 +y Fy(\(copy-tty-info)38 b FB(tty-info-r)o(ecord)p Fy(\))85 +b Fu(\000)-15 b(!)88 b FB(tty-info-r)o(ecord)504 b FC(pr)o(ocedur)o(e) +573 2480 y(These)24 b(pr)o(ocedur)o(es)f(make)h(it)h(possible)g(to)f +(cr)o(eate)f(new)i Fy(tty-info)c FC(r)o(ecor)o(ds.)35 +b(The)573 2579 y(typical)18 b(method)g(for)g(cr)o(eating)f(a)g(new)i(r) +o(ecor)o(d)d(is)i(to)h(copy)f(one)g(r)o(etrieved)e(by)i(a)g(call)573 +2679 y(to)27 b(the)f Fy(tty-info)d FC(pr)o(ocedur)o(e,)i(then)i(modify) +g(the)f(copy)h(as)f(desir)o(ed.)40 b(Note)27 b(that)573 +2779 y(the)32 b Fy(make-tty-info)26 b FC(pr)o(ocedur)o(e)k(does)i(not)g +(take)f(a)h(parameter)e(to)i(de\002ne)f(the)573 2878 +y(new)d(r)o(ecor)o(d's)e(contr)o(ol)h(characters.)1759 +2848 y Fv(4)1841 2878 y FC(Instead,)h(it)g(simply)g(r)o(eturns)f(a)g +Fy(tty-info)573 2978 y FC(r)o(ecor)o(d)16 b(whose)i(contr)o +(ol-character)e(string)i(has)f(all)g(elements)h(initialised)g(to)i(A)t +Ft(S)t(C)t(I)t(I)573 3078 y FC(nul.)77 b(Y)-8 b(ou)38 +b(may)g(then)g(install)g(the)g(special)f(characters)g(by)h(assigning)g +(to)g(the)573 3177 y(string.)43 b(Similarly)-9 b(,)27 +b(the)g(contr)o(ol-character)d(string)k(in)e(the)h(r)o(ecor)o(d)d(pr)o +(oduced)h(by)573 3277 y Fy(copy-tty-info)16 b FC(does)22 +b(not)g(shar)o(e)f(str)o(uctur)o(e)g(with)i(the)f(string)g(in)g(the)g +(r)o(ecor)o(d)e(be-)573 3376 y(ing)h(copied,)f(so)i(you)f(may)g(mutate) +f(it)h(fr)o(eely)-9 b(.)365 3582 y Fy(\(tty-info)40 b +FB(fd/port)p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(tty-info-r)o(ecord)984 +b FC(pr)o(ocedur)o(e)573 3728 y(The)32 b FB(fd/port)f +FC(parameter)g(is)i(an)f(integer)h(\002le)g(descriptor)f(or)g(Scheme)g +(I/O)h(port)573 3828 y(opened)24 b(on)h(a)e(terminal)i(device.)35 +b(This)25 b(pr)o(ocedur)o(e)d(r)o(eturns)i(a)f Fy(tty-info)e +FC(r)o(ecor)o(d)573 3927 y(describing)g(the)g(terminal's)g(curr)o(ent)f +(mode.)365 4133 y Fy(\(set-tty-info/now)37 b FB(fd/port)19 +b(info)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(no-value)685 +b FC(pr)o(ocedur)o(e)365 4233 y Fy(\(set-tty-info/dra)o(in)37 +b FB(fd/port)19 b(info)p Fy(\))87 b Fu(\000)-14 b(!)87 +b FB(no-value)598 b FC(pr)o(ocedur)o(e)365 4332 y Fy +(\(set-tty-info/flu)o(sh)37 b FB(fd/port)19 b(info)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(no-value)598 b FC(pr)o(ocedur)o(e) +573 4478 y(The)32 b FB(fd/port)f FC(parameter)g(is)i(an)f(integer)h +(\002le)g(descriptor)f(or)g(Scheme)g(I/O)h(port)573 4578 +y(opened)d(on)g(a)g(terminal)g(device.)52 b(The)30 b(pr)o(ocedur)o(e)e +(chosen)j(determines)f(when)573 4678 y(and)20 b(how)i(the)f(terminal's) +g(mode)g(is)g(alter)o(ed:)p 365 4742 1146 4 v 450 4796 +a Fq(4)485 4819 y Ft(Why?)i(Because)17 b(the)f(length)h(of)g(the)g +(string)g(varies)g(fr)o(om)h(Unix)f(to)g(Unix.)22 b(For)c(example,)f +(the)f(wor)o(d-erase)365 4898 y(contr)o(ol)i(character)f(\(typically)h +(contr)o(ol-w\))g(is)f(pr)o(ovided)f(by)g(most)g(Unixes,)g(but)g(not)h +(part)f(of)h(the)h(P)t Fp(O)t(S)t(I)t(X)d Ft(spec.)1756 +5147 y FC(79)p eop +%%Page: 80 86 +80 85 bop 1004 535 2425 4 v 1004 634 4 100 v 1057 604 +a FC(Pr)o(ocedur)o(e)508 b(Meaning)p 3426 634 V 1004 +638 2425 4 v 1004 654 V 1004 754 4 100 v 1057 724 a Fy +(set-tty-info/now)181 b FC(Make)19 b(change)i(immediately)-9 +b(.)p 3426 754 V 1004 853 V 1057 824 a Fy(set-tty-info/drai)o(n)94 +b FC(Drain)20 b(output,)h(then)h(change.)p 3426 853 V +1004 953 V 1057 923 a Fy(set-tty-info/flus)o(h)94 b FC(Drain)20 +b(output,)h(\003ush)h(input,)f(then)g(change.)p 3426 +953 V 1004 956 2425 4 v 681 1261 a FA(3.12.5)80 b(Other)20 +b(terminal-device)d(procedures)681 1492 y Fy(\(send-tty-break)37 +b FB(fd/port)19 b([duration])p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(no-value)555 b FC(pr)o(ocedur)o(e)888 1624 +y(Send)34 b(a)g(br)o(eak)e(signal)j(on)g(the)f(terminal)g(associated)g +(with)h(\002le)f(descriptor)g(or)888 1724 y(Scheme)18 +b(I/O)h(port)f FB(fd/port)o FC(.)24 b(A)18 b(br)o(eak)f(signal)i(is)g +(a)e(sequence)i(of)f(continuous)i(zer)o(os)888 1823 y(on)i(the)f +(terminal's)g(transmission)h(line.)888 1972 y(The)h FB(duration)f +FC(ar)o(gument)f(determines)i(the)f(length)h(of)g(the)f(br)o(eak)f +(signal.)31 b(A)22 b(zer)o(o)888 2071 y(value)i(\(the)g(default\))f +(causes)h(a)g(br)o(eak)f(of)h(between)g(0.25)f(and)h(0.5)f(seconds)i +(to)f(be)888 2171 y(sent;)d(other)f(values)f(determine)h(a)f(period)h +(in)g(a)f(manner)h(that)g(will)g(depend)f(upon)888 2271 +y(local)i(community)h(standar)o(ds.)681 2509 y Fy(\(drain-tty)39 +b FB(fd/port)p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(no-value)1140 +b FC(pr)o(ocedur)o(e)888 2666 y(This)27 b(pr)o(ocedur)o(e)e(waits)i +(until)g(all)g(the)f(output)h(written)g(to)g(the)g(terminal)g(device) +888 2765 y(has)37 b(been)g(transmitted)g(to)g(the)g(device.)73 +b(If)36 b FB(fd/port)f FC(is)i(an)g(output)g(port)g(with)888 +2865 y(buf)o(fer)o(ed)19 b(I/O)j(enabled,)f(then)g(the)h(port's)g(buf)o +(fer)o(ed)d(characters)h(ar)o(e)g(\003ushed)i(be-)888 +2965 y(for)o(e)e(waiting)h(for)g(the)g(device)f(to)h(drain.)681 +3203 y Fy(\(flush-tty/input)37 b FB(fd/port)p Fy(\))85 +b Fu(\000)-14 b(!)87 b FB(no-value)878 b FC(pr)o(ocedur)o(e)681 +3302 y Fy(\(flush-tty/outpu)o(t)37 b FB(fd/port)p Fy(\))86 +b Fu(\000)-15 b(!)87 b FB(no-value)835 b FC(pr)o(ocedur)o(e)681 +3402 y Fy(\(flush-tty/both)37 b FB(fd/port)p Fy(\))85 +b Fu(\000)-14 b(!)87 b FB(no-value)922 b FC(pr)o(ocedur)o(e)888 +3559 y(These)33 b(pr)o(ocedur)o(es)e(discar)o(d)h(the)h(unr)o(ead)f +(input)h(chars)g(or)g(unwritten)h(output)888 3658 y(chars)21 +b(in)g(the)g(tty's)g(kernel)g(buf)o(fers.)681 3897 y +Fy(\(start-tty-outpu)o(t)37 b FB(fd/port)p Fy(\))86 b +Fu(\000)-15 b(!)87 b FB(no-value)835 b FC(pr)o(ocedur)o(e)681 +3996 y Fy(\(stop-tty-output)37 b FB(fd/port)p Fy(\))85 +b Fu(\000)-14 b(!)87 b FB(no-value)878 b FC(pr)o(ocedur)o(e)681 +4096 y Fy(\(start-tty-input)37 b FB(fd/port)p Fy(\))85 +b Fu(\000)-14 b(!)87 b FB(no-value)878 b FC(pr)o(ocedur)o(e)681 +4195 y Fy(\(stop-tty-input)37 b FB(fd/port)p Fy(\))85 +b Fu(\000)-14 b(!)87 b FB(no-value)922 b FC(pr)o(ocedur)o(e)888 +4352 y(These)38 b(pr)o(ocedur)o(es)e(can)h(be)g(used)g(to)h(contr)o(ol) +g(a)f(terminal's)h(input)g(and)f(out-)888 4452 y(put)22 +b(\003ow)-8 b(.)31 b(The)23 b Fy(stop-tty-output)15 b +FC(and)22 b Fy(start-tty-output)16 b FC(pr)o(ocedur)o(es)k(sus-)888 +4552 y(pend)28 b(and)f(r)o(esume)h(output)g(fr)o(om)g(a)f(terminal)h +(device.)46 b(The)28 b Fy(stop-tty-input)888 4651 y FC(and)21 +b Fy(start-tty-input)15 b FC(pr)o(ocedur)o(es)20 b(transmit)i(the)f +(special)g(ST)o(OP)g(and)g(ST)-6 b(AR)m(T)888 4751 y(characters)19 +b(to)i(the)f(terminal)g(with)h(the)f(intention)i(of)e(stopping)h(and)f +(starting)g(ter)o(-)888 4850 y(minal)i(input)f(\003ow)-8 +b(.)2071 5147 y(80)p eop +%%Page: 81 87 +81 86 bop 365 614 a FA(3.12.6)81 b(Control)20 b(terminals,)e(sessions,) +h(and)h(terminal)f(process)h(groups)365 813 y Fy(\(open-control-tty)37 +b FB(tty-name)19 b([\003ags])p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(port)678 b FC(pr)o(ocedur)o(e)573 933 y(This)18 +b(pr)o(ocedur)o(e)e(opens)i(terminal)g(device)f FB(tty-name)g +FC(as)g(the)h(pr)o(ocess')g(contr)o(ol)g(ter)o(-)573 +1032 y(minal)j(\(see)g(the)g Fy(termios)d FC(man)k(page)e(for)h(mor)o +(e)g(information)h(on)f(contr)o(ol)h(termi-)573 1132 +y(nals\).)29 b(The)22 b FB(tty-name)e FC(ar)o(gument)i(is)g(a)g +(\002le-name)g(such)g(as)g Fy(/dev/ttya)p FC(.)k(The)c +FB(\003ags)573 1232 y FC(ar)o(gument)29 b(is)g(a)g(value)g(suitable)g +(as)g(the)h(second)f(ar)o(gument)g(to)h(the)f Fy(open-file)573 +1331 y FC(call;)g(it)f(defaults)e(to)h Fy(open/read+write)p +FC(,)22 b(causing)27 b(the)h(terminal)f(to)g(be)g(opened)573 +1431 y(for)20 b(both)i(input)f(and)f(output.)573 1559 +y(The)h(port)g(r)o(eturned)f(is)i(an)e(input)i(port)f(if)g(the)g +FB(\003ags)g FC(permit)h(it,)f(otherwise)h(an)e(out-)573 +1659 y(put)j(port.)33 b(R4RS/Scheme)23 b(48/scsh)h(do)f(not)h(have)f +(input/output)h(ports,)g(so)g(it's)573 1758 y(one)i(or)f(the)h(other)-6 +b(.)40 b(However)-6 b(,)26 b(you)g(can)f(get)g(both)h(r)o(ead)e(and)h +(write)h(ports)f(open)573 1858 y(on)e(a)e(terminal)h(by)h(opening)g(it) +f(r)o(ead/write,)f(taking)h(the)g(r)o(esult)g(input)h(port,)f(and)573 +1958 y(duping)f(it)g(to)g(an)g(output)g(port)g(with)g +Fy(dup->outport)p FC(.)573 2086 y(This)d(pr)o(ocedur)o(e)e(guarantees)h +(to)h(make)g(the)g(opened)f(terminal)h(the)g(pr)o(ocess')f(con-)573 +2185 y(tr)o(ol)29 b(terminal)g(only)h(if)f(the)h(pr)o(ocess)e(does)h +(not)h(have)f(an)g(assigned)g(contr)o(ol)h(ter)o(-)573 +2285 y(minal)h(at)g(the)g(time)h(of)f(the)g(call.)57 +b(If)30 b(the)i(scsh)f(pr)o(ocess)g(alr)o(eady)e(has)j(a)e(contr)o(ol) +573 2385 y(terminal,)20 b(the)h(r)o(esults)g(ar)o(e)e(unde\002ned.)573 +2513 y(T)-8 b(o)19 b(arrange)e(for)i(the)f(pr)o(ocess)h(to)g(have)f(no) +h(contr)o(ol)g(terminal)f(prior)h(to)g(calling)g(this)573 +2613 y(pr)o(ocedur)o(e,)f(use)j(the)g Fy(become-session-l)o(ead)o(er)14 +b FC(pr)o(ocedur)o(e.)365 2790 y Fy(\(become-session-l)o(ea)o(der)o(\)) +81 b Fu(\000)-14 b(!)87 b FB(integer)944 b FC(pr)o(ocedur)o(e)573 +2921 y(This)20 b(is)g(the)g(C)g Fy(setsid\(\))c FC(call.)27 +b(P)t Ft(O)t(S)t(I)t(X)c FC(job-contr)o(ol)d(has)g(a)f(thr)o(ee-level)g +(hierar)o(chy:)573 3021 y(session/pr)o(ocess-gr)o(oup/pr)o(ocess.)31 +b(Every)22 b(session)i(has)f(an)f(associated)g(contr)o(ol)573 +3121 y(terminal.)59 b(This)32 b(pr)o(ocedur)o(e)e(places)h(the)h(curr)o +(ent)g(pr)o(ocess)f(into)i(a)e(brand)g(new)573 3220 y(session,)f(and)e +(disassociates)g(the)g(pr)o(ocess)f(fr)o(om)g(any)h(pr)o(evious)g +(contr)o(ol)g(termi-)573 3320 y(nal.)d(Y)-8 b(ou)20 b(may)e +(subsequently)i(use)f Fy(open-control-tty)12 b FC(to)20 +b(open)f(a)f(new)h(contr)o(ol)573 3420 y(terminal.)573 +3548 y(It)34 b(is)h(an)f(err)o(or)f(to)i(call)e(this)i(pr)o(ocedur)o(e) +e(if)h(the)g(curr)o(ent)f(pr)o(ocess)h(is)h(alr)o(eady)d(a)573 +3647 y(pr)o(ocess-gr)o(oup)18 b(leader)-6 b(.)24 b(One)c(way)g(to)g +(guarantee)e(this)j(is)f(not)g(the)g(case)f(is)h(only)g(to)573 +3747 y(call)g(this)i(pr)o(ocedur)o(e)d(after)g(forking.)365 +3924 y Fy(\(tty-process-grou)o(p)37 b FB(fd/port)p Fy(\))86 +b Fu(\000)-15 b(!)88 b FB(integer)847 b FC(pr)o(ocedur)o(e)365 +4024 y Fy(\(set-tty-process-)o(gr)o(oup)37 b FB(fd/port)19 +b(pgrp)p Fy(\))86 b Fu(\000)-15 b(!)88 b FB(unde\002ned)400 +b FC(pr)o(ocedur)o(e)573 4156 y(This)22 b(pair)g(of)f(pr)o(ocedur)o(es) +g(gets)h(and)f(sets)h(the)g(pr)o(ocess)g(gr)o(oup)f(of)h(a)g(given)g +(termi-)573 4255 y(nal.)365 4432 y Fy(\(control-tty-file)o(-n)o(ame)o +(\))81 b Fu(\000)-14 b(!)87 b FB(string)976 b FC(pr)o(ocedur)o(e)573 +4564 y(Return)20 b(the)g(\002le-name)g(of)g(the)g(pr)o(ocess')f(contr)o +(ol)h(tty)-9 b(.)26 b(On)20 b(every)f(version)i(of)f(Unix)573 +4664 y(of)j(which)h(we)f(ar)o(e)f(awar)o(e,)f(this)j(is)g(just)f(the)h +(string)f Fy("/dev/tty")p FC(.)29 b(However)-6 b(,)23 +b(this)573 4763 y(pr)o(ocedur)o(e)15 b(uses)j(the)f(of)o(\002cial)g +(Posix)h(interface,)f(so)h(it)f(is)h(mor)o(e)f(portable)g(than)g(sim-) +573 4863 y(ply)k(using)g(a)g(constant)g(string.)1756 +5147 y(81)p eop +%%Page: 82 88 +82 87 bop 681 614 a FA(3.12.7)80 b(Pseudo-terminals)681 +797 y FC(Scsh)21 b(implements)g(an)g(interface)e(to)j(Berkeley-style)e +(pseudo-terminals.)681 946 y Fy(\(fork-pty-sessio)o(n)37 +b FB(thunk)p Fy(\))65 b Fu(\000)-14 b(!)65 b FB([pr)o(ocess)18 +b(pty-in)f(pty-out)f(tty-name])85 b FC(pr)o(ocedur)o(e)888 +1086 y(This)54 b(pr)o(ocedur)o(e)d(gives)j(a)f(convenient)h(high-level) +g(interface)e(to)h(pseudo-)888 1186 y(terminals.)59 b(It)32 +b(\002rst)g(allocates)f(a)g(pty/tty)i(pair)e(of)h(devices,)h(and)e +(then)i(forks)f(a)888 1285 y(child)21 b(to)g(execute)f(pr)o(ocedur)o(e) +f FB(thunk)o FC(.)26 b(In)21 b(the)g(child)g(pr)o(ocess)988 +1451 y Fu(\017)41 b FC(Stdio)21 b(and)f(the)h(curr)o(ent)f(I/O)h(ports) +g(ar)o(e)e(bound)j(to)f(the)g(terminal)f(device.)988 +1582 y Fu(\017)41 b FC(The)29 b(child)g(is)g(placed)e(in)j(its)f(own,)i +(new)e(session)h(\(see)e Fy(become-session-)1071 1682 +y(leader)p FC(\).)988 1814 y Fu(\017)41 b FC(The)20 b(terminal)h +(device)f(becomes)g(the)h(new)f(session's)i(contr)o(olling)g(terminal) +1071 1914 y(\(see)e Fy(open-control-tty)o FC(\).)988 +2046 y Fu(\017)41 b FC(The)21 b Fy(\(error-output-po)o(rt)o(\))15 +b FC(is)21 b(unbuf)o(fer)o(ed.)888 2211 y(The)16 b Fy(fork-pty-session) +10 b FC(pr)o(ocedur)o(e)k(r)o(eturns)h(four)h(values:)23 +b(the)16 b(child's)g(pr)o(ocess)888 2310 y(object,)21 +b(two)g(ports)g(open)g(on)g(the)g(contr)o(olling)h(pty)e(device,)g(and) +g(the)h(name)f(of)h(the)888 2410 y(child's)h(corr)o(esponding)f +(terminal)f(device.)681 2600 y Fy(\(open-pty\))83 b Fu(\000)-14 +b(!)87 b FB(pty-inport)18 b(tty-name)1073 b FC(pr)o(ocedur)o(e)888 +2740 y(This)27 b(pr)o(ocedur)o(e)e(\002nds)h(a)g(fr)o(ee)f(pty/tty)i +(pair)-6 b(,)27 b(and)f(opens)h(the)f(pty)h(device)e(with)888 +2840 y(r)o(ead/write)19 b(access.)24 b(It)c(r)o(eturns)g(a)f(port)h(on) +h(the)f(pty)-9 b(,)19 b(and)h(the)g(name)f(of)h(the)g(corr)o(e-)888 +2939 y(sponding)i(terminal)f(device.)888 3072 y(The)i(port)f(r)o +(eturned)f(is)i(an)f(input)h(port\227Scheme)f(doesn't)h(allow)g +(input/output)888 3171 y(ports.)51 b(However)-6 b(,)31 +b(you)f(can)f(easily)g(use)g Fy(\(dup->outport)39 b FB(pty-inport)m +Fy(\))29 b FC(to)h(pr)o(o-)888 3271 y(duce)20 b(a)f(matching)i(output)g +(port.)k(Y)-8 b(ou)21 b(may)f(wish)h(to)f(turn)h(of)o(f)e(I/O)h(buf)o +(fering)f(for)888 3370 y(this)j(output)f(port.)681 3560 +y Fy(\(pty-name->tty-n)o(am)o(e)38 b FB(pty-name)p Fy(\))84 +b Fu(\000)-14 b(!)87 b FB(tty-name)642 b FC(pr)o(ocedur)o(e)681 +3660 y Fy(\(tty-name->pty-n)o(am)o(e)38 b FB(tty-name)p +Fy(\))85 b Fu(\000)-15 b(!)88 b FB(pty-name)641 b FC(pr)o(ocedur)o(e) +888 3800 y(These)17 b(two)g(pr)o(ocedur)o(es)e(map)h(between)h(corr)o +(esponding)f(terminal)h(and)f(pty)h(con-)888 3900 y(tr)o(oller)k +(names.)k(For)c(example,)1071 4065 y Fy(\(pty-name->tty-n)o(ame)37 +b("/dev/ptyq3"\))h Fn(=)-14 b Fu(\))87 b Fy("/dev/ttyq3")1071 +4164 y(\(tty-name->pty-n)o(ame)37 b("/dev/ttyrc"\))h +Fn(=)-14 b Fu(\))87 b Fy("/dev/ptyrc")1071 4370 y Fl(Remark:)59 +b Fk(This)20 b(is)h(rather)f(Berkeley-speci\002c.)26 +b(SVR4)21 b(ptys)g(ar)o(e)f(rar)o(e)f(enough)1071 4462 +y(that)j(I've)e(no)g(r)o(eal)f(idea)h(if)g(it)g(generalises)e(acr)o +(oss)h(the)i(Unix)f(gap.)27 b(Experts)18 b(ar)o(e)1071 +4553 y(invited)k(to)g(advise.)32 b(Users)21 b(feel)g(fr)o(ee)g(to)h +(not)g(worry\227the)f(pr)o(edominance)h(of)1071 4644 +y(curr)o(ent)c(popular)g(Unix)h(systems)e(use)h(Berkeley)e(ptys.)681 +4850 y Fy(\(make-pty-genera)o(to)o(r\))81 b Fu(\000)-15 +b(!)88 b FB(pr)o(ocedur)o(e)982 b FC(pr)o(ocedur)o(e)2071 +5147 y(82)p eop +%%Page: 83 89 +83 88 bop 573 614 a FC(This)17 b(pr)o(ocedur)o(e)e(r)o(eturns)h(a)g +(generator)g(of)h(candidate)e(pty)i(names.)24 b(Each)16 +b(time)h(the)573 714 y(r)o(eturned)j(pr)o(ocedur)o(e)g(is)i(called,)f +(it)h(pr)o(oduces)f(a)g(new)h(candidate.)27 b(Softwar)o(e)21 +b(that)573 814 y(wishes)f(to)g(sear)o(ch)f(thr)o(ough)h(the)g(set)g(of) +f(available)f(ptys)i(can)g(use)f(a)g(pty)h(generator)573 +913 y(to)28 b(iterate)f(over)g(them.)47 b(After)26 b(pr)o(oducing)i +(all)f(the)h(possible)g(ptys,)i(a)d(generator)573 1013 +y(r)o(eturns)20 b Fy(#f)g FC(every)g(time)h(it)g(is)g(called.)k +(Example:)756 1179 y Fy(\(define)40 b(pg)j(\(make-pty-genera)o(to)o +(r\)\))756 1279 y(\(pg\))e Fn(=)-14 b Fu(\))87 b Fy("/dev/ptyp0")756 +1378 y(\(pg\))41 b Fn(=)-14 b Fu(\))87 b Fy("/dev/ptyp1")1104 +1465 y(.)1104 1498 y(.)1104 1532 y(.)756 1631 y(\(pg\))41 +b Fn(=)-14 b Fu(\))87 b Fy("/dev/ptyqe")756 1731 y(\(pg\))41 +b Fn(=)-14 b Fu(\))87 b Fy("/dev/ptyqf")170 b Fs(\(Last)41 +b(one\))756 1830 y Fy(\(pg\))g Fn(=)-14 b Fu(\))87 b +Fy(#f)756 1930 y(\(pg\))41 b Fn(=)-14 b Fu(\))87 b Fy(#f)1104 +2017 y(.)1104 2050 y(.)1104 2083 y(.)1756 5147 y FC(83)p +eop +%%Page: 84 90 +84 89 bop 1083 1460 2060 4 v 1083 1559 4 100 v 1136 1529 +a FC(Scsh)938 b(C)346 b(T)-7 b(ypical)20 b(char)p 3139 +1559 V 1083 1563 2060 4 v 1083 1579 V 1083 1679 4 100 +v 1138 1649 a(P)t Ft(O)t(S)t(I)t(X)p 3139 1679 V 1083 +1779 V 1136 1749 a Fy(ttychar/delete-ch)o(ar)267 b(ERASE)185 +b FC(del)p 3139 1779 V 1083 1878 V 1136 1848 a Fy(ttychar/delete-li)o +(ne)267 b(KILL)229 b(^U)p 3139 1878 V 1083 1978 V 1136 +1948 a(ttychar/eof)618 b(EOF)273 b(^D)p 3139 1978 V 1083 +2077 V 1136 2048 a(ttychar/eol)618 b(EOL)p 3139 2077 +V 1083 2177 V 1136 2147 a(ttychar/interrupt)354 b(INTR)229 +b(^C)p 3139 2177 V 1083 2277 V 1136 2247 a(ttychar/quit)574 +b(QUIT)229 b(^\\)p 3139 2277 V 1083 2376 V 1136 2346 +a(ttychar/suspend)442 b(SUSP)229 b(^Z)p 3139 2376 V 1083 +2476 V 1136 2446 a(ttychar/start)530 b(START)185 b(^Q)p +3139 2476 V 1083 2576 V 1136 2546 a(ttychar/stop)574 +b(STOP)229 b(^S)p 3139 2576 V 1083 2579 2060 4 v 1083 +2595 V 1083 2695 4 100 v 1136 2665 a FC(SVR4)21 b(and)f(4.3+BSD)p +3139 2695 V 1083 2795 V 1136 2765 a Fy(ttychar/delayed-s)o(us)o(pen)o +(d)93 b(DSUSP)185 b(^Y)p 3139 2795 V 1083 2894 V 1136 +2864 a(ttychar/delete-wo)o(rd)267 b(WERASE)141 b(^W)p +3139 2894 V 1083 2994 V 1136 2964 a(ttychar/discard)442 +b(DISCARD)97 b(^O)p 3139 2994 V 1083 3094 V 1136 3064 +a(ttychar/eol2)574 b(EOL2)p 3139 3094 V 1083 3193 V 1136 +3163 a(ttychar/literal-n)o(ex)o(t)224 b(LNEXT)185 b(^V)p +3139 3193 V 1083 3293 V 1136 3263 a(ttychar/reprint)442 +b(REPRINT)97 b(^R)p 3139 3293 V 1083 3296 2060 4 v 1083 +3313 V 1083 3412 4 100 v 1136 3383 a FC(4.3+BSD)p 3139 +3412 V 1083 3512 V 1136 3482 a Fy(ttychar/status)486 +b(STATUS)141 b(^T)p 3139 3512 V 1083 3515 2060 4 v 681 +3751 a FC(T)-8 b(able)23 b(3.4:)29 b(Indices)23 b(into)i(the)e +Fy(tty-info)d FC(r)o(ecor)o(d's)i FB(contr)o(ol-chars)g +FC(string,)i(and)f(the)g(char)o(-)681 3850 y(acter)f(traditionally)i +(found)g(at)f(each)g(index.)34 b(Only)25 b(the)f(indices)g(for)f(the)j +(P)t Ft(O)t(S)t(I)t(X)h FC(entries)681 3950 y(ar)o(e)19 +b(guaranteed)h(to)h(be)f(non-)p Fy(#f)p FC(.)2071 5147 +y(84)p eop +%%Page: 85 91 +85 90 bop 383 558 2830 4 v 383 650 4 92 v 436 622 a Fk(Scsh)1090 +b(C)321 b(Meaning)p 3209 650 V 383 653 2830 4 v 383 670 +V 383 761 4 92 v 438 733 a(P)t Fg(O)t(S)t(I)t(X)p 3209 +761 V 383 852 V 436 825 a Fh(ttyin/check-parity)535 b(INPCK)179 +b Fk(Check)19 b(parity)-8 b(.)p 3209 852 V 383 944 V +436 916 a Fh(ttyin/ignore-bad-parity-chars)106 b(IGNPAR)140 +b Fk(Ignor)o(e)18 b(chars)h(with)g(parity)g(err)o(ors.)p +3209 944 V 383 1035 V 436 1007 a Fh(ttyin/mark-parity-errors)301 +b(PARMRK)140 b Fk(Insert)19 b(chars)g(to)g(mark)f(parity)g(err)o(ors.)p +3209 1035 V 383 1126 V 436 1099 a Fh(ttyin/ignore-break)535 +b(IGNBRK)140 b Fk(Ignor)o(e)18 b(br)o(eaks.)p 3209 1126 +V 383 1217 V 436 1190 a Fh(ttyin/interrupt-on-break)301 +b(BRKINT)140 b Fk(Signal)19 b(on)g(br)o(eaks.)p 3209 +1217 V 383 1309 V 436 1281 a Fh(ttyin/7bits)808 b(ISTRIP)140 +b Fk(Strip)19 b(char)g(to)g(seven)f(bits.)p 3209 1309 +V 383 1400 V 436 1373 a Fh(ttyin/cr->nl)769 b(ICRNL)179 +b Fk(Map)19 b(carriage-r)o(eturn)e(to)i(newline.)p 3209 +1400 V 383 1491 V 436 1464 a Fh(ttyin/ignore-cr)652 b(IGNCR)179 +b Fk(Ignor)o(e)18 b(carriage-r)o(eturns.)p 3209 1491 +V 383 1583 V 436 1555 a Fh(ttyin/nl->cr)769 b(INLCR)179 +b Fk(Map)19 b(newline)g(to)g(carriage-r)o(eturn.)p 3209 +1583 V 383 1674 V 436 1647 a Fh(ttyin/input-flow-ctl)457 +b(IXOFF)179 b Fk(Enable)19 b(input)h(\003ow)f(contr)o(ol.)p +3209 1674 V 383 1765 V 436 1738 a Fh(ttyin/output-flow-ctl)418 +b(IXON)218 b Fk(Enable)19 b(output)h(\003ow)f(contr)o(ol.)p +3209 1765 V 383 1769 2830 4 v 383 1785 V 383 1877 4 92 +v 436 1849 a(SVR4)g(and)g(4.3+BSD)p 3209 1877 V 383 1968 +V 436 1941 a Fh(ttyin/xon-any)730 b(IXANY)179 b Fk(Any)19 +b(char)g(r)o(estarts)f(after)h(stop.)p 3209 1968 V 383 +2059 V 436 2032 a Fh(ttyin/beep-on-overflow)379 b(IMAXBEL)101 +b Fk(Ring)19 b(bell)f(when)i(queue)e(full.)p 3209 2059 +V 383 2063 2830 4 v 383 2079 V 383 2171 4 92 v 436 2143 +a(SVR4)p 3209 2171 V 383 2262 V 436 2235 a Fh(ttyin/lowercase)652 +b(IUCLC)179 b Fk(Map)19 b(upper)f(case)g(to)h(lower)f(case.)p +3209 2262 V 383 2265 2830 4 v 365 2500 a FC(T)-8 b(able)31 +b(3.5:)46 b(Input-\003ags.)58 b(These)31 b(ar)o(e)f(the)i(named)f +(\003ags)h(for)f(the)h Fy(tty-info)c FC(r)o(ecor)o(d's)365 +2600 y FB(input-\003ags)i FC(\002eld.)54 b(These)30 b(\003ags)g +(generally)h(contr)o(ol)f(the)h(pr)o(ocessing)f(of)g(input)h(chars.)365 +2699 y(Only)22 b(the)h(P)t Ft(O)t(S)t(I)t(X)h FC(entries)d(ar)o(e)e +(guaranteed)h(to)h(be)f(non-)p Fy(#f)p FC(.)p 495 2840 +2605 4 v 495 2939 4 100 v 548 2909 a(Scsh)982 b(C)339 +b(Meaning)p 3096 2939 V 495 2943 2605 4 v 495 2959 V +495 3059 4 100 v 550 3029 a(P)t Ft(O)t(S)t(I)t(X)p 3096 +3059 V 495 3159 V 548 3129 a Fy(ttyout/enable)574 b(OPOST)178 +b FC(Enable)20 b(output)i(pr)o(ocessing.)p 3096 3159 +V 495 3162 2605 4 v 495 3178 V 495 3278 4 100 v 548 3248 +a(SVR4)e(and)h(4.3+BSD)p 3096 3278 V 495 3378 V 548 3348 +a Fy(ttyout/nl->crnl)486 b(ONLCR)178 b FC(Map)20 b(nl)h(to)g(cr)o(-nl.) +p 3096 3378 V 495 3381 2605 4 v 495 3398 V 495 3497 4 +100 v 548 3467 a(4.3+BSD)p 3096 3497 V 495 3597 V 548 +3567 a Fy(ttyout/discard-eo)o(t)355 b(ONOEOT)134 b FC(Discar)o(d)20 +b(EOT)h(chars.)p 3096 3597 V 495 3697 V 548 3667 a Fy +(ttyout/expand-tab)o(s)355 b(OXTABS)1958 3637 y Fv(5)2092 +3667 y FC(Expand)20 b(tabs.)p 3096 3697 V 495 3700 2605 +4 v 495 3716 V 495 3816 4 100 v 548 3786 a(SVR4)p 3096 +3816 V 495 3916 V 548 3886 a Fy(ttyout/cr->nl)574 b(OCRNL)178 +b FC(Map)20 b(cr)g(to)i(nl.)p 3096 3916 V 495 4015 V +548 3985 a Fy(ttyout/nl-does-cr)398 b(ONLRET)134 b FC(Nl)21 +b(performs)g(cr)f(as)h(well.)p 3096 4015 V 495 4115 V +548 4085 a Fy(ttyout/no-col0-cr)398 b(ONOCR)178 b FC(No)21 +b(cr)g(output)g(in)g(column)h(0.)p 3096 4115 V 495 4215 +V 548 4185 a Fy(ttyout/delay-w/fi)o(ll)o(-ch)o(ar)93 +b(OFILL)178 b FC(Send)20 b(\002ll)i(char)e(to)h(delay)-9 +b(.)p 3096 4215 V 495 4314 V 548 4284 a Fy(ttyout/fill-w/del)398 +b(OFDEL)178 b FC(Fill)22 b(char)e(is)j(A)t Ft(S)t(C)t(I)t(I)h +FC(DEL.)p 3096 4314 V 495 4414 V 548 4384 a Fy(ttyout/uppercase)442 +b(OLCUC)178 b FC(Map)20 b(lower)h(to)g(upper)f(case.)p +3096 4414 V 495 4417 2605 4 v 365 4652 a(T)-8 b(able)27 +b(3.6:)36 b(Output-\003ags.)44 b(These)26 b(ar)o(e)g(the)h(named)f +(\003ags)h(for)g(the)g Fy(tty-info)c FC(r)o(ecor)o(d's)365 +4752 y FB(output-\003ags)f FC(\002eld.)31 b(These)22 +b(\003ags)h(generally)g(contr)o(ol)g(the)f(pr)o(ocessing)h(of)g(output) +g(chars.)365 4851 y(Only)f(the)h(P)t Ft(O)t(S)t(I)t(X)h +FC(entries)d(ar)o(e)e(guaranteed)h(to)h(be)f(non-)p Fy(#f)p +FC(.)1756 5147 y(85)p eop +%%Page: 86 92 +86 91 bop 1581 1286 1696 4 v 1578 1382 4 100 v 1631 1352 +a FC(V)-8 b(alue)676 b(Comment)p 3274 1382 V 1581 1385 +1696 4 v 927 1452 a(Backspace)19 b(delay)p 1578 1482 +4 100 v 102 w Fy(ttyout/bs-delay)224 b FC(Bit-\002eld)21 +b(mask)p 3274 1482 V 1578 1581 V 1631 1551 a Fy(ttyout/bs-delay0)p +3274 1581 V 1578 1681 V 1631 1651 a(ttyout/bs-delay1)p +3274 1681 V 1581 1684 1696 4 v 731 1750 a FC(Carriage-r)o(eturn)d +(delay)p 1578 1780 4 100 v 102 w Fy(ttyout/cr-delay)224 +b FC(Bit-\002eld)21 b(mask)p 3274 1780 V 1578 1880 V +1631 1850 a Fy(ttyout/cr-delay0)p 3274 1880 V 1578 1980 +V 1631 1950 a(ttyout/cr-delay1)p 3274 1980 V 1578 2079 +V 1631 2049 a(ttyout/cr-delay2)p 3274 2079 V 1578 2179 +V 1631 2149 a(ttyout/cr-delay3)p 3274 2179 V 1581 2182 +1696 4 v 922 2249 a FC(Form-feed)f(delay)p 1578 2279 +4 100 v 102 w Fy(ttyout/ff-delay)224 b FC(Bit-\002eld)21 +b(mask)p 3274 2279 V 1578 2378 V 1631 2348 a Fy(ttyout/ff-delay0)p +3274 2378 V 1578 2478 V 1631 2448 a(ttyout/ff-delay1)p +3274 2478 V 1581 2481 1696 4 v 764 2548 a FC(Horizontal-tab)f(delay)p +1578 2577 4 100 v 102 w Fy(ttyout/tab-delay)180 b FC(Bit-\002eld)21 +b(mask)p 3274 2577 V 1578 2677 V 1631 2647 a Fy(ttyout/tab-delay0)p +3274 2677 V 1578 2777 V 1631 2747 a(ttyout/tab-delay1)p +3274 2777 V 1578 2876 V 1631 2846 a(ttyout/tab-delay2)p +3274 2876 V 1578 2976 V 1631 2946 a(ttyout/tab-delayx)136 +b FC(Expand)20 b(tabs)p 3274 2976 V 1581 2979 1696 4 +v 991 3046 a(Newline)h(delay)p 1578 3076 4 100 v 102 +w Fy(ttyout/nl-delay)224 b FC(Bit-\002eld)21 b(mask)p +3274 3076 V 1578 3175 V 1631 3145 a Fy(ttyout/nl-delay0)p +3274 3175 V 1578 3275 V 1631 3245 a(ttyout/nl-delay1)p +3274 3275 V 1581 3278 1696 4 v 893 3345 a FC(V)-9 b(ertical)20 +b(tab)g(delay)p 1578 3374 4 100 v 102 w Fy(ttyout/vtab-delay)136 +b FC(Bit-\002eld)21 b(mask)p 3274 3374 V 1578 3474 V +1631 3444 a Fy(ttyout/vtab-delay)o(0)p 3274 3474 V 1578 +3574 V 1631 3544 a(ttyout/vtab-delay)o(1)p 3274 3574 +V 1581 3577 1696 4 v 1415 3643 a FC(All)p 1578 3673 4 +100 v 103 w Fy(ttyout/all-delay)180 b FC(T)-8 b(otal)21 +b(bit-\002eld)g(mask)p 3274 3673 V 1581 3677 1696 4 v +681 3825 a(T)-8 b(able)18 b(3.7:)23 b(Delay)18 b(constants.)25 +b(These)18 b(ar)o(e)f(the)i(named)f(\003ags)g(for)g(the)h +Fy(tty-info)14 b FC(r)o(ecor)o(d's)681 3925 y FB(output-\003ags)h +FC(\002eld.)24 b(These)17 b(\003ags)g(contr)o(ol)g(the)f(output)i +(delays)e(associated)g(with)h(printing)681 4024 y(special)j +(characters.)25 b(They)d(ar)o(e)d(non-)r(P)t Ft(O)t(S)t(I)t(X)r +FC(,)k(and)e(have)f(non-)p Fy(#f)h FC(values)g(only)h(on)g(SVR4)681 +4124 y(systems.)2071 5147 y(86)p eop +%%Page: 87 93 +87 92 bop 409 1570 2777 4 v 409 1669 4 100 v 462 1639 +a FC(Scsh)982 b(C)476 b(Meaning)p 3183 1669 V 409 1672 +2777 4 v 409 1689 V 409 1789 4 100 v 464 1759 a(P)t Ft(O)t(S)t(I)t(X)p +3183 1789 V 409 1888 V 462 1858 a Fy(ttyc/char-size)530 +b(CSIZE)315 b FC(Character)19 b(size)i(mask)p 3183 1888 +V 409 1988 V 462 1958 a Fy(ttyc/char-size5)486 b(CS5)403 +b FC(5)21 b(bits)p 3183 1988 V 409 2088 V 462 2058 a +Fy(ttyc/char-size6)486 b(CS6)403 b FC(6)21 b(bits)p 3183 +2088 V 409 2187 V 462 2157 a Fy(ttyc/char-size7)486 b(CS7)403 +b FC(7)21 b(bits)p 3183 2187 V 409 2287 V 462 2257 a +Fy(ttyc/char-size8)486 b(CS8)403 b FC(8)21 b(bits)p 3183 +2287 V 409 2386 V 462 2357 a Fy(ttyc/enable-pari)o(ty)355 +b(PARENB)271 b FC(Generate)20 b(and)h(detect)f(parity)-9 +b(.)p 3183 2386 V 409 2486 V 462 2456 a Fy(ttyc/odd-parity)486 +b(PARODD)271 b FC(Odd)21 b(parity)-9 b(.)p 3183 2486 +V 409 2586 V 462 2556 a Fy(ttyc/enable-read)442 b(CREAD)315 +b FC(Enable)20 b(r)o(eception)h(of)f(chars.)p 3183 2586 +V 409 2685 V 462 2655 a Fy(ttyc/hup-on-clos)o(e)399 b(HUPCL)315 +b FC(Hang)21 b(up)g(on)g(last)g(close.)p 3183 2685 V +409 2785 V 462 2755 a Fy(ttyc/no-modem-sy)o(nc)355 b(LOCAL)315 +b FC(Ignor)o(e)21 b(modem)g(lines.)p 3183 2785 V 409 +2885 V 462 2855 a Fy(ttyc/2-stop-bits)442 b(CSTOPB)271 +b FC(Send)20 b(two)i(stop)f(bits.)p 3183 2885 V 409 2888 +2777 4 v 409 2905 V 409 3004 4 100 v 462 2974 a(4.3+BSD)p +3183 3004 V 409 3104 V 462 3074 a Fy(ttyc/ignore-flag)o(s)399 +b(CIGNORE)227 b FC(Ignor)o(e)21 b(contr)o(ol)g(\003ags.)p +3183 3104 V 409 3203 V 462 3173 a Fy(ttyc/CTS-output-)o(flo)o(w-)o(ctl) +93 b(CCTS_OFLOW)i FC(CTS)20 b(\003ow)i(contr)o(ol)f(of)g(output)p +3183 3203 V 409 3303 V 462 3273 a Fy(ttyc/RTS-input-f)o(low)o(-c)o(tl) +137 b(CRTS_IFLOW)95 b FC(R)m(TS)21 b(\003ow)h(contr)o(ol)f(of)g(input)p +3183 3303 V 409 3403 V 462 3373 a Fy(ttyc/carrier-flo)o(w-c)o(tl)224 +b(MDMBUF)p 3183 3403 V 409 3406 2777 4 v 365 3641 a FC(T)-8 +b(able)26 b(3.8:)35 b(Contr)o(ol-\003ags.)41 b(These)26 +b(ar)o(e)e(the)j(named)e(\003ags)h(for)g(the)g Fy(tty-info)d +FC(r)o(ecor)o(d's)365 3740 y FB(contr)o(ol-\003ags)32 +b FC(\002eld.)61 b(These)33 b(\003ags)g(generally)f(contr)o(ol)h(the)g +(details)g(of)f(the)h(terminal's)365 3840 y(serial)21 +b(line.)26 b(Only)21 b(the)i(P)t Ft(O)t(S)t(I)t(X)h FC(entries)d(ar)o +(e)e(guaranteed)h(to)h(be)g(non-)p Fy(#f)p FC(.)1756 +5147 y(87)p eop +%%Page: 88 94 +88 93 bop 725 1442 2776 4 v 725 1533 4 92 v 778 1506 +a Fk(Scsh)973 b(C)439 b(Meaning)p 3497 1533 V 725 1536 +2776 4 v 725 1553 V 725 1644 4 92 v 780 1617 a(P)t Fg(O)t(S)t(I)t(X)p +3497 1644 V 725 1736 V 778 1708 a Fh(ttyl/canonical)574 +b(ICANON)258 b Fk(Canonical)19 b(input)h(pr)o(ocessing.)p +3497 1736 V 725 1827 V 778 1799 a Fh(ttyl/echo)769 b(ECHO)336 +b Fk(Enable)19 b(echoing.)p 3497 1827 V 725 1918 V 778 +1891 a Fh(ttyl/echo-delete-line)301 b(ECHOK)c Fk(Echo)18 +b(newline)h(after)g(line)f(kill.)p 3497 1918 V 725 2010 +V 778 1982 a Fh(ttyl/echo-nl)652 b(ECHONL)258 b Fk(Echo)18 +b(newline)h(even)g(if)g(echo)g(is)f(of)o(f.)p 3497 2010 +V 725 2101 V 778 2073 a Fh(ttyl/visual-delete)418 b(ECHOE)297 +b Fk(V)l(isually)17 b(erase)h(chars.)p 3497 2101 V 725 +2192 V 778 2165 a Fh(ttyl/enable-signals)379 b(ISIG)336 +b Fk(Enable)19 b Fh(^)p Fk(C,)f Fh(^)p Fk(Z)h(signalling.)p +3497 2192 V 725 2284 V 778 2256 a Fh(ttyl/extended)613 +b(IEXTEN)258 b Fk(Enable)19 b(extensions.)p 3497 2284 +V 725 2375 V 778 2347 a Fh(ttyl/no-flush-on-interrupt)106 +b(NOFLSH)258 b Fk(Don't)19 b(\003ush)g(after)f(interr)o(upt.)p +3497 2375 V 725 2466 V 778 2439 a Fh(ttyl/ttou-signal)496 +b(ITOSTOP)219 b(SIGTTOU)20 b Fk(on)f(backgr)o(ound)f(output.)p +3497 2466 V 725 2469 2776 4 v 725 2486 V 725 2577 4 92 +v 778 2550 a(SVR4)h(and)g(4.3+BSD)p 3497 2577 V 725 2669 +V 778 2641 a Fh(ttyl/echo-ctl)613 b(ECHOCTL)219 b Fk(Echo)18 +b(contr)o(ol)h(chars)g(as)f(\223)p Fh(^X)p Fk(\224.)p +3497 2669 V 725 2760 V 778 2733 a Fh(ttyl/flush-output)457 +b(FLUSHO)258 b Fk(Output)19 b(is)f(being)g(\003ushed.)p +3497 2760 V 725 2851 V 778 2824 a Fh(ttyl/hardcopy-delete)340 +b(ECHOPRT)219 b Fk(V)l(isual)18 b(erase)g(for)f(har)o(dcopy)-8 +b(.)p 3497 2851 V 725 2943 V 778 2915 a Fh(ttyl/reprint-unread-chars) +145 b(PENDIN)258 b Fk(Retype)18 b(pending)g(input.)p +3497 2943 V 725 3034 V 778 3007 a Fh(ttyl/visual-delete-line)223 +b(ECHOKE)258 b Fk(V)l(isually)17 b(erase)h(a)h(line-kill.)p +3497 3034 V 725 3037 2776 4 v 725 3054 V 725 3145 4 92 +v 778 3118 a(4.3+BSD)p 3497 3145 V 725 3237 V 778 3209 +a Fh(ttyl/alt-delete-word)340 b(ALTWERASE)141 b Fk(Alternate)19 +b(wor)o(d)e(erase)h(algorithm)p 3497 3237 V 725 3328 +V 778 3301 a Fh(ttyl/no-kernel-status)301 b(NOKERNINFO)102 +b Fk(No)18 b(kernel)g(status)h(on)g Fh(^T)p Fk(.)p 3497 +3328 V 725 3331 2776 4 v 725 3348 V 725 3439 4 92 v 778 +3412 a(SVR4)p 3497 3439 V 725 3530 V 778 3503 a Fh(ttyl/case-map)613 +b(XCASE)297 b Fk(Canonical)19 b(case)g(pr)o(esentation)p +3497 3530 V 725 3534 2776 4 v 681 3769 a FC(T)-8 b(able)31 +b(3.9:)47 b(Local-\003ags.)58 b(These)32 b(ar)o(e)e(the)i(named)f +(\003ags)h(for)g(the)g Fy(tty-info)c FC(r)o(ecor)o(d's)681 +3868 y FB(local-\003ags)k FC(\002eld.)61 b(These)32 b(\003ags)h +(generally)g(contr)o(ol)g(the)g(details)f(of)h(the)g(line-editting)681 +3968 y(user)20 b(interface.)25 b(Only)c(the)i(P)t Ft(O)t(S)t(I)t(X)i +FC(entries)20 b(ar)o(e)g(guaranteed)f(to)i(be)g(non-)p +Fy(#f)p FC(.)2071 5147 y(88)p eop +%%Page: 89 95 +89 94 bop 365 1274 a Fx(Chapter)45 b(4)365 1727 y FD(Networking)365 +2220 y FC(The)28 b(Scheme)g(Shell)g(pr)o(ovides)f(a)h(BSD-style)f +(sockets)i(interface.)46 b(Ther)o(e)27 b(is)h(not)h(an)f(of-)365 +2320 y(\002cial)f(standar)o(d)e(for)i(a)f(network)h(interface)f(for)h +(scsh)g(to)g(adopt)f(\(this)h(is)h(the)f(subject)g(of)365 +2420 y(the)k(forthcoming)h(Posix.8)e(standar)o(d\).)52 +b(However)-6 b(,)33 b(Berkeley)c(sockets)i(ar)o(e)e(a)h +FB(de)g(facto)365 2519 y FC(standar)o(d,)19 b(being)i(found)g(on)g +(most)h(Unix)f(workstations)h(and)e(PC)h(operating)g(systems.)490 +2656 y(It)29 b(is)h(fairly)f(straightforwar)o(d)g(to)h(add)e(higher)o +(-level)h(network)i(pr)o(otocols)f(such)g(as)365 2756 +y(smtp,)22 b(telnet,)f(or)g(http)h(on)f(top)h(of)f(the)g(the)h(basic)e +(socket-level)h(support)h(scsh)g(pr)o(ovides.)365 2855 +y(The)29 b(Scheme)f(Under)o(gr)o(ound)f(has)i(also)g(r)o(eleased)e(a)h +(network)h(library)f(with)i(many)f(of)365 2955 y(these)22 +b(pr)o(otocols)g(as)g(a)f(companion)i(to)f(the)g(curr)o(ent)f(r)o +(elease)f(of)i(scsh.)29 b(See)21 b(this)h(code)g(for)365 +3055 y(examples)e(showing)j(the)e(use)g(of)f(the)h(sockets)h +(interface.)365 3364 y Fw(4.1)99 b(High-level)26 b(interface)365 +3595 y FC(For)18 b(convenience,)h(and)e(to)h(avoid)g(some)g(of)g(the)g +(messy)h(details)e(of)h(the)g(socket)g(interface,)365 +3694 y(we)f(pr)o(ovide)f(a)h(high)g(level)g(socket)g(interface.)23 +b(These)17 b(r)o(outines)g(attempt)g(to)g(make)g(it)g(easy)365 +3794 y(to)23 b(write)f(simple)h(clients)g(and)f(servers)g(without)h +(having)g(to)f(think)i(of)e(many)h(of)f(the)g(de-)365 +3894 y(tails)g(of)f(initiating)h(socket)g(connections.)28 +b(W)-8 b(e)22 b(welcome)f(suggested)h(impr)o(ovements)f(to)365 +3993 y(this)i(interface,)e(including)i(better)f(names,)g(which)h(right) +g(now)g(ar)o(e)d(solely)j(descriptions)365 4093 y(of)28 +b(the)h(pr)o(ocedur)o(e's)d(action.)48 b(This)28 b(might)i(be)d(\002ne) +i(for)f(people)g(who)h(alr)o(eady)d(under)o(-)365 4193 +y(stand)21 b(sockets,)g(but)g(does)g(not)g(help)g(the)g(new)g +(networking)h(pr)o(ogrammer)-6 b(.)365 4350 y Fy(\(socket-connect)38 +b FB(pr)o(otocol-family)18 b(socket-type)h(.)h(ar)o(gs)p +Fy(\))87 b Fu(\000)-15 b(!)87 b FB(socket)139 b FC(pr)o(ocedur)o(e)573 +4500 y Fy(socket-connect)92 b FC(is)98 b(intended)g(for)g(cr)o(eating)f +(client)i(applications.)573 4599 y FB(pr)o(otocol-family)49 +b FC(is)k(speci\002ed)f(as)g(either)g(the)g Fy(protocol-family/i)o(nte) +o(rn)o(et)573 4699 y FC(or)85 b Fy(protocol-family)o(/un)o(ix)o +FC(.)212 b FB(socket-type)83 b FC(is)i(speci\002ed)f(as)h(either)573 +4799 y Fy(socket-type/stre)o(am)44 b FC(or)51 b Fy(socket-type/data)o +(gra)o(m)p FC(.)109 b(See)50 b Fy(socket)f FC(for)h(a)573 +4898 y(mor)o(e)20 b(complete)h(description)g(of)g(these)g(terms.)1756 +5147 y(89)p eop +%%Page: 90 96 +90 95 bop 888 614 a FC(The)20 b(variable)e FB(ar)o(gs)g +FC(list)i(is)g(meant)f(to)g(specify)g(pr)o(otocol)h(family)f +(speci\002c)g(informa-)888 714 y(tion.)48 b(For)28 b(Internet)g +(sockets,)i(this)e(consists)i(of)d(two)i(ar)o(guments:)39 +b(a)27 b(host)i(name)888 814 y(and)21 b(a)f(port)h(number)-6 +b(.)25 b(For)c(Unix)g(sockets,)g(this)h(consists)g(of)e(a)h(pathname.) +888 947 y Fy(socket-connect)e FC(r)o(eturns)24 b(a)g +Fy(socket)e FC(which)j(can)f(be)g(used)g(for)g(input)h(and)f(out-)888 +1046 y(put)19 b(fr)o(om)f(a)h(r)o(emote)f(server)-6 b(.)24 +b(See)18 b Fy(socket)e FC(for)i(a)h(description)g(of)f(the)h +FB(socket)g(r)o(ecord)p FC(.)681 1238 y Fy(\(bind-listen-acc)o(ep)o +(t-l)o(oo)o(p)37 b FB(pr)o(otocol-family)13 b(pr)o(oc)i(ar)o(g)p +Fy(\))43 b Fu(\000)-15 b(!)44 b FB(does-not-r)o(eturn)86 +b FC(pr)o(ocedur)o(e)888 1380 y Fy(bind-listen-accep)o(t-)o(loo)o(p)22 +b FC(is)29 b(intended)f(for)g(cr)o(eating)f(server)g(applications.)888 +1480 y FB(pr)o(otocol-family)k FC(is)j(speci\002ed)g(as)f(either)g(the) +h Fy(protocol-family/i)o(nt)o(ern)o(et)27 b FC(or)888 +1579 y Fy(protocol-family/u)o(ni)o(x)p FC(.)d FB(pr)o(oc)d +FC(is)i(a)e(pr)o(ocedur)o(e)g(of)h(two)h(ar)o(guments:)28 +b(a)22 b Fy(socket)888 1679 y FC(and)c(a)f(socket-addr)o(ess.)23 +b FB(ar)o(g)17 b FC(speci\002es)i(a)e(port)h(number)g(for)g(Internet)g +(sockets)g(or)h(a)888 1778 y(pathname)k(for)g(Unix)h(sockets.)33 +b(See)23 b Fy(socket)d FC(for)k(a)e(mor)o(e)h(complete)h(description) +888 1878 y(of)d(these)g(terms.)888 2011 y FB(pr)o(oc)g +FC(is)h(called)f(with)h(a)f(socket)h(and)f(a)g(socket)h(addr)o(ess)e +(each)h(time)h(ther)o(e)f(is)h(a)f(con-)888 2111 y(nection)36 +b(fr)o(om)f(a)g(client)g(application.)69 b(The)35 b(socket)g(allows)h +(communications)888 2210 y(with)30 b(the)g(client.)51 +b(The)29 b(socket)g(addr)o(ess)f(speci\002es)h(the)g(addr)o(ess)f(of)h +(the)h(r)o(emote)888 2310 y(client.)888 2443 y(This)23 +b(pr)o(ocedur)o(e)e(does)h(not)h(r)o(eturn,)f(but)g(loops)i +(inde\002nitely)f(accepting)f(connec-)888 2543 y(tions)g(fr)o(om)f +(client)g(pr)o(ograms.)681 2838 y Fw(4.2)99 b(Sockets)681 +3078 y Fy(\(create-socket)38 b FB(pr)o(otocol-family)18 +b(type)h([pr)o(otocol])p Fy(\))85 b Fu(\000)-15 b(!)88 +b FB(socket)269 b FC(pr)o(ocedur)o(e)681 3178 y Fy(\(create-socket-p)o +(ai)o(r)38 b FB(type)p Fy(\))85 b Fu(\000)-14 b(!)87 +b FB([socket)2275 3190 y Fv(1)2333 3178 y FB(socket)2533 +3190 y Fv(2)2570 3178 y FB(])572 b FC(pr)o(ocedur)o(e)681 +3277 y Fy(\(close-socket)38 b FB(socket)p Fy(\))86 b +Fu(\000)-14 b(!)87 b FB(unde\002ned)998 b FC(pr)o(ocedur)o(e)888 +3402 y(A)28 b(socket)g(is)h(one)f(end)g(of)g(a)g(network)g(connection.) +49 b(Thr)o(ee)27 b(speci\002c)h(pr)o(operties)888 3501 +y(of)i(sockets)f(ar)o(e)f(speci\002ed)h(at)g(cr)o(eation)f(time:)43 +b(the)30 b(pr)o(otocol-family)-9 b(,)30 b(type,)h(and)888 +3601 y(pr)o(otocol.)888 3734 y(The)43 b FB(pr)o(otocol-family)c +FC(speci\002es)k(the)g(pr)o(otocol)f(family)h(to)f(be)g(used)h(with)g +(the)888 3834 y(socket.)75 b(This)37 b(also)g(determines)g(the)g(addr)o +(ess)f(family)h(of)g(socket)g(addr)o(esses,)888 3934 +y(which)30 b(ar)o(e)e(described)g(in)i(mor)o(e)f(detail)f(below)-8 +b(.)52 b(Scsh)29 b(curr)o(ently)f(supports)i(the)888 +4033 y(Unix)i(internal)h(pr)o(otocols)f(and)g(the)g(Internet)h(pr)o +(otocols)f(using)h(the)g(following)888 4133 y(constants:)1071 +4300 y Fy(protocol-family/)o(uns)o(pe)o(ci)o(fie)o(d)1071 +4399 y(protocol-family/)o(uni)o(x)1071 4499 y(protocol-family/)o(int)o +(er)o(ne)o(t)888 4699 y FC(The)23 b FB(type)f FC(speci\002es)h(the)g +(style)g(of)g(communication.)34 b(Examples)22 b(that)h(your)g(oper)o(-) +888 4799 y(ating)c(system)f(pr)o(obably)f(pr)o(ovides)h(ar)o(e)e(str)o +(eam)h(and)h(datagram)e(sockets.)26 b(Others)888 4898 +y(maybe)21 b(available)e(depending)i(on)g(your)g(system.)26 +b(T)-7 b(ypical)20 b(values)h(ar)o(e:)2071 5147 y(90)p +eop +%%Page: 91 97 +91 96 bop 756 614 a Fy(socket-type/str)o(ea)o(m)756 714 +y(socket-type/dat)o(ag)o(ram)756 814 y(socket-type/raw)573 +1007 y FC(The)19 b FB(pr)o(otocol)e FC(speci\002es)i(a)g(particular)f +(pr)o(otocol)h(to)g(use)h(within)g(a)e(pr)o(otocol)i(family)573 +1107 y(and)15 b(type.)24 b(Usually)16 b(only)g(one)h(choice)f(exists,)g +(but)g(it's)h(pr)o(obably)e(safest)g(to)h(set)g(this)573 +1207 y(explicitly)-9 b(.)33 b(See)23 b(the)g(pr)o(otocol)h(database)e +(r)o(outines)h(for)h(information)g(on)g(looking)573 1306 +y(up)d(pr)o(otocol)g(constants.)573 1437 y(New)48 b(sockets)h(ar)o(e)e +(typically)i(cr)o(eated)e(with)i Fy(create-socket)p FC(.)103 +b(However)-6 b(,)573 1537 y Fy(create-socket-pa)o(ir)14 +b FC(can)19 b(also)i(be)f(used)g(to)g(cr)o(eate)f(a)g(pair)h(of)g +(connected)g(sock-)573 1637 y(ets)36 b(in)g(the)g Fy(protocol-family/u) +o(nix)29 b FC(pr)o(otocol-family)-9 b(.)71 b(The)36 b(value)f(of)h(a)g +(r)o(e-)573 1736 y(turned)20 b(socket)h(is)h(a)e FB(socket)g(r)o(ecord) +p FC(,)g(de\002ned)h(to)g(have)f(the)h(following)h(str)o(uctur)o(e:)756 +1899 y Fy(\(define-record)37 b(socket)843 1998 y(family)1392 +b(;)43 b(protocol)d(family)843 2098 y(inport)1392 b(;)43 +b(input-port)843 2198 y(outport\))1304 b(;)43 b(output-port)573 +2391 y FC(The)26 b Fy(family)e FC(speci\002es)j(the)f(pr)o(otocol)h +(family)g(of)f(the)h(socket.)43 b(The)26 b Fy(inport)e +FC(and)573 2491 y Fy(outport)h FC(\002elds)j(ar)o(e)f(ports)i(that)f +(can)g(be)g(used)f(for)h(input)h(and)f(output,)i(r)o(espec-)573 +2591 y(tively)-9 b(.)48 b(For)29 b(a)e(str)o(eam)h(socket,)i(they)f(ar) +o(e)e(only)i(usable)f(after)f(a)h(connection)i(has)573 +2690 y(been)18 b(established)g(via)g Fy(connect-socket)13 +b FC(or)19 b Fy(accept-connecti)o(on)p FC(.)f(For)h(a)f(data-)573 +2790 y(gram)j(socket,)g FB(outport)f FC(can)h(be)g(immediately)g(using) +h Fy(send-message)p FC(,)16 b(and)21 b FB(inport)573 +2890 y FC(can)f(be)h(used)f(after)g Fy(bind)f FC(has)i(cr)o(eated)d(a)j +(local)f(addr)o(ess.)573 3021 y Fy(close-socket)j FC(pr)o(ovides)28 +b(a)g(convenient)h(way)g(to)f(close)h(a)f(socket's)h(port.)49 +b(It)28 b(is)573 3120 y(pr)o(eferr)o(ed)14 b(to)j(explicitly)g(closing) +i(the)e(inport)g(and)g(outport)h(because)e(using)i Fy(close)573 +3220 y FC(on)j(sockets)h(is)f(not)g(curr)o(ently)f(portable)h(acr)o +(oss)f(operating)h(systems.)365 3510 y Fw(4.3)99 b(Socket)26 +b(addresses)365 3724 y FC(The)i(format)g(of)g(a)g(socket-addr)o(ess)e +(depends)i(on)g(the)h(addr)o(ess)d(family)i(of)g(the)g(socket.)365 +3824 y(Addr)o(ess-family-speci\002c)21 b(r)o(outines)j(ar)o(e)e(pr)o +(ovided)g(to)i(convert)f(pr)o(otocol-speci\002c)h(ad-)365 +3924 y(dr)o(esses)i(to)i(socket)f(addr)o(esses.)43 b(The)27 +b(value)f(r)o(eturned)g(by)h(these)g(r)o(outines)g(is)h(a)e +FB(socket-)365 4023 y(addr)o(ess)21 b(r)o(ecord)p FC(,)f(de\002ned)g +(to)h(have)f(the)h(following)i(visible)e(str)o(uctur)o(e:)573 +4207 y Fy(\(define-record)38 b(socket-address)660 4307 +y(family\))1348 b(;)43 b(address)e(family)490 4515 y +FC(The)21 b Fy(family)d FC(is)j(one)g(of)g(the)g(following)h +(constants:)573 4699 y Fy(address-family/u)o(ns)o(pec)o(if)o(ied)573 +4799 y(address-family/u)o(ni)o(x)573 4898 y(address-family/i)o(nt)o +(ern)o(et)1756 5147 y FC(91)p eop +%%Page: 92 98 +92 97 bop 681 614 a Fy(\(unix-address->s)o(oc)o(ket)o(-a)o(dd)o(res)o +(s)37 b FB(pathname)p Fy(\))56 b Fu(\000)-14 b(!)57 b +FB(socket-addr)o(ess)86 b FC(pr)o(ocedur)o(e)888 752 +y Fy(unix-address->soc)o(ke)o(t-a)o(dd)o(res)o(s)33 b +FC(r)o(eturns)38 b(a)g FB(socket-addr)o(ess)g FC(based)g(on)i(the)888 +851 y(string)e FB(pathname)n FC(.)75 b(Ther)o(e)36 b(is)h(a)g(system)g +(dependent)g(limit)g(on)h(the)f(length)h(of)888 951 y +FB(pathname)o FC(.)681 1136 y Fy(\(internet-addres)o(s-)o(>so)o(ck)o +(et)o(-ad)o(dr)o(ess)f FB(host-addr)o(ess)14 b(service-port)p +Fy(\))43 b Fu(\000)-15 b(!)44 b FB(socket-addr)o(ess)86 +b FC(pr)o(ocedur)o(e)888 1273 y Fy(internet-address-)o(>s)o(ock)o(et)o +(-ad)o(dr)o(ess)28 b FC(r)o(eturns)34 b(a)h FB(socket-addr)o(ess)e +FC(based)h(on)888 1373 y(an)25 b(integer)g FB(host-addr)o(ess)f +FC(and)g(an)h(integer)g FB(service-port)p FC(.)38 b(Besides)24 +b(being)i(a)e(32-bit)888 1472 y(host)29 b(addr)o(ess,)g(an)f(Internet)g +(host)h(addr)o(ess)d(can)i(also)h(be)f(one)g(of)g(the)h(following)888 +1572 y(constants:)1071 1734 y Fy(internet-address)o(/an)o(y)1071 +1833 y(internet-address)o(/lo)o(op)o(ba)o(ck)1071 1933 +y(internet-address)o(/br)o(oa)o(dc)o(ast)888 2126 y FC(The)h(use)f(of)h +Fy(internet-addres)o(s/a)o(ny)23 b FC(is)30 b(described)e(below)i(in)g +Fy(bind-socket)p FC(.)888 2226 y Fy(internet-address/)o(lo)o(opb)o(ac)o +(k)11 b FC(is)17 b(an)f(addr)o(ess)f(that)i(always)f(speci\002es)h(the) +g(local)888 2326 y(machine.)47 b Fy(internet-address)o(/br)o(oa)o(dca)o +(st)21 b FC(is)28 b(used)g(for)f(network)i(br)o(oadcast)888 +2425 y(communications.)888 2556 y(For)f(information)g(on)h(obtaining)f +(a)f(host's)i(addr)o(ess,)e(see)g(the)h Fy(host-info)c +FC(func-)888 2656 y(tion.)681 2841 y Fy(\(socket-address-)o(>u)o(nix)o +(-a)o(dd)o(res)o(s)37 b FB(socket-addr)o(ess)p Fy(\))56 +b Fu(\000)-14 b(!)57 b FB(pathname)86 b FC(pr)o(ocedur)o(e)681 +2940 y Fy(\(socket-address-)o(>i)o(nte)o(rn)o(et)o(-ad)o(dr)o(ess)37 +b FB(socket-addr)o(ess)p Fy(\))42 b Fu(\000)-14 b(!)43 +b FB([host-addr)o(ess)14 b(service-port])86 b FC(pr)o(ocedur)o(e)888 +3077 y(The)227 b(r)o(outines)h Fy(socket-address-)o(>in)o(te)o(rne)o +(t-)o(ad)o(dre)o(ss)220 b FC(and)888 3177 y Fy(socket-address->u)o(ni)o +(x-a)o(dd)o(res)o(s)74 b FC(r)o(eturn)81 b(the)f(addr)o +(ess-family-speci\002c)888 3277 y(addr)o(esses.)94 b(Be)43 +b(awar)o(e)g(that)g(most)i(implementations)h(don't)e(corr)o(ectly)f(r)o +(e-)888 3376 y(turn)e(anything)g(mor)o(e)f(than)g(an)g(empty)g(string)h +(for)f(addr)o(esses)e(in)j(the)f(Unix)888 3476 y(addr)o(ess-family)-9 +b(.)681 3766 y Fw(4.4)99 b(Socket)25 b(primitives)681 +3980 y FC(The)30 b(pr)o(ocedur)o(es)f(in)i(this)h(section)f(ar)o(e)e +(pr)o(esented)h(in)h(the)g(or)o(der)e(in)j(which)f(a)f(typical)681 +4080 y(pr)o(ogram)24 b(will)i(use)f(them.)39 b(Consult)26 +b(a)e(text)h(on)g(network)h(systems)g(pr)o(ogramming)f(for)681 +4179 y(mor)o(e)18 b(information)h(on)g(sockets.)1743 +4149 y Fv(1)1805 4179 y FC(The)f(last)g(two)h(tutorials)f(ar)o(e)f(fr)o +(eely)g(available)g(as)h(part)p 681 4252 1146 4 v 766 +4306 a Fq(1)800 4329 y Ft(Some)f(r)o(ecommended)d(ones)j(ar)o(e:)812 +4446 y Fd(\017)41 b Ft(\223Unix)17 b(Network)g(Pr)o(ogramming\224)g(by) +f(W)-6 b(.)17 b(Richar)o(d)g(Stevens)812 4554 y Fd(\017)41 +b Ft(\223An)19 b(Intr)o(oductory)g(4.3BSD)g(Interpr)o(ocess)g +(Communication)g(T)-6 b(utorial.\224)28 b(\(r)o(eprinted)18 +b(in)h(UNIX)h(Pr)o(o-)888 4632 y(grammer)5 b('s)17 b(Supplementary)f +(Documents)h(V)-7 b(olume)16 b(1,)g(PS1:7\))812 4741 +y Fd(\017)41 b Ft(\223An)25 b(Advanced)f(4.3BSD)h(Interpr)o(ocess)h +(Communication)g(T)-6 b(utorial.\224)48 b(\(r)o(eprinted)24 +b(in)i(UNIX)g(Pr)o(o-)888 4819 y(grammer)5 b('s)17 b(Supplementary)f +(Documents)h(V)-7 b(olume)16 b(1,)g(PS1:8\))2071 5147 +y FC(92)p eop +%%Page: 93 99 +93 98 bop 365 614 a FC(of)22 b(BSD.)e(In)i(the)g(absence)e(of)i(these,) +f(your)h(Unix)f(manual)h(pages)f(for)g(socket)h(might)g(be)f(a)365 +714 y(good)h(starting)f(point)g(for)g(information.)365 +864 y Fy(\(connect-socket)38 b FB(socket)20 b(socket-addr)o(ess)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(unde\002ned)415 b +FC(pr)o(ocedur)o(e)573 1005 y Fy(connect-socket)52 b +FC(sets)58 b(up)g(a)f(connection)i(fr)o(om)f(a)f FB(socket)g +FC(to)i(a)e(r)o(emote)573 1105 y FB(socket-addr)o(ess)o +FC(.)62 b(A)32 b(connection)j(has)e(dif)o(fer)o(ent)d(meanings)k +(depending)f(on)g(the)573 1205 y(socket)22 b(type.)30 +b(A)22 b(str)o(eam)g(socket)g(must)h(be)f(connected)g(befor)o(e)f(use.) +30 b(A)22 b(datagram)573 1304 y(socket)h(can)f(be)g(connected)g +(multiple)h(times,)g(but)f(need)g(not)h(be)f(connected)h(at)f(all)573 +1404 y(if)f(the)h(r)o(emote)f(addr)o(ess)f(is)h(speci\002ed)g(with)i +(each)d Fy(send-message)p FC(,)d(described)j(be-)573 +1504 y(low)-8 b(.)26 b(Also,)20 b(datagram)e(sockets)i(may)f(be)g +(disassociated)g(fr)o(om)g(a)g(r)o(emote)g(addr)o(ess)573 +1603 y(by)i(connecting)h(to)f(a)f(null)h(r)o(emote)g(addr)o(ess.)365 +1795 y Fy(\(bind-socket)39 b FB(socket)20 b(socket-addr)o(ess)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(unde\002ned)546 b +FC(pr)o(ocedur)o(e)573 1937 y Fy(bind-socket)24 b FC(assigns)29 +b(a)f(certain)g(local)g FB(socket-addr)o(ess)f FC(to)i(a)f +FB(socket)p FC(.)48 b(Binding)29 b(a)573 2037 y(socket)h(r)o(eserves)f +(the)h(local)g(addr)o(ess.)52 b(T)-8 b(o)31 b(r)o(eceive)d(connections) +k(after)d(binding)573 2136 y(the)23 b(socket,)h(use)f +Fy(listen-socket)18 b FC(for)k(str)o(eam)h(sockets)g(and)g +Fy(receive-message)573 2236 y FC(for)d(datagram)g(sockets.)573 +2369 y(Binding)e(an)f(Internet)h(socket)g(with)g(a)f(host)h(addr)o(ess) +e(of)i Fy(internet-address)o(/a)o(ny)573 2469 y FC(indicates)f(that)h +(the)g(caller)f(does)g(not)i(car)o(e)d(to)i(specify)f(fr)o(om)h(which)g +(local)g(network)573 2568 y(interface)i(connections)i(ar)o(e)d(r)o +(eceived.)24 b(Binding)d(an)g(Internet)g(socket)g(with)g(a)g(ser)o(-) +573 2668 y(vice)h(port)h(number)g(of)f(zer)o(o)g(indicates)g(that)h +(the)g(caller)f(has)g(no)i(pr)o(efer)o(ence)c(as)i(to)573 +2768 y(the)f(port)g(number)g(assigned.)573 2901 y(Binding)27 +b(a)e(socket)i(in)g(the)f(Unix)g(addr)o(ess)f(family)h(cr)o(eates)e(a)i +(socket)h(special)e(\002le)573 3000 y(in)f(the)f(\002le)g(system)h +(that)f(must)h(be)f(deleted)f(befor)o(e)g(the)i(addr)o(ess)d(can)i(be)g +(r)o(eused.)573 3100 y(See)d Fy(delete-file)p FC(.)365 +3292 y Fy(\(listen-socket)38 b FB(socket)21 b(backlog)p +Fy(\))86 b Fu(\000)-15 b(!)88 b FB(unde\002ned)686 b +FC(pr)o(ocedur)o(e)573 3434 y Fy(listen-socket)21 b FC(allows)27 +b(a)e(str)o(eam)h FB(socket)g FC(to)h(start)f(r)o(eceiving)f +(connections,)k(al-)573 3533 y(lowing)19 b(a)e(queue)g(of)h(up)f(to)h +FB(backlog)f FC(connection)i(r)o(equests.)24 b(Queued)17 +b(connections)573 3633 y(may)k(be)f(accepted)f(by)i Fy +(accept-connectio)o(n)p FC(.)365 3825 y Fy(\(accept-connectio)o(n)37 +b FB(socket)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB([new-socket)20 +b(socket-addr)o(ess])192 b FC(pr)o(ocedur)o(e)573 3967 +y Fy(accept-connectio)o(n)24 b FC(r)o(eceives)30 b(a)g(connection)i(on) +f(a)f FB(socket)p FC(,)j(r)o(eturning)d(a)g(new)573 4066 +y(socket)19 b(that)g(can)f(be)h(used)g(for)f(this)i(connection)g(and)e +(the)h(r)o(emote)g(socket)g(addr)o(ess)573 4166 y(associated)h(with)h +(the)g(connection.)365 4358 y Fy(\(socket-local-add)o(re)o(ss)37 +b FB(socket)p Fy(\))87 b Fu(\000)-15 b(!)88 b FB(socket-addr)o(ess)503 +b FC(pr)o(ocedur)o(e)365 4458 y Fy(\(socket-remote-ad)o(dr)o(ess)37 +b FB(socket)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(socket-addr)o(ess)460 +b FC(pr)o(ocedur)o(e)573 4599 y(Sockets)42 b(can)g(be)g(associated)g +(with)h(a)f(local)g(addr)o(ess)f(or)h(a)g(r)o(emote)g(addr)o(ess)573 +4699 y(or)33 b(both.)62 b Fy(socket-local-ad)o(dr)o(ess)26 +b FC(r)o(eturns)32 b(the)h(local)g FB(socket-addr)o(ess)e +FC(r)o(ecor)o(d)573 4799 y(associated)46 b(with)i FB(socket)o +FC(.)104 b Fy(socket-remote-add)o(res)o(s)41 b FC(r)o(eturns)46 +b(the)h(r)o(emote)573 4898 y FB(socket-addr)o(ess)20 +b FC(r)o(ecor)o(d)f(associated)h(with)h FB(socket)p FC(.)1756 +5147 y(93)p eop +%%Page: 94 100 +94 99 bop 681 614 a Fy(\(shutdown-socket)37 b FB(socket)20 +b(how-to)p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(unde\002ned)616 +b FC(pr)o(ocedur)o(e)888 781 y Fy(shutdown-socket)19 +b FC(shuts)27 b(down)f(part)e(of)h(a)g(full-duplex)g(socket.)39 +b(The)26 b(method)888 881 y(of)21 b(shutting)h(done)f(is)g(speci\002ed) +g(by)f(the)h FB(how-to)e FC(ar)o(gument,)h(one)i(of:)1071 +1098 y Fy(shutdown/receive)o(s)1071 1198 y(shutdown/sends)1071 +1298 y(shutdown/sends+r)o(ece)o(iv)o(es)681 1851 y Fw(4.5)99 +b(Performing)24 b(input)h(and)g(output)g(on)g(sockets)681 +2128 y Fy(\(receive-message)37 b FB(socket)15 b(length)g([\003ags])p +Fy(\))43 b Fu(\000)-15 b(!)44 b FB([string-or-)p Fy(#f)p +FC(socket-addr)o(ess])83 b(pr)o(ocedur)o(e)681 2227 y +Fy(\(receive-message)o(!)37 b FB(socket)16 b(string)g([start])e([end])h +([\003ags])p Fy(\))43 b Fu(\000)-14 b(!)43 b FB([count-or-)p +Fy(#f)p FC(socket-addr)o(ess])83 b(pr)o(ocedur)o(e)681 +2327 y Fy(\(receive-message)o(/p)o(art)o(ia)o(l)37 b +FB(socket)16 b(length)f([\003ags])p Fy(\))42 b Fu(\000)-14 +b(!)44 b FB([string-or-)p Fy(#f)p FC(socket-addr)o(ess])83 +b(pr)o(ocedur)o(e)681 2427 y Fy(\(receive-message)o(!/)o(par)o(ti)o(al) +37 b FB(socket)16 b(string)f([start])g([end])g([\003ags])p +Fy(\))43 b Fu(\000)-15 b(!)44 b FB([count-or-)p Fy(#f)p +FC(socket-addr)o(ess])83 b(pr)o(ocedur)o(e)681 2602 y +Fy(\(send-message)38 b FB(socket)16 b(string)f([start])g([end])g +([\003ags])g([socket-addr)o(ess])p Fy(\))42 b Fu(\000)-15 +b(!)44 b FB(unde\002ned)87 b FC(pr)o(ocedur)o(e)681 2701 +y Fy(\(send-message/pa)o(rt)o(ial)37 b FB(socket)15 b(string)h([start]) +f([end])g([\003ags])g([socket-addr)o(ess])p Fy(\))41 +b Fu(\000)-14 b(!)44 b FB(count)86 b FC(pr)o(ocedur)o(e)888 +2839 y(For)23 b(most)h(uses,)f(standar)o(d)e(input)i(and)f(output)h(r)o +(outines)g(such)g(as)g Fy(read-string)888 2938 y FC(and)i +Fy(write-string)20 b FC(should)26 b(suf)o(\002ce.)37 +b(However)-6 b(,)26 b(in)f(some)h(cases)e(an)h(extended)888 +3038 y(interface)c(is)g(r)o(equir)o(ed.)26 b(The)21 b +Fy(receive-message)15 b FC(and)21 b Fy(send-message)16 +b FC(calls)22 b(par)o(-)888 3138 y(allel)37 b(the)h Fy(read-string)33 +b FC(and)j Fy(write-string)d FC(calls)k(with)h(a)f(similar)g(naming)888 +3237 y(scheme.)888 3396 y(One)i(additional)g(featur)o(e)e(of)h(these)h +(r)o(outines)g(is)g(that)g Fy(receive-message)32 b FC(r)o(e-)888 +3495 y(turns)21 b(the)f(r)o(emote)g FB(socket-addr)o(ess)f +FC(and)h FB(send-message)g FC(takes)g(an)g(optional)i(r)o(emote)888 +3595 y Fy(socket-address)p FC(.)56 b(This)34 b(allows)f(a)g(pr)o(ogram) +f(to)h(know)h(the)f(sour)o(ce)g(of)g(input)888 3695 y(fr)o(om)20 +b(a)g(datagram)e(socket)j(and)f(to)g(use)g(a)g(datagram)f(socket)h(for) +g(output)h(without)888 3794 y(\002rst)g(connecting)h(it.)888 +3953 y(All)j(of)g(these)g(pr)o(ocedur)o(es)f(take)g(an)h(optional)h +FB(\003ags)f FC(\002eld.)38 b(This)25 b(ar)o(gument)g(is)g(an)888 +4053 y(integer)c(bit-mask,)g(composed)g(by)g(or)6 b('ing)21 +b(together)g(the)g(following)i(constants:)1071 4270 y +Fy(message/out-of-b)o(and)1071 4370 y(message/peek)1071 +4469 y(message/dont-rou)o(te)888 4746 y FC(See)29 b Fy(read-string)d +FC(and)j Fy(write-string)c FC(for)k(a)h(mor)o(e)f(detailed)g +(description)h(of)888 4845 y(the)21 b(ar)o(guments)g(and)f(r)o(eturn)g +(values.)2071 5147 y(94)p eop +%%Page: 95 101 +95 100 bop 365 614 a Fw(4.6)99 b(Socket)26 b(options)365 +845 y Fy(\(socket-option)38 b FB(socket)21 b(level)g(option)p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(value)699 b FC(pr)o(ocedur)o(e)365 +944 y Fy(\(set-socket-optio)o(n)37 b FB(socket)21 b(level)g(option)f +(value)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(unde\002ned)174 +b FC(pr)o(ocedur)o(e)573 1065 y Fy(socket-option)19 b +FC(and)24 b Fy(set-socket-option)18 b FC(allow)25 b(the)g(inspection)g +(and)g(mod-)573 1164 y(i\002cation,)30 b(r)o(espectively)-9 +b(,)29 b(of)f(several)f(options)i(available)e(on)i(sockets.)48 +b(The)28 b FB(level)573 1264 y FC(ar)o(gument)d(speci\002es)g(what)g +(pr)o(otocol)h(level)f(is)g(to)h(be)f(examined)f(or)i(af)o(fected.)36 +b(A)573 1363 y(level)30 b(of)h Fy(level/socket)26 b FC(speci\002es)31 +b(the)f(highest)i(possible)f(level)g(that)g(is)g(avail-)573 +1463 y(able)24 b(on)h(all)f(socket)g(types.)37 b(A)24 +b(speci\002c)g(pr)o(otocol)h(number)f(can)g(also)h(be)f(used)g(as)573 +1563 y(pr)o(ovided)19 b(by)i Fy(protocol-info)p FC(,)15 +b(described)20 b(below)-8 b(.)573 1691 y(Ther)o(e)25 +b(ar)o(e)f(several)g(dif)o(fer)o(ent)g(classes)h(of)h(socket)g +(options.)41 b(The)26 b(\002rst)g(class)f(con-)573 1791 +y(sists)k(of)g(boolean)g(options)h(which)f(can)f(be)h(either)f(tr)o(ue) +h(or)f(false.)49 b(Examples)28 b(of)573 1890 y(this)21 +b(option)h(type)f(ar)o(e:)756 2048 y Fy(socket/debug)756 +2148 y(socket/accept-c)o(on)o(nec)o(t)756 2247 y(socket/reuse-ad)o(dr)o +(ess)756 2347 y(socket/keep-ali)o(ve)756 2446 y(socket/dont-rou)o(te) +756 2546 y(socket/broadcas)o(t)756 2646 y(socket/use-loop)o(-b)o(ack) +756 2745 y(socket/oob-inli)o(ne)756 2845 y(socket/use-priv)o(il)o(ege)o +(d)756 2945 y(socket/cant-sig)o(na)o(l)756 3044 y(tcp/no-delay)573 +3231 y FC(V)-8 b(alue)17 b(options)h(ar)o(e)e(another)i(category)f(of)g +(socket)g(options.)26 b(Options)18 b(of)g(this)g(type)573 +3330 y(ar)o(e)h(an)i(integer)g(value.)j(Examples)d(of)f(this)i(option)g +(type)e(ar)o(e:)756 3488 y Fy(socket/send-buf)o(fe)o(r)756 +3587 y(socket/receive-)o(bu)o(ffe)o(r)756 3687 y(socket/send-low)o(-w)o +(ate)o(r)756 3786 y(socket/receive-)o(lo)o(w-w)o(at)o(er)756 +3886 y(socket/error)756 3986 y(socket/type)756 4085 y(ip/time-to-live) +756 4185 y(tcp/max-segment)573 4371 y FC(A)d(thir)o(d)h(option)h(type)e +(speci\002es)h(how)h(long)g(for)e(data)g(to)h(linger)g(after)f(a)g +(socket)i(has)573 4471 y(been)24 b(closed.)37 b(Ther)o(e)24 +b(is)h(only)h(one)f(option)h(of)e(this)i(type:)33 b Fy(socket/linger)p +FC(.)f(It)24 b(is)573 4571 y(set)i(with)g(either)g Fy(#f)p +FC(to)f(disable)g(it)h(or)f(an)h(integer)g(number)f(of)h(seconds)g(to)g +(linger)573 4670 y(and)20 b(r)o(eturns)g(a)h(value)f(of)h(the)f(same)h +(type)g(upon)g(inspection.)573 4799 y(The)46 b(fourth)h(and)f(\002nal)h +(option)h(type)e(of)g(this)i(time)f(is)f(a)g(timeout)i(option.)573 +4898 y(Ther)o(e)25 b(ar)o(e)g(two)i(examples)e(of)h(this)h(option)h +(type:)36 b Fy(socket/send-tim)o(eou)o(t)20 b FC(and)1756 +5147 y(95)p eop +%%Page: 96 102 +96 101 bop 888 614 a Fy(socket/receive-ti)o(me)o(out)o +FC(.)20 b(These)g(ar)o(e)f(set)h(with)h(a)f(r)o(eal)f(number)h(of)h +(micr)o(osec-)888 714 y(onds)h(r)o(esolution)f(and)f(r)o(eturns)h(a)f +(value)g(of)h(the)g(same)f(type)h(upon)g(inspection.)681 +1006 y Fw(4.7)99 b(Database-information)24 b(entries)681 +1242 y Fy(\(host-info)39 b FB(name-or-socket-addr)o(ess)p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(host-info)583 b FC(pr)o(ocedur)o(e) +681 1342 y Fy(\(network-info)38 b FB(name-or-socket-addr)o(ess)p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(network-info)319 b +FC(pr)o(ocedur)o(e)681 1441 y Fy(\(service-info)38 b +FB(name-or-number)18 b([pr)o(otocol-name])p Fy(\))56 +b Fu(\000)-15 b(!)59 b FB(service-info)88 b FC(pr)o(ocedur)o(e)681 +1541 y Fy(\(protocol-info)38 b FB(name-or-number)p Fy(\))87 +b Fu(\000)-15 b(!)88 b FB(pr)o(otocol-info)493 b FC(pr)o(ocedur)o(e)888 +1664 y Fy(host-info)22 b FC(allows)k(a)g(pr)o(ogram)f(to)h(look)g(up)g +(a)f(host)h(entry)g(based)f(on)h(either)g(its)888 1764 +y(string)d FB(name)f FC(or)f FB(socket-addr)o(ess)o FC(.)29 +b(The)22 b(value)f(r)o(eturned)f(by)i(this)h(r)o(outine)f(is)g(a)f +FB(host-)888 1864 y(info)g(r)o(ecord)p FC(,)f(de\002ned)h(to)g(have)f +(the)h(following)h(str)o(uctur)o(e:)1071 2027 y Fy(\(define-record)38 +b(host-info)1158 2127 y(name)1480 b(;)44 b(Host)e(name)1158 +2227 y(aliases)1348 b(;)44 b(Alternative)39 b(names)1158 +2326 y(addresses\))1216 b(;)44 b(Host)e(addresses)888 +2522 y(host-info)17 b FC(could)k(fail)f(and)h(raise)f(an)h(err)o(or)e +(for)i(one)g(of)g(the)g(following)h(r)o(easons:)1071 +2685 y Fy(herror/host-not-)o(fou)o(nd)1071 2785 y(herror/try-again)1071 +2885 y(herror/no-recove)o(ry)1071 2984 y(herror/no-data)1071 +3084 y(herror/no-addres)o(s)888 3280 y(network-info)27 +b FC(allows)32 b(a)f(pr)o(ogram)g(to)h(look)h(up)e(a)h(network)g(entry) +g(based)e(on)888 3379 y(either)21 b(its)h(string)f FB(name)g +FC(or)h FB(socket-addr)o(ess)o FC(.)k(The)21 b(value)f(r)o(eturned)g +(by)h(this)h(r)o(outine)888 3479 y(is)f(a)g FB(network-info)f(r)o +(ecord)p FC(,)g(de\002ned)h(to)g(have)f(the)h(following)h(str)o(uctur)o +(e:)1071 3642 y Fy(\(define-record)38 b(network-info)1158 +3742 y(name)1480 b(;)44 b(Network)c(name)1158 3842 y(aliases)1348 +b(;)44 b(Alternative)39 b(names)1158 3941 y(net\))1480 +b(;)44 b(Network)c(number)888 4137 y(service-info)21 +b FC(allows)27 b(a)e(pr)o(ogram)g(to)h(look)h(up)f(a)f(service)g(entry) +h(based)f(on)h(ei-)888 4237 y(ther)e(its)g(string)h FB(name)e +FC(or)h(integer)g FB(port)o FC(.)35 b(The)24 b(value)f(r)o(eturned)g +(by)g(this)i(r)o(outine)f(is)888 4336 y(a)d FB(service-info)g(r)o +(ecord)p FC(,)f(de\002ned)g(to)h(have)f(the)h(following)i(str)o(uctur)o +(e:)1071 4500 y Fy(\(define-record)38 b(service-info)1158 +4599 y(name)1480 b(;)44 b(Service)c(name)1158 4699 y(aliases)1348 +b(;)44 b(Alternative)39 b(names)1158 4799 y(port)1480 +b(;)44 b(Port)e(number)1158 4898 y(protocol\))1260 b(;)44 +b(Protocol)c(name)2071 5147 y FC(96)p eop +%%Page: 97 103 +97 102 bop 573 614 a Fy(protocol-info)12 b FC(allows)19 +b(a)f(pr)o(ogram)f(to)h(look)h(up)f(a)g(pr)o(otocol)g(entry)g(based)f +(on)i(ei-)573 714 y(ther)i(its)g(string)h FB(name)f FC(or)g(integer)g +FB(number)q FC(.)26 b(The)21 b(value)g(r)o(eturned)f(by)h(this)h(r)o +(outine)573 814 y(is)f(a)f FB(pr)o(otocol-info)f(r)o(ecord)p +FC(,)h(de\002ned)h(to)g(have)f(the)h(following)h(str)o(uctur)o(e:)756 +980 y Fy(\(define-record)37 b(protocol-info)843 1079 +y(name)1480 b(;)43 b(Protocol)d(name)843 1179 y(aliases)1348 +b(;)43 b(Alternative)c(names)843 1279 y(number\))1348 +b(;)43 b(Protocol)d(number\))1756 5147 y FC(97)p eop +%%Page: 98 104 +98 103 bop 681 1265 a Fx(Chapter)44 b(5)681 1707 y FD(Strings)51 +b(and)i(characters)681 2190 y FC(Scsh)28 b(pr)o(ovides)f(a)h(set)g(of)h +(pr)o(ocedur)o(es)d(for)i(pr)o(ocessing)h(strings)g(and)e(characters.) +47 b(The)681 2290 y(pr)o(ocedur)o(es)38 b(pr)o(ovided)h(match)h(r)o +(egular)f(expr)o(essions,)45 b(sear)o(ch)39 b(strings,)46 +b(parse)39 b(\002le-)681 2390 y(names,)20 b(and)h(manipulate)f(sets)h +(of)g(characters.)805 2517 y(Also)43 b(see)e(chapters)h(6)f(and)h(7)f +(on)i(r)o(ecor)o(d)d(I/O,)i(\002eld)g(parsing,)47 b(and)42 +b(the)g(awk)681 2616 y(loop.)26 b(The)19 b(pr)o(ocedur)o(es)f +(documented)i(ther)o(e)e(allow)i(you)h(to)f(r)o(ead)e(character)o +(-delimited)681 2716 y(r)o(ecor)o(ds)k(fr)o(om)i(ports,)h(use)f(r)o +(egular)f(expr)o(essions)h(to)h(split)f(the)h(r)o(ecor)o(ds)d(into)j +(\002elds)g(\(for)681 2816 y(example,)k(splitting)h(a)f(string)g(at)f +(every)g(occurr)o(ence)g(of)g(colon)i(or)f(white-space\),)g(and)681 +2915 y(loop)21 b(over)g(str)o(eams)f(of)h(these)g(r)o(ecor)o(ds)e(in)i +(a)f(convenient)i(way)-9 b(.)681 3199 y Fw(5.1)99 b(String)25 +b(manipulation)681 3417 y FC(Strings)33 b(ar)o(e)e(the)h(basic)h +(communication)h(medium)f(for)f(Unix)g(pr)o(ocesses,)j(so)e(a)f(shell) +681 3516 y(language)20 b(must)i(have)e(r)o(easonable)f(facilities)i +(for)f(manipulating)i(them.)681 3774 y FA(5.1.1)81 b(Regular)19 +b(expressions)681 3960 y FC(The)24 b(following)i(functions)f(perform)f +(r)o(egular)f(expr)o(ession)h(matching.)37 b(The)24 b(code)g(uses)681 +4060 y(Henry)d(Spencer)6 b('s)20 b(r)o(egular)f(expr)o(ession)i +(package.)681 4211 y Fy(\(string-match)38 b FB(r)o(egexp)20 +b(string)g([start])p Fy(\))86 b Fu(\000)-14 b(!)87 b +FB(match)19 b(or)i(false)389 b FC(pr)o(ocedur)o(e)888 +4354 y(Sear)o(ch)20 b FB(string)i FC(starting)g(at)f(position)i +FB(start)o FC(,)f(looking)h(for)f(a)f(match)g(for)h FB(r)o(egexp)n +FC(.)28 b(If)22 b(a)888 4454 y(match)d(is)h(found,)f(r)o(eturn)g(a)f +(match)h(str)o(uctur)o(e)g(describing)g(the)g(match,)g(otherwise)888 +4553 y Fy(#f)p FC(.)25 b FB(Start)20 b FC(defaults)g(to)h(0.)681 +4849 y Fy(\(regexp-match?)38 b FB(obj)p Fy(\))87 b Fu(\000)-15 +b(!)88 b FB(boolean)1135 b FC(pr)o(ocedur)o(e)2071 5147 +y(98)p eop +%%Page: 99 105 +99 104 bop 573 614 a FC(Is)21 b(the)g(object)g(a)f(r)o(egular)g(expr)o +(ession)g(match?)365 894 y Fy(\(match:start)39 b FB(match)19 +b([match-number])p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(\002xnum)20 +b(or)h(false)299 b FC(pr)o(ocedur)o(e)573 1028 y(Returns)31 +b(the)g(start)f(position)i(of)e(the)h(match)f(denoted)g(by)h +FB(match-number)o FC(.)55 b(The)573 1127 y(whole)21 b(r)o(egexp)e(is)i +(0.)j(Each)c(further)g(number)g(r)o(epr)o(esents)f(positions)j +(enclosed)e(by)573 1227 y Fy(\(...\))f FC(sections.)26 +b FB(Match-number)20 b FC(defaults)g(to)h(0.)573 1356 +y(If)k(the)h(r)o(egular)e(expr)o(ession)h(matches)h(as)f(a)g(whole,)i +(but)f(a)f(particular)f(par)o(enthe-)573 1456 y(sized)c(sub-expr)o +(ession)g(does)h(not)h(match,)e(then)h Fy(match:start)c +FC(r)o(eturns)j Fy(#f)p FC(.)365 1736 y Fy(\(match:end)40 +b FB(match)19 b([match-number])p Fy(\))85 b Fu(\000)-14 +b(!)87 b FB(\002xnum)643 b FC(pr)o(ocedur)o(e)573 1869 +y(Returns)55 b(the)g(end)g(position)h(of)f(the)g(match)g(denoted)f(by)h +FB(match-number)o FC(.)573 1969 y FB(Match-number)20 +b FC(defaults)g(to)h(0)g(\(the)f(whole)i(match\).)573 +2098 y(If)j(the)h(r)o(egular)e(expr)o(ession)h(matches)h(as)f(a)g +(whole,)i(but)f(a)f(particular)f(par)o(enthe-)573 2198 +y(sized)c(sub-expr)o(ession)g(does)h(not)h(match,)e(then)h +Fy(match:end)c FC(r)o(eturns)k Fy(#f)p FC(.)365 2477 +y Fy(\(match:substring)37 b FB(match)19 b([match-number])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(string)21 b(or)g(false)164 +b FC(pr)o(ocedur)o(e)573 2611 y(Returns)33 b(the)f(substring)h(matched) +f(by)g(match)g FB(match-number)o FC(.)60 b FB(Match-number)573 +2711 y FC(defaults)20 b(to)h(0)f(\(the)h(whole)g(match\).)k(If)c(ther)o +(e)f(was)h(no)g(match,)g(r)o(eturns)f(false.)490 2973 +y(Regular)g(expr)o(ession)g(matching)g(compiles)h(patterns)f(into)g +(special)g(data)f(str)o(uctur)o(es)365 3073 y(which)26 +b(can)f(be)g(ef)o(\002ciently)g(used)f(to)i(match)f(against)g(strings.) +40 b(The)25 b(over)o(head)e(of)i(com-)365 3172 y(piling)e(patterns)e +(that)g(will)h(be)f(used)h(for)f(multiple)h(sear)o(ches)e(can)h(be)g +(avoided)g(by)g(these)365 3272 y(lower)o(-level)f(r)o(outines:)365 +3414 y Fy(\(make-regexp)39 b FB(str)p Fy(\))87 b Fu(\000)-14 +b(!)87 b FB(r)o(e)1416 b FC(pr)o(ocedur)o(e)573 3548 +y(Generate)20 b(a)g(compiled)h(r)o(egular)f(expr)o(ession)g(fr)o(om)h +(the)f(given)i(string.)365 3827 y Fy(\(regexp?)41 b FB(obj)p +Fy(\))87 b Fu(\000)-15 b(!)88 b FB(boolean)1397 b FC(pr)o(ocedur)o(e) +573 3961 y(Is)21 b(the)g(object)g(a)f(r)o(egular)g(expr)o(ession?)365 +4241 y Fy(\(regexp-exec)39 b FB(r)o(egexp)20 b(str)h([start])p +Fy(\))85 b Fu(\000)-14 b(!)87 b FB(match)19 b(or)i(false)544 +b FC(pr)o(ocedur)o(e)573 4375 y(Apply)26 b(the)g(r)o(egular)e(expr)o +(ession)i FB(r)o(egexp)f FC(to)h(the)g(string)h FB(str)f +FC(starting)h(at)e(position)573 4474 y FB(start)p FC(.)g(If)20 +b(the)g(match)h(succeeds)f(it)g(r)o(eturns)g(a)g(r)o(egexp-match,)e +(otherwise)j Fy(#f)p FC(.)k FB(Start)573 4574 y FC(defaults)20 +b(to)h(0.)365 4854 y Fy(\(regexp-quote)39 b FB(str)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(string)1233 b FC(pr)o(ocedur)o(e) +1756 5147 y(99)p eop +%%Page: 100 106 +100 105 bop 888 614 a FC(Returns)24 b(a)f(r)o(egular)e(expr)o(ession)i +(that)g(matches)g(the)g(string)h FB(str)f FC(exactly)-9 +b(.)31 b(In)24 b(other)888 714 y(wor)o(ds,)18 b(it)g(quotes)h(the)f(r)o +(egular)f(expr)o(ession,)h(pr)o(epending)f(backslashes)h(to)g(all)g +(the)888 814 y(special)j(r)o(egexp)e(characters)h(in)h +FB(str)p FC(.)1071 993 y Fy(\(regexp-quote)38 b("*Hello*)i(world."\)) +1245 1093 y Fn(=)-14 b Fu(\))44 b Fy("\\\\*Hello\\\\*)38 +b(world\\\\.")681 1489 y FA(5.1.2)81 b(Other)20 b(string)g +(manipulation)d(facilities)681 1707 y Fy(\(index)41 b +FB(string)21 b(char)f([start])p Fy(\))86 b Fu(\000)-15 +b(!)88 b FB(\002xnum)20 b(or)g(false)732 b FC(pr)o(ocedur)o(e)681 +1806 y Fy(\(rindex)40 b FB(string)21 b(char)f([start])p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(\002xnum)20 b(or)h(false)688 +b FC(pr)o(ocedur)o(e)888 1934 y(These)17 b(pr)o(ocedur)o(es)e(sear)o +(ch)h(thr)o(ough)h FB(string)g FC(looking)i(for)d(an)h(occurr)o(ence)f +(of)g(char)o(-)888 2034 y(acter)k FB(char)p FC(.)25 b +Fy(index)19 b FC(sear)o(ches)g(left-to-right;)i Fy(rindex)d +FC(sear)o(ches)i(right-to-left.)888 2173 y Fy(index)j +FC(r)o(eturns)g(the)i(smallest)f(index)g Fz(i)g FC(of)h +FB(string)f FC(gr)o(eater)e(than)j(or)f(equal)h(to)f +FB(start)888 2273 y FC(such)g(that)e FB(string)p Fn([)p +Fz(i)p Fn(])27 b(=)g FB(char)o FC(.)32 b(The)23 b(default)e(for)i +FB(start)g FC(is)g(zer)o(o.)30 b(If)23 b(ther)o(e)f(is)h(no)h(such)888 +2373 y(match,)d Fy(index)e FC(r)o(eturns)h(false.)888 +2512 y Fy(rindex)39 b FC(r)o(eturns)h(the)h(lar)o(gest)f(index)g +Fz(i)h FC(of)f FB(string)h FC(less)g(than)g FB(start)g +FC(such)g(that)888 2612 y FB(string)p Fn([)p Fz(i)p Fn(])28 +b(=)g FB(char)o FC(.)34 b(The)23 b(default)g(for)g FB(start)g +FC(is)h Fy(\(string-length)38 b FB(string)p Fy(\))p FC(.)33 +b(If)23 b(ther)o(e)888 2711 y(is)e(no)h(such)f(match,)g +Fy(rindex)d FC(r)o(eturns)i(false.)805 2901 y(I)f(should)g(pr)o(obably) +f(snarf)g(all)g(the)h(MIT)f(Scheme)g(string)h(functions,)h(and)e(stick) +h(them)681 3000 y(in)i(a)f(package.)25 b(Unix)20 b(pr)o(ograms)h(need)f +(to)h(mung)h(character)d(strings)j(a)e(lot.)805 3135 +y(MIT)g(string)i(match)f(commands:)888 3235 y Fy([sub]string-match)o +(-f)o(orw)o(ar)o(d,b)o(ac)o(kwa)o(rd)o([-)o(ci])888 3334 +y([sub]string-prefi)o(x,)o(suf)o(fi)o(x[-)o(ci)o(]?)888 +3434 y([sub]string-find-)o(ne)o(xt,)o(pr)o(evi)o(ou)o(s-c)o(ha)o(r[)o +(-ci)o(])888 3533 y([sub]string-find-)o(ne)o(xt,)o(pr)o(evi)o(ou)o(s-c) +o(ha)o(r-)o(in-)o(se)o(t)888 3633 y([sub]string-repla)o(ce)o([!])888 +3733 y(...)p Fs(etc.)681 3832 y FC(These)f(ar)o(e)g(not)h(curr)o(ently) +g(pr)o(ovided.)681 3988 y Fy(\(substitute-env-)o(va)o(rs)37 +b FB(fname)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(string)816 +b FC(pr)o(ocedur)o(e)888 4136 y(Replace)24 b(occurr)o(ences)f(of)i +(envir)o(onment)g(variables)e(with)i(their)f(values.)36 +b(An)24 b(en-)888 4236 y(vir)o(onment)19 b(variable)d(is)j(denoted)e +(by)h(a)g(dollar)f(sign)i(followed)f(by)g(alphanumeric)888 +4336 y(chars)j(and)f(underscor)o(es,)g(or)h(is)g(surr)o(ounded)f(by)h +(braces.)1071 4512 y Fy(\(substitute-env-)o(var)o(s)37 +b("$USER/.login"\))1237 4611 y Fn(=)-14 b Fu(\))104 b +Fy("shivers/.login)o(")1071 4711 y(\(substitute-env-)o(var)o(s)37 +b("$)p Fu(f)p Fy(USER)p Fu(g)p Fy(_log"\))77 b Fn(=)-14 +b Fu(\))104 b Fy("shivers_log")2051 5147 y FC(100)p eop +%%Page: 101 107 +101 106 bop 365 614 a FA(5.1.3)81 b(Manipulating)18 b(\002le-names)365 +797 y FC(These)27 b(pr)o(ocedur)o(es)d(do)j(not)g(access)f(the)g +(\002le-system)h(at)f(all;)j(they)e(mer)o(ely)e(operate)h(on)365 +897 y(\002le-name)f(strings.)38 b(Much)24 b(of)h(this)h(str)o(uctur)o +(e)e(is)h(patterned)e(after)h(the)h(gnu)g(emacs)f(de-)365 +997 y(sign.)59 b(Per)o(haps)31 b(a)g(mor)o(e)h(sophisticated)g(system)g +(would)g(be)g(better)-6 b(,)33 b(something)g(like)365 +1096 y(the)23 b(pathname)f(abstractions)g(of)j(C)t Ft(O)t(M)t(M)t(O)t +(N)i FC(L)t Ft(I)t(S)t(P)e FC(or)d(MIT)g(Scheme.)30 b(However)-6 +b(,)22 b(being)365 1196 y(Unix-speci\002c,)e(we)h(can)g(be)f(a)g +(little)h(less)g(general.)365 1446 y FA(T)-9 b(erminology)365 +1629 y FC(These)30 b(pr)o(ocedur)o(es)e(car)o(efully)h(adher)o(e)f(to)i +(the)i(P)t Ft(O)t(S)t(I)t(X)i FC(standar)o(d)28 b(for)i(\002le-name)f +(r)o(eso-)365 1729 y(lution,)g(which)f(occasionally)f(entails)g(some)g +(slightly)h(odd)f(things.)44 b(This)27 b(section)h(will)365 +1828 y(describe)20 b(these)h(r)o(ules,)g(and)f(give)h(some)g(basic)g +(terminology)-9 b(.)490 1953 y(A)17 b FB(\002le-name)g +FC(is)h(either)f(the)g(\002le-system)h(r)o(oot)g(\(\223/\224\),)e(or)i +(a)e(series)i(of)f(slash-terminated)365 2053 y(dir)o(ectory)27 +b(components,)k(followed)d(by)g(a)g(a)f(\002le)h(component.)48 +b(Root)30 b(is)e(the)g(only)h(\002le-)365 2152 y(name)21 +b(that)g(may)f(end)h(in)g(slash.)26 b(Some)21 b(examples:)738 +2342 y(File)g(name)395 b(Dir)21 b(components)207 b(File)21 +b(component)p 688 2375 2220 4 v 738 2445 a Fy(src/des/main.c)137 +b(\("src")41 b("des"\))228 b("main.c")738 2544 y(/src/des/main.c)93 +b(\("")42 b("src")g("des"\))97 b("main.c")738 2644 y(main.c)489 +b(\(\))709 b("main.c")490 2831 y FC(Note)24 b(that)g(the)g(r)o(elative) +f(\002lename)h Fy(src/des/main.c)18 b FC(and)23 b(the)i(absolute)e +(\002lename)365 2931 y Fy(/src/des/main.c)17 b FC(ar)o(e)k +(distinguished)j(by)f(the)g(pr)o(esence)e(of)i(the)g(r)o(oot)f +(component)i Fy("")365 3030 y FC(in)e(the)e(absolute)h(path.)490 +3155 y(Multiple)h(embedded)f(slashes)h(within)i(a)d(path)h(have)g(the)g +(same)g(meaning)h(as)f(a)f(sin-)365 3254 y(gle)27 b(slash.)42 +b(Mor)o(e)26 b(than)g(two)h(leading)f(slashes)h(at)f(the)h(beginning)g +(of)g(a)e(path)i(have)e(the)365 3354 y(same)d(meaning)h(as)f(a)g +(single)h(leading)f(slash\227they)h(indicate)f(that)h(the)f +(\002le-name)g(is)h(an)365 3454 y(absolute)d(one,)g(with)g(the)g(path)f +(leading)g(fr)o(om)g(r)o(oot.)25 b(However)-6 b(,)21 +b(P)t Ft(O)t(S)t(I)t(X)i FC(permits)d(the)g(OS)365 3553 +y(to)j(give)f(special)g(meaning)h(to)g FB(two)f FC(leading)g(slashes.) +31 b(For)23 b(this)g(r)o(eason,)f(the)g(r)o(outines)h(in)365 +3653 y(this)f(section)f(do)g(not)h(simplify)f(two)g(leading)g(slashes)g +(to)g(a)f(single)i(slash.)490 3778 y(A)e(\002le-name)g(in)h +FB(dir)o(ectory)e(form)h FC(is)h(either)f(a)g(\002le-name)g(terminated) +g(by)g(a)g(slash,)g FB(e.g.)p FC(,)365 3877 y(\223)p +Fy(/src/des/)p FC(\224,)14 b(or)19 b(the)f(empty)h(string,)g(\223\224.) +24 b(The)18 b(empty)g(string)h(corr)o(esponds)f(to)h(the)g(cur)o(-)365 +3977 y(r)o(ent)g(working)h(dir)o(ectory)-9 b(,)18 b(whose)i +(\002le-name)f(is)h(dot)f(\(\223)p Fy(.)p FC(\224\).)k(W)-8 +b(orking)20 b(backwar)o(ds)e(fr)o(om)365 4076 y(the)g(append-a-slash)e +(r)o(ule,)i(we)g(extend)f(the)h(syntax)g(of)i(P)t Ft(O)t(S)t(I)t(X)h +FC(\002le-names)d(to)g(de\002ne)f(the)365 4176 y(empty)22 +b(string)f(to)h(be)f(a)f(\002le-name)h(form)g(of)g(the)h(r)o(oot)f(dir) +o(ectory)f(\223)p Fy(/)p FC(\224.)25 b(\(However)-6 b(,)20 +b(\223)p Fy(/)p FC(\224)g(is)365 4276 y(also)26 b(acceptable)d(as)j(a)e +(\002le-name)h(form)h(for)f(r)o(oot.\))39 b(So)25 b(the)h(empty)f +(string)h(has)f(two)h(in-)365 4375 y(terpr)o(etations:)f(as)19 +b(a)h(\002le-name)f(form,)h(it)h(is)f(the)g(\002le-system)g(r)o(oot;)g +(as)g(a)g(dir)o(ectory)f(form,)365 4475 y(it)24 b(is)g(the)f(curr)o +(ent)g(working)h(dir)o(ectory)-9 b(.)33 b(Slash)23 b(is)h(also)f(an)g +(ambiguous)h(form:)31 b Fy(/)23 b FC(is)h(both)365 4575 +y(a)d(dir)o(ectory-form)e(and)i(a)f(\002le-name)g(form.)490 +4699 y(The)51 b(dir)o(ectory)g(form)g(of)h(a)f(\002le-name)g(is)g(very) +g(rar)o(ely)f(used.)118 b(Almost)52 b(all)365 4799 y(of)61 +b(the)f(pr)o(ocedur)o(es)f(in)h(scsh)h(name)f(dir)o(ectories)g(by)g +(giving)h(their)g(\002le-name)365 4898 y(form)45 b(\(without)g(the)f +(trailing)g(slash\),)50 b(not)45 b(their)f(dir)o(ectory)g(form.)95 +b(So,)50 b(you)45 b(say)1735 5147 y(101)p eop +%%Page: 102 108 +102 107 bop 681 614 a FC(\223)p Fy(/usr/include)p FC(\224,)22 +b(and)k(\223)p Fy(.)p FC(\224,)h(not)h(\223)p Fy(/usr/include/)p +FC(\224)20 b(and)27 b(\223\224.)43 b(The)27 b(sole)g(exceptions)681 +714 y(ar)o(e)g Fy(file-name-as-dire)o(cto)o(ry)22 b FC(and)29 +b Fy(directory-as-fil)o(e-)o(nam)o(e)p FC(,)c(whose)30 +b(jobs)f(ar)o(e)681 814 y(to)34 b(convert)h(back-and-forth)d(between)i +(these)h(forms,)i(and)d Fy(file-name-directo)o(ry)o FC(,)681 +913 y(whose)22 b(job)h(it)e(is)h(to)g(split)g(out)g(the)g(dir)o(ectory) +f(portion)h(of)g(a)f(\002le-name.)28 b(However)-6 b(,)21 +b(most)681 1013 y(pr)o(ocedur)o(es)k(that)i(expect)g(a)g(dir)o(ectory)f +(ar)o(gument)h(will)h(coer)o(ce)e(a)h(\002le-name)g(in)h(dir)o(ec-)681 +1112 y(tory)f(form)g(to)g(\002le-name)f(form)h(if)f(it)h(does)g(not)h +(have)e(a)g(trailing)h(slash.)44 b(Bear)25 b(in)j(mind)681 +1212 y(that)e(the)h(ambiguous)g(case,)g(empty)g(string,)h(will)f(be)f +(interpr)o(eted)f(in)i(\002le-name)f(form,)681 1312 y +FB(i.e.)p FC(,)20 b(as)h(r)o(oot.)681 1624 y FA(Procedures)681 +1855 y Fy(\(file-name-direc)o(to)o(ry?)37 b FB(fname)p +Fy(\))86 b Fu(\000)-14 b(!)87 b FB(boolean)726 b FC(pr)o(ocedur)o(e)681 +1955 y Fy(\(file-name-non-d)o(ir)o(ect)o(or)o(y?)37 b +FB(fname)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(boolean)551 +b FC(pr)o(ocedur)o(e)888 2087 y(These)18 b(pr)o(edicates)f(r)o(eturn)g +(tr)o(ue)i(if)f(the)g(string)h(is)f(in)h(dir)o(ectory)e(form,)i(or)f +(\002le-name)888 2187 y(form)24 b(\(see)f(the)h(above)f(discussion)i +(of)f(these)f(two)i(forms\).)34 b(Note)24 b(that)f(they)h(both)888 +2286 y(r)o(eturn)19 b(tr)o(ue)h(on)g(the)g(ambiguous)h(case)e(of)g +(empty)h(string,)g(which)h(is)f(both)g(a)g(dir)o(ec-)888 +2386 y(tory)h(\(curr)o(ent)f(working)i(dir)o(ectory\),)d(and)i(a)f +(\002le)h(name)f(\(the)h(\002le-system)g(r)o(oot\).)1202 +2536 y(File)g(name)177 b Fy(...-directory?)94 b(...-non-director)o(y?)p +1152 2570 2130 4 v 1202 2639 a("src/des")139 b(#f)622 +b(#t)1202 2739 y("src/des/")95 b(#t)622 b(#f)1202 2839 +y("/")403 b(#t)622 b(#f)1202 2938 y(".")403 b(#f)622 +b(#t)1202 3038 y("")447 b(#t)622 b(#t)681 3276 y(\(file-name-as-di)o +(re)o(cto)o(ry)37 b FB(fname)p Fy(\))87 b Fu(\000)-15 +b(!)88 b FB(string)685 b FC(pr)o(ocedur)o(e)888 3433 +y(Convert)29 b(a)g(\002le-name)f(to)h(dir)o(ectory)f(form.)50 +b(Basically)-9 b(,)30 b(add)e(a)g(trailing)h(slash)g(if)888 +3532 y(needed:)1071 3688 y Fy(\(file-name-as-di)o(rec)o(to)o(ry)37 +b("src/des"\))123 b Fn(=)-14 b Fu(\))103 b Fy("src/des/")1071 +3788 y(\(file-name-as-di)o(rec)o(to)o(ry)37 b("src/des/"\))79 +b Fn(=)-14 b Fu(\))103 b Fy("src/des/")1071 3965 y(.)p +FC(,)20 b Fy(/)p FC(,)g(and)g Fy("")g FC(ar)o(e)g(special:)1071 +4065 y Fy(\(file-name-as-di)o(rec)o(to)o(ry)37 b("."\))387 +b Fn(=)-14 b Fu(\))103 b Fy("")1071 4165 y(\(file-name-as-di)o(rec)o +(to)o(ry)37 b("/"\))387 b Fn(=)-14 b Fu(\))103 b Fy("/")1071 +4264 y(\(file-name-as-di)o(rec)o(to)o(ry)37 b(""\))431 +b Fn(=)-14 b Fu(\))103 b Fy("/")681 4642 y(\(directory-as-fi)o(le)o +(-na)o(me)37 b FB(fname)p Fy(\))87 b Fu(\000)-15 b(!)88 +b FB(string)685 b FC(pr)o(ocedur)o(e)888 4799 y(Convert)21 +b(a)g(dir)o(ectory)f(to)h(a)f(simple)i(\002le-name.)j(Basically)-9 +b(,)20 b(kill)h(a)g(trailing)g(slash)g(if)888 4898 y(one)h(is)f(pr)o +(esent:)2051 5147 y(102)p eop +%%Page: 103 109 +103 108 bop 756 601 a Fy(\(directory-as-f)o(il)o(e-n)o(am)o(e)38 +b("foo/bar/"\))78 b Fn(=)-14 b Fu(\))104 b Fy("foo/bar")756 +779 y(/)20 b FC(and)g Fy("")g FC(ar)o(e)f(special:)756 +878 y Fy(\(directory-as-f)o(il)o(e-n)o(am)o(e)38 b("/"\))386 +b Fn(=)-14 b Fu(\))104 b Fy("/")756 978 y(\(directory-as-f)o(il)o(e-n)o +(am)o(e)38 b(""\))430 b Fn(=)-14 b Fu(\))104 b Fy(".")19 +b FC(\()p FB(i.e.)p FC(,)h(the)h(cwd\))365 1269 y Fy +(\(file-name-absolu)o(te)o(?)38 b FB(fname)p Fy(\))86 +b Fu(\000)-14 b(!)87 b FB(boolean)770 b FC(pr)o(ocedur)o(e)573 +1412 y(Does)20 b FB(fname)f FC(begin)h(with)g(a)f(r)o(oot)h(or)f +Fy(~)h FC(component?)26 b(\(Recognising)21 b Fy(~)e FC(as)g(a)g(home-) +573 1511 y(dir)o(ectory)h(speci\002cation)h(is)g(an)g(extension)g(of)i +(P)t Ft(O)t(S)t(I)t(X)h FC(r)o(ules.\))756 1654 y Fy(\(file-name-abso)o +(lu)o(te?)37 b("/usr/shivers"\))77 b Fn(=)-14 b Fu(\))103 +b Fy(#t)756 1754 y(\(file-name-abso)o(lu)o(te?)37 b("src/des"\))297 +b Fn(=)-14 b Fu(\))103 b Fy(#f)756 1854 y(\(file-name-abso)o(lu)o(te?) +37 b("~/src/des"\))209 b Fn(=)-14 b Fu(\))103 b Fy(#t)756 +2031 y FC(Non-obvious)21 b(case:)756 2131 y Fy(\(file-name-abso)o(lu)o +(te?)37 b(""\))605 b Fn(=)-14 b Fu(\))103 b Fy(#t)20 +b FC(\()p FB(i.e.)p FC(,)g(r)o(oot\))365 2422 y Fy(\(file-name-direct)o +(or)o(y)38 b FB(fname)p Fy(\))86 b Fu(\000)-14 b(!)87 +b FB(string)21 b(or)g(false)559 b FC(pr)o(ocedur)o(e)573 +2565 y(Return)30 b(the)f(dir)o(ectory)g(component)h(of)f +FB(fname)h FC(in)g(dir)o(ectory)e(form.)51 b(If)29 b(the)h(\002le-)573 +2664 y(name)21 b(is)g(alr)o(eady)e(in)i(dir)o(ectory)f(form,)g(r)o +(eturn)g(it)h(as-is.)756 2807 y Fy(\(file-name-dire)o(ct)o(ory)37 +b("/usr/bdc"\))165 b Fn(=)-14 b Fu(\))104 b Fy("/usr/")756 +2907 y(\(file-name-dire)o(ct)o(ory)37 b("/usr/bdc/"\))121 +b Fn(=)-14 b Fu(\))104 b Fy("/usr/bdc/")756 3007 y(\(file-name-dire)o +(ct)o(ory)37 b("bdc/.login"\))77 b Fn(=)-14 b Fu(\))104 +b Fy("bdc/")756 3106 y(\(file-name-dire)o(ct)o(ory)37 +b("main.c"\))253 b Fn(=)-14 b Fu(\))104 b Fy("")756 3284 +y FC(Root)21 b(has)g(no)h(dir)o(ectory)e(component:)756 +3383 y Fy(\(file-name-dire)o(ct)o(ory)37 b("/"\))473 +b Fn(=)-14 b Fu(\))104 b Fy("")756 3483 y(\(file-name-dire)o(ct)o(ory) +37 b(""\))517 b Fn(=)-14 b Fu(\))104 b Fy("")365 3774 +y(\(file-name-nondir)o(ec)o(tor)o(y)37 b FB(fname)p Fy(\))87 +b Fu(\000)-14 b(!)87 b FB(string)686 b FC(pr)o(ocedur)o(e)573 +3917 y(Return)21 b(non-dir)o(ectory)g(component)h(of)e(fname.)756 +4060 y Fy(\(file-name-nond)o(ir)o(ect)o(or)o(y)38 b("/usr/ian"\))165 +b Fn(=)-14 b Fu(\))104 b Fy("ian")756 4159 y(\(file-name-nond)o(ir)o +(ect)o(or)o(y)38 b("/usr/ian/"\))121 b Fn(=)-14 b Fu(\))104 +b Fy("")756 4259 y(\(file-name-nond)o(ir)o(ect)o(or)o(y)38 +b("ian/.login"\))77 b Fn(=)-14 b Fu(\))104 b Fy(".login")756 +4359 y(\(file-name-nond)o(ir)o(ect)o(or)o(y)38 b("main.c"\))253 +b Fn(=)-14 b Fu(\))104 b Fy("main.c")756 4458 y(\(file-name-nond)o(ir)o +(ect)o(or)o(y)38 b(""\))517 b Fn(=)-14 b Fu(\))104 b +Fy("")756 4558 y(\(file-name-nond)o(ir)o(ect)o(or)o(y)38 +b("/"\))473 b Fn(=)-14 b Fu(\))104 b Fy("/")365 4849 +y(\(split-file-name)37 b FB(fname)p Fy(\))87 b Fu(\000)-14 +b(!)87 b FB(string)21 b(list)864 b FC(pr)o(ocedur)o(e)1735 +5147 y(103)p eop +%%Page: 104 110 +104 109 bop 888 614 a FC(Split)21 b(a)f(\002le-name)h(into)g(its)g +(components.)1071 757 y Fy(\(split-file-name)37 b("src/des/main.c")o +(\))1237 857 y Fn(=)-14 b Fu(\))267 b Fy(\("src")41 b("des")g +("main.c"\))1071 1015 y(\(split-file-name)c("/src/des/main.c)o("\))1237 +1114 y Fn(=)-14 b Fu(\))136 b Fy(\("")42 b("src")g("des")f("main.c"\)) +1071 1272 y(\(split-file-name)c("main.c"\))1237 1372 +y Fn(=)-14 b Fu(\))790 b Fy(\("main.c"\))1071 1530 y(\(split-file-name) +37 b("/"\))1237 1630 y Fn(=)-14 b Fu(\))104 b Fy(\(""\))681 +1920 y(\(path-list->file)o(-n)o(ame)37 b FB(path-list)19 +b([dir])p Fy(\))86 b Fu(\000)-15 b(!)88 b FB(string)521 +b FC(pr)o(ocedur)o(e)888 2062 y(Inverse)21 b(of)g Fy(split-file-name)o +FC(.)1071 2230 y Fy(\(path-list->file)o(-na)o(me)37 b('\("src")k("des") +g("main.c"\)\))1245 2329 y Fn(=)-14 b Fu(\))87 b Fy("src/des/main.c") +1071 2429 y(\(path-list->file)o(-na)o(me)37 b('\("")42 +b("src")f("des")h("main.c"\)\))1245 2528 y Fn(=)-14 b +Fu(\))87 b Fy("/src/des/main.c")1071 2728 y FC(Optional)21 +b FB(dir)g FC(ar)o(g)f(anchors)h(r)o(elative)e(path-lists:)1071 +2827 y Fy(\(path-list->file)o(-na)o(me)37 b('\("src")k("des")g +("main.c"\))2030 2927 y("/usr/shivers"\))1245 3027 y +Fn(=)-14 b Fu(\))87 b Fy("/usr/shivers/src)o(/d)o(es/)o(ma)o(in)o(.c") +888 3194 y FC(The)21 b(optional)h FB(dir)e FC(ar)o(gument)g(is)i +(usefully)f Fy(\(cwd\))p FC(.)681 3488 y Fy(\(file-name-exten)o(si)o +(on)37 b FB(fname)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(string)816 +b FC(pr)o(ocedur)o(e)888 3630 y(Return)22 b(the)e(\002le-name's)h +(extension.)1071 3751 y Fy(\(file-name-exten)o(sio)o(n)37 +b("main.c"\))341 b Fn(=)-14 b Fu(\))104 b Fy(".c")1071 +3850 y(\(file-name-exten)o(sio)o(n)37 b("main.c.old"\))165 +b Fn(=)-14 b Fu(\))104 b Fy(".old")1071 3950 y(\(file-name-exten)o(sio) +o(n)37 b("/usr/shivers"\))77 b Fn(=)-14 b Fu(\))104 b +Fy("")1071 4099 y FC(W)-8 b(eir)o(d)20 b(cases:)1071 +4199 y Fy(\(file-name-exten)o(sio)o(n)37 b("foo."\))124 +b Fn(=)-14 b Fu(\))104 b Fy(".")1071 4298 y(\(file-name-exten)o(sio)o +(n)37 b("foo.."\))80 b Fn(=)-14 b Fu(\))104 b Fy(".")1071 +4447 y FC(Dot)21 b(\002les)h(ar)o(e)d(not)i(extensions:)1071 +4547 y Fy(\(file-name-exten)o(sio)o(n)37 b("/usr/shivers/.lo)o(gi)o +(n"\))76 b Fn(=)-14 b Fu(\))104 b Fy("")681 4850 y(\(file-name-sans-)o +(ex)o(ten)o(si)o(on)37 b FB(fname)p Fy(\))87 b Fu(\000)-14 +b(!)87 b FB(string)598 b FC(pr)o(ocedur)o(e)2051 5147 +y(104)p eop +%%Page: 105 111 +105 110 bop 573 614 a FC(Return)21 b(everything)g(but)g(the)g +(extension.)756 757 y Fy(\(file-name-sans)o(-e)o(xte)o(ns)o(ion)37 +b("main.c"\))253 b Fn(=)-14 b Fu(\))104 b Fy("main")756 +856 y(\(file-name-sans)o(-e)o(xte)o(ns)o(ion)37 b("main.c.old"\))77 +b Fn(=)-14 b Fu(\))104 b Fy("main.c"")756 956 y(\(file-name-sans)o(-e)o +(xte)o(ns)o(ion)37 b("/usr/shivers"\))922 1056 y Fn(=)-14 +b Fu(\))103 b Fy("/usr/shivers")756 1205 y FC(W)-8 b(eir)o(d)20 +b(cases:)756 1304 y Fy(\(file-name-sans)o(-e)o(xte)o(ns)o(ion)37 +b("foo."\))123 b Fn(=)-14 b Fu(\))104 b Fy("foo")756 +1404 y(\(file-name-sans)o(-e)o(xte)o(ns)o(ion)37 b("foo.."\))79 +b Fn(=)-14 b Fu(\))104 b Fy("foo.")756 1581 y FC(Dot)21 +b(\002les)g(ar)o(e)e(not)j(extensions:)756 1681 y Fy(\(file-name-sans)o +(-e)o(xte)o(ns)o(ion)37 b("/usr/shivers/.l)o(og)o(in)o("\))922 +1781 y Fn(=)-14 b Fu(\))103 b Fy("/usr/shivers/.l)o(ogi)o(n)573 +1994 y FC(Note)39 b(that)h(appending)f(the)h(r)o(esults)f(of)g +Fy(file-name-extens)o(ion)33 b FC(and)39 b Fy(file-)573 +2093 y(name-sans-extens)o(io)o(n)15 b FC(in)21 b(all)g(cases)f(pr)o +(oduces)g(the)h(original)g(\002le-name.)365 2386 y Fy +(\(parse-file-name)37 b FB(fname)p Fy(\))87 b Fu(\000)-14 +b(!)87 b FB([dir)20 b(name)h(extension])502 b FC(pr)o(ocedur)o(e)573 +2529 y(Let)31 b Fz(f)39 b FC(be)31 b Fy(\(file-name-nondir)o(ec)o(tor)o +(y)37 b FB(fname)p Fy(\))p FC(.)57 b(This)32 b(function)g(r)o(eturns)e +(the)573 2628 y(thr)o(ee)20 b(values:)672 2796 y Fu(\017)42 +b Fy(\(file-name-dire)o(ct)o(ory)37 b FB(fname)p Fy(\))672 +2930 y Fu(\017)42 b Fy(\(file-name-sans)o(-e)o(xte)o(ns)o(ion)37 +b FB(f)p Fy(\)\))672 3063 y Fu(\017)42 b Fy(\(file-name-exte)o(ns)o +(ion)37 b FB(f)p Fy(\))573 3231 y FC(The)d(inverse)g(of)g +Fy(parse-file-name)p FC(,)d(in)k(all)f(cases,)j(is)d +Fy(string-append)p FC(.)61 b(The)573 3331 y(boundary)20 +b(case)h(of)f Fy(/)h FC(was)f(chosen)i(to)f(pr)o(eserve)e(this)j +(inverse.)365 3624 y Fy(\(replace-extensio)o(n)37 b FB(fname)21 +b(ext)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(string)782 +b FC(pr)o(ocedur)o(e)573 3766 y(This)26 b(pr)o(ocedur)o(e)e(r)o +(eplaces)g FB(fname)p FC('s)i(extension)h(with)f FB(ext)p +FC(.)40 b(It)26 b(is)g(exactly)f(equiva-)573 3866 y(lent)c(to)756 +4006 y Fy(\(string-append)37 b(\(file-name-sans-e)o(xt)o(ens)o(io)o(n)h +FB(fname)p Fy(\))43 b FB(ext)o Fy(\))365 4358 y(\(simplify-file-na)o +(me)37 b FB(fname)p Fy(\))87 b Fu(\000)-15 b(!)88 b FB(string)860 +b FC(pr)o(ocedur)o(e)573 4500 y(Removes)29 b(leading)g(and)f(internal)h +(occurr)o(ences)e(of)i(dot.)49 b(A)28 b(trailing)h(dot)g(is)g(left)573 +4599 y(alone,)g(as)e(the)h(par)o(ent)e(could)i(be)f(a)h(symlink.)47 +b(Removes)28 b(internal)g(and)f(trailing)573 4699 y(double-slashes.)37 +b(A)25 b(leading)g(double-slash)f(is)h(left)g(alone,)h(in)f(accor)o +(dance)e(with)575 4799 y(P)t Ft(O)t(S)t(I)t(X)r FC(.)30 +b(However)-6 b(,)22 b(triple)g(and)f(mor)o(e)h(leading)f(slashes)i(ar)o +(e)d(r)o(educed)g(to)i(a)g(single)573 4898 y(slash,)k(in)g(accor)o +(dance)d(with)28 b(P)t Ft(O)t(S)t(I)t(X)r FC(.)41 b(Double-dots)25 +b(\(par)o(ent)f(dir)o(ectory\))g(ar)o(e)g(left)1735 5147 +y(105)p eop +%%Page: 106 112 +106 111 bop 888 614 a FC(alone,)27 b(in)e(case)g(they)g(come)h(after)e +(symlinks)j(or)e(appear)f(in)h(a)g Fy(/../)p FB(machine)n +Fy(/...)888 714 y FC(\223super)o(-r)o(oot\224)19 b(form)i(\(which)i(P)t +Ft(O)t(S)t(I)t(X)h FC(permits\).)681 950 y Fy(\(resolve-file-na)o(me)37 +b FB(fname)21 b([dir])p Fy(\))86 b Fu(\000)-15 b(!)88 +b FB(string)730 b FC(pr)o(ocedur)o(e)988 1106 y Fu(\017)41 +b FC(Do)21 b Fy(~)g FC(expansion.)988 1254 y Fu(\017)41 +b FC(If)23 b FB(dir)h FC(is)g(given,)g(convert)g(a)f(r)o(elative)g +(\002le-name)g(to)h(an)g(absolute)g(\002le-name,)1071 +1354 y(r)o(elative)19 b(to)j(dir)o(ectory)d FB(dir)p +FC(.)681 1590 y Fy(\(expand-file-nam)o(e)37 b FB(fname)21 +b([dir])p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(string)774 +b FC(pr)o(ocedur)o(e)888 1746 y(Resolve)22 b(and)e(simplify)h(the)g +(\002le-name.)681 2082 y Fy(\(home-dir)40 b FB([user])p +Fy(\))87 b Fu(\000)-15 b(!)88 b FB(string)1300 b FC(pr)o(ocedur)o(e)888 +2238 y Fy(home-dir)17 b FC(r)o(eturns)j FB(user)q FC('s)g(home)h(dir)o +(ectory)-9 b(.)24 b FB(User)d FC(defaults)e(to)h(the)g(curr)o(ent)g +(user)-6 b(.)1071 2438 y Fy(\(home-dir\))471 b Fn(=)-14 +b Fu(\))104 b Fy("/user1/lecture)o(r/s)o(hi)o(ver)o(s")1071 +2537 y(\(home-dir)40 b("ctkwan"\))79 b Fn(=)-14 b Fu(\))104 +b Fy("/user0/researc)o(h/c)o(tk)o(wan)o(")681 2946 y(\(home-file)39 +b FB([user])21 b(fname)p Fy(\))87 b Fu(\000)-14 b(!)87 +b FB(string)1033 b FC(pr)o(ocedur)o(e)888 3103 y(Returns)21 +b(\002le-name)e FB(fname)h FC(r)o(elative)f(to)h FB(user)q +FC('s)g(home)h(dir)o(ectory;)e FB(user)i FC(defaults)e(to)888 +3202 y(the)i(curr)o(ent)f(user)-6 b(.)1071 3356 y Fy(\(home-file)39 +b("man"\))473 b Fn(=)-14 b Fu(\))104 b Fy("/usr/shivers/ma)o(n")1071 +3456 y(\(home-file)39 b("fcmlau")i("man"\))80 b Fn(=)-14 +b Fu(\))104 b Fy("/usr/fcmlau/man)o(")805 3824 y FC(The)26 +b(general)e Fy(substitute-env-va)o(rs)19 b FC(string)26 +b(pr)o(ocedur)o(e,)e(de\002ned)h(in)h(the)f(pr)o(evi-)681 +3923 y(ous)c(section,)g(is)g(also)g(fr)o(equently)g(useful)g(for)f +(expanding)h(\002le-names.)681 4258 y Fw(5.2)99 b(ASCII)24 +b(encoding)681 4519 y Fy(\(char->ascii)38 b FB(character)p +Fy(\))87 b Fu(\000)-15 b(!)87 b FB(integer)1029 b FC(pr)o(ocedur)o(e) +681 4619 y Fy(\(ascii->char)38 b FB(integer)p Fy(\))87 +b Fu(\000)-14 b(!)87 b FB(character)1028 b FC(pr)o(ocedur)o(e)888 +4751 y(These)36 b(ar)o(e)f(identical)g(to)i Fy(char->integer)30 +b FC(and)35 b Fy(integer->char)c FC(except)k(that)888 +4851 y(they)21 b(use)g(the)i(A)t Ft(S)t(C)t(I)t(I)h FC(encoding.)2051 +5147 y(106)p eop +%%Page: 107 113 +107 112 bop 365 614 a Fw(5.3)99 b(Character)25 b(sets)365 +828 y FC(Scsh)c(pr)o(ovides)g(a)f Fy(char-set)e FC(type)j(for)g(expr)o +(essing)f(sets)i(of)f(characters.)k(These)c(sets)g(ar)o(e)365 +928 y(used)d(by)h(some)g(of)f(the)h(delimited-input)f(pr)o(ocedur)o(es) +f(\(section)h(7.1\).)23 b(The)c(character)e(set)365 1028 +y(package)j(that)h(scsh)g(uses)g(was)g(taken)f(fr)o(om)h(Pr)o(oject)f +(Mac's)g(MIT)g(Scheme.)365 1175 y Fy(\(char-set?)40 b +FB(x)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(boolean)1367 +b FC(pr)o(ocedur)o(e)573 1315 y(Returns)21 b(tr)o(ue)g(if)g(the)g +(object)g FB(x)f FC(is)h(a)f(character)g(set.)365 1580 +y FA(5.3.1)81 b(Creating)20 b(character)f(sets)365 1786 +y Fy(\(char-set)40 b FB(char)946 1798 y Fv(1)983 1786 +y FB(.)12 b(.)g(.)g Fy(\))87 b Fu(\000)-14 b(!)87 b FB(char-set)1156 +b FC(pr)o(ocedur)o(e)573 1910 y(Return)21 b(a)f(character)g(set)g +(containing)i(the)f(given)g(characters.)365 2098 y Fy +(\(chars->char-set)37 b FB(chars)p Fy(\))87 b Fu(\000)-14 +b(!)87 b FB(char-set)955 b FC(pr)o(ocedur)o(e)573 2238 +y(Return)21 b(a)f(character)g(set)g(containing)i(the)f(characters)f(in) +h(the)g(list)g FB(chars)p FC(.)365 2426 y Fy(\(string->char-set)37 +b FB(s)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(char-set)1056 +b FC(pr)o(ocedur)o(e)573 2565 y(Return)21 b(a)f(character)g(set)g +(containing)i(the)f(characters)f(in)h(the)g(string)g +FB(s)q FC(.)365 2753 y Fy(\(predicate->char-)o(se)o(t)38 +b FB(pr)o(ed)p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(char-set)812 +b FC(pr)o(ocedur)o(e)573 2892 y(Returns)30 b(a)f(character)f(set)i +(containing)g(every)f(character)f FB(c)h FC(such)h(that)g +Fy(\()p FB(pr)o(ed)42 b(c)p Fy(\))573 2992 y FC(r)o(eturns)20 +b(tr)o(ue.)365 3180 y Fy(\(ascii-range->cha)o(r-)o(set)37 +b FB(lower)21 b(upper)p Fy(\))87 b Fu(\000)-15 b(!)87 +b FB(char-set)472 b FC(pr)o(ocedur)o(e)573 3319 y(Returns)21 +b(a)g(character)e(set)i(containing)h(every)e(character)f(whose)24 +b(A)t Ft(S)t(C)t(I)t(I)g FC(code)c(lies)573 3419 y(in)h(the)g +(half-open)f(range)h Fn([)p FB(lower)p Fz(;)14 b FB(upper)p +Fn(\))p FC(.)365 3685 y FA(5.3.2)81 b(Querying)20 b(character)f(sets) +365 3891 y Fy(\(char-set-members)37 b FB(char-set)p Fy(\))86 +b Fu(\000)-14 b(!)87 b FB(character-list)647 b FC(pr)o(ocedur)o(e)573 +4015 y(This)21 b(pr)o(ocedur)o(e)e(r)o(eturns)h(a)g(list)i(of)f(the)f +(members)h(of)g FB(char-set)o FC(.)365 4155 y Fy(\(char-set-contain)o +(s?)37 b FB(char-set)20 b(char)p Fy(\))86 b Fu(\000)-14 +b(!)87 b FB(boolean)587 b FC(pr)o(ocedur)o(e)573 4286 +y(This)21 b(pr)o(ocedur)o(e)e(tests)i FB(char)f FC(for)h(membership)g +(in)g(set)g FB(char-set)o FC(.)756 4442 y Fl(Remark:)226 +b Fk(Pr)o(evious)62 b(r)o(eleases)e(of)j(scsh)f(called)g(this)h(pr)o +(ocedur)o(e)756 4533 y Fh(char-set-member?)p Fk(,)25 +b(r)o(eversing)19 b(the)k(or)o(der)c(of)i(the)h(ar)o(guments.)31 +b(This)21 b(made)756 4624 y(sense,)34 b(but)e(was)h(unfortunately)f +(the)h(r)o(everse)c(or)o(der)h(in)i(which)h(the)g(ar)o(gu-)756 +4716 y(ments)g(appear)h(in)g(MIT)f(Scheme.)68 b(A)34 +b(r)o(easonable)f(ar)o(gument)g(or)o(der)f(was)756 4807 +y(not)23 b(backwar)o(ds-compatible)g(with)h(MIT)f(Scheme;)j(on)d(the)h +(other)f(hand,)i(the)756 4898 y(MIT)d(Scheme)h(ar)o(gument)f(or)o(der)f +(was)i(counter)o(-intuitive)f(and)h(at)h(odds)d(with)1735 +5147 y FC(107)p eop +%%Page: 108 114 +108 113 bop 1071 614 a Fk(common)24 b(mathematical)i(notation)f(and)g +(the)g Fh(member)g Fk(family)e(of)h(R4RS)h(pr)o(o-)1071 +706 y(cedur)o(es.)1071 814 y(W)-7 b(e)18 b(sought)h(to)g(escape)f(the)h +(dilemma)f(by)h(shifting)g(to)f(a)h(new)h(name.)681 1131 +y FA(5.3.3)81 b(Character)19 b(set)h(algebra)681 1339 +y Fy(\(char-set-invert)37 b FB(char-set)p Fy(\))86 b +Fu(\000)-14 b(!)87 b FB(char-set)867 b FC(pr)o(ocedur)o(e)681 +1439 y Fy(\(char-set-union)37 b FB(char-set)1642 1451 +y Fv(1)1700 1439 y FB(char-set)1965 1451 y Fv(2)2002 +1439 y Fy(\))87 b Fu(\000)-14 b(!)87 b FB(char-set)551 +b FC(pr)o(ocedur)o(e)681 1538 y Fy(\(char-set-inters)o(ec)o(tio)o(n)37 +b FB(char-set)1948 1550 y Fv(1)2006 1538 y FB(char-set)2270 +1550 y Fv(2)2307 1538 y Fy(\))87 b Fu(\000)-14 b(!)87 +b FB(char-set)246 b FC(pr)o(ocedur)o(e)681 1638 y Fy(\(char-set-differ) +o(en)o(ce)37 b FB(char-set)1860 1650 y Fv(1)1918 1638 +y FB(char-set)2183 1650 y Fv(2)2220 1638 y Fy(\))87 b +Fu(\000)-14 b(!)87 b FB(char-set)333 b FC(pr)o(ocedur)o(e)888 +1762 y(These)31 b(pr)o(ocedur)o(es)f(implement)h(set)h(complement,)i +(union,)g(intersection,)g(and)888 1862 y(dif)o(fer)o(ence)19 +b(for)h(character)f(sets.)681 2130 y FA(5.3.4)81 b(Standard)18 +b(character)h(sets)681 2313 y FC(Several)g(character)g(sets)i(ar)o(e)f +(pr)o(ede\002ned)f(for)h(convenience:)p 749 2456 2729 +4 v 749 2555 4 100 v 802 2525 a Fy(char-set:upper-c)o(as)o(e)268 +b FC(A\226Z)p 3474 2555 V 749 2655 V 802 2625 a Fy(char-set:lower-c)o +(as)o(e)g FC(a\226z)p 3474 2655 V 749 2754 V 802 2725 +a Fy(char-set:numeric)398 b FC(0\2269)p 3474 2754 V 749 +2854 V 802 2824 a Fy(char-set:whitesp)o(ac)o(e)268 b +FC(space,)20 b(newline,)h(tab,)f(linefeed,)g(page,)g(r)o(eturn)p +3474 2854 V 749 2954 V 802 2924 a Fy(char-set:not-whi)o(te)o(spa)o(ce) +93 b FC(Complement)22 b(of)e Fy(char-set:whitespa)o(ce)p +3474 2954 V 749 3053 V 802 3023 a(char-set:alphabe)o(ti)o(c)268 +b FC(A\226Z)20 b(and)h(a\226z)p 3474 3053 V 749 3153 +V 802 3123 a Fy(char-set:alphanu)o(me)o(ric)180 b FC(Alphabetic)20 +b(or)h(numeric)p 3474 3153 V 749 3253 V 802 3223 a Fy(char-set:graphic) +398 b FC(Printing)22 b(characters)d(and)i(space)p 3474 +3253 V 749 3256 2729 4 v 681 3458 a Fy(\(char-upper-case)o(?)37 +b FB(character)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(boolean)796 +b FC(pr)o(ocedur)o(e)681 3558 y Fy(\(char-lower-case)o(?)37 +b FB(character)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(boolean)796 +b FC(pr)o(ocedur)o(e)681 3657 y Fy(\(char-numeric?)81 +b FB(character)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(boolean)883 +b FC(pr)o(ocedur)o(e)681 3757 y Fy(\(char-whitespace)o(?)37 +b FB(character)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(boolean)796 +b FC(pr)o(ocedur)o(e)681 3856 y Fy(\(char-alphabetic)o(?)37 +b FB(character)p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(boolean)796 +b FC(pr)o(ocedur)o(e)681 3956 y Fy(\(char-alphanumer)o(ic)o(?)38 +b FB(character)p Fy(\))86 b Fu(\000)-15 b(!)88 b FB(boolean)708 +b FC(pr)o(ocedur)o(e)681 4056 y Fy(\(char-graphic?)38 +b FB(character)p Fy(\))86 b Fu(\000)-15 b(!)88 b FB(boolean)926 +b FC(pr)o(ocedur)o(e)888 4197 y(These)21 b(pr)o(edicates)e(ar)o(e)g +(de\002ned)i(in)g(terms)g(of)g(the)f(above)h(character)e(sets.)2051 +5147 y(108)p eop +%%Page: 109 115 +109 114 bop 365 1272 a Fx(Chapter)45 b(6)365 1723 y FD(Reading)53 +b(delimited)e(strings)365 2214 y FC(Scsh)21 b(pr)o(ovides)g(a)f(set)h +(of)g(pr)o(ocedur)o(es)e(that)i(r)o(ead)f(delimited)g(strings)i(fr)o +(om)f(input)h(ports.)365 2314 y(Ther)o(e)17 b(ar)o(e)f(pr)o(ocedur)o +(es)g(to)i(r)o(ead)d(a)i(single)i(line)f(of)f(text)g(\(terminated)g(by) +h(a)f(newline)h(char)o(-)365 2414 y(acter\),)24 b(a)g(single)h +(paragraph)e(\(terminated)h(by)g(a)g(blank)h(line\),)g(and)f(general)g +(delimited)365 2513 y(strings)e(\(terminated)e(by)h(a)f(character)f +(belonging)j(to)f(an)g(arbitrary)e(character)h(set\).)490 +2648 y(These)k(pr)o(ocedur)o(es)f(can)i(be)f(applied)g(to)h(any)g +(Scheme)f(input)h(port.)37 b(However)-6 b(,)25 b(the)365 +2748 y(scsh)h(virtual)f(machine)h(has)f(native-code)g(support)g(for)g +(performing)h(delimited)f(r)o(eads)365 2848 y(on)i(Unix)g(ports,)h(and) +e(these)h(input)g(operations)f(should)i(be)e(particularly)g +(fast\227much)365 2947 y(faster)33 b(than)h(doing)h(the)f(equivalent)g +(character)o(-at-a-time)c(operation)k(fr)o(om)f(Scheme)365 +3047 y(code.)490 3182 y(All)19 b(of)h(the)g(delimited)f(input)i +(operations)f(described)e(below)i(take)f(a)h Fy(handle-delim)365 +3281 y FC(parameter)-6 b(,)30 b(which)h(determines)e(what)h(the)g(pr)o +(ocedur)o(e)e(does)i(with)g(the)g(terminating)365 3381 +y(delimiter)19 b(character)-6 b(.)23 b(Ther)o(e)18 b(ar)o(e)g(four)g +(possible)i(choices)f(for)g(a)f Fy(handle-delim)c FC(param-)365 +3481 y(eter:)p 573 3550 2428 4 v 573 3649 4 100 v 626 +3619 a Fy(handle-delim)p 1199 3649 V 98 w FC(Meaning)p +2997 3649 V 573 3653 2428 4 v 573 3669 V 573 3769 4 100 +v 626 3739 a Fy('trim)p 1199 3769 V 406 w FC(Ignor)o(e)21 +b(delimiter)f(character)-6 b(.)p 2997 3769 V 573 3868 +V 626 3838 a Fy('peek)p 1199 3868 V 406 w FC(Leave)19 +b(delimiter)i(character)e(in)j(input)f(str)o(eam.)p 2997 +3868 V 573 3968 V 626 3938 a Fy('concat)p 1199 3968 V +318 w FC(Append)f(delimiter)h(character)e(to)i(r)o(eturned)f(value.)p +2997 3968 V 573 4068 V 626 4038 a Fy('split)p 1199 4068 +V 362 w FC(Return)h(delimiter)g(as)f(second)h(value.)p +2997 4068 V 573 4071 2428 4 v 365 4195 a(The)28 b(\002rst)g(case,)h +Fy('trim)p FC(,)e(is)h(the)g(standar)o(d)e(default)h(for)h(all)f(the)h +(r)o(outines)g(described)f(in)365 4295 y(this)21 b(section.)26 +b(The)21 b(last)f(thr)o(ee)g(cases)f(allow)i(the)g(pr)o(ogrammer)e(to)i +(distinguish)h(between)365 4394 y(strings)h(that)f(ar)o(e)e(terminated) +h(by)h(a)g(delimiter)f(character)-6 b(,)21 b(and)g(strings)i(that)e(ar) +o(e)g(termi-)365 4494 y(nated)f(by)h(an)g(end-of-\002le.)365 +4651 y Fy(\(read-line)40 b FB([port)19 b(handle-newline])p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(string)21 b(or)g(eof-object)306 +b FC(pr)o(ocedur)o(e)573 4799 y(Reads)20 b(and)g(r)o(eturns)g(one)h +(line)g(of)g(text;)f(on)h(eof,)f(r)o(eturns)g(the)h(eof)f(object.)26 +b(A)20 b(line)h(is)573 4898 y(terminated)f(by)h(newline)g(or)g(eof.) +1735 5147 y(109)p eop +%%Page: 110 116 +110 115 bop 888 614 a FB(handle-newline)19 b FC(determines)f(what)h +Fy(read-line)c FC(does)j(with)h(the)g(newline)g(or)g(EOF)888 +714 y(that)29 b(terminates)g(the)g(line;)j(it)d(takes)g(the)g(general)f +(set)h(of)f(values)h(described)e(for)888 814 y(the)22 +b(general)e Fy(handle-delim)d FC(case)j(above,)h(and)f(defaults)h(to)g +Fy('trim)f FC(\(discar)o(d)f(the)888 913 y(newline\).)35 +b(Using)24 b(this)h(ar)o(gument)e(allows)i(one)f(to)g(tell)g(whether)g +(or)g(not)g(the)g(last)888 1013 y(line)d(of)g(input)g(in)h(a)e(\002le)h +(is)g(newline)g(terminated.)681 1305 y Fy(\(read-paragraph)37 +b FB([port)20 b(handle-delim])p Fy(\))85 b Fu(\000)-14 +b(!)87 b FB(string)21 b(or)f(eof)387 b FC(pr)o(ocedur)o(e)888 +1446 y(This)19 b(pr)o(ocedur)o(e)e(skips)i(blank)f(lines,)h(then)g(r)o +(eads)e(text)h(fr)o(om)g(a)g(port)h(until)g(a)f(blank)888 +1546 y(line)25 b(or)f(eof)g(is)h(found.)35 b(A)24 b(\223blank)g +(line\224)g(is)h(a)e(\(possibly)i(empty\))f(line)h(composed)888 +1645 y(only)e(of)e(white)h(space.)27 b(The)22 b FB(handle-delim)e +FC(parameter)g(determines)h(how)i(the)e(ter)o(-)888 1745 +y(minating)33 b(blank)f(line)g(is)g(handled.)58 b(It)31 +b(is)h(described)f(above,)j(and)d(defaults)g(to)888 1845 +y Fy('trim)p FC(.)24 b(The)c Fy('peek)f FC(option)j(is)f(not)h +(available.)805 2012 y(The)17 b(following)h(pr)o(ocedur)o(es)c(r)o(ead) +h(in)i(strings)h(fr)o(om)e(ports)g(delimited)h(by)f(characters)681 +2112 y(belonging)34 b(to)g(a)e(speci\002c)h(set.)62 b(See)33 +b(section)g(5.3)f(for)h(information)h(on)f(character)f(set)681 +2211 y(manipulation.)681 2361 y Fy(\(read-delimited)37 +b FB(char-set)20 b([port)g(handle-delim])p Fy(\))85 b +Fu(\000)-14 b(!)87 b FB(string)21 b(or)g(eof)101 b FC(pr)o(ocedur)o(e) +888 2503 y(Read)46 b(until)i(we)e(encounter)h(one)g(of)f(the)h(chars)f +(in)h FB(char-set)f FC(or)h(eof.)102 b(The)888 2602 y +FB(handle-delim)19 b FC(parameter)f(determines)i(how)h(the)g +(terminating)f(character)f(is)h(han-)888 2702 y(dled.)25 +b(It)c(is)g(described)f(above,)g(and)g(defaults)g(to)h +Fy('trim)p FC(.)888 2835 y(The)g FB(char-set)f FC(ar)o(gument)h(may)f +(be)h(a)f(charset,)g(a)h(string,)g(a)f(character)-6 b(,)19 +b(or)i(a)g(charac-)888 2935 y(ter)g(pr)o(edicate;)d(it)j(is)g(coer)o +(ced)f(to)h(a)f(charset.)681 3127 y Fy(\(read-delimited!)37 +b FB(char-set)15 b(buf)h([port)f(handle-delim)f(start)i(end])p +Fy(\))43 b Fu(\000)-15 b(!)44 b FB(nchars)16 b(or)g(eof)g(or)g(#f)86 +b FC(pr)o(ocedur)o(e)888 3268 y(A)21 b(side-ef)o(fecting)e(variant)h +(of)h Fy(read-delimited)p FC(.)888 3402 y(The)26 b(data)f(is)i(written) +f(into)h(the)f(string)h FB(buf)g FC(at)e(the)h(indices)h(in)f(the)g +(half-open)g(in-)888 3501 y(terval)h Fn([)p FB(start)o +Fz(;)14 b FB(end)p Fn(\))p FC(;)31 b(the)c(default)f(interval)h(is)g +(the)g(whole)h(string:)39 b FB(start)c Fn(=)f(0)26 b +FC(and)888 3601 y FB(end)k Fn(=)g Fy(\(string-length)38 +b FB(buf)p Fy(\))p FC(.)f(The)24 b(values)g(of)h FB(start)f +FC(and)g FB(end)g FC(must)h(specify)g(a)888 3700 y(well-de\002ned)c +(interval)f(in)h FB(str)p FC(,)g FB(i.e.)p FC(,)f Fn(0)j +Fu(\024)g FB(start)f Fu(\024)h FB(end)g Fu(\024)g Fy(\(string-length)37 +b FB(buf)q Fy(\))p FC(.)888 3834 y(It)21 b(r)o(eturns)e +FB(nbytes)q FC(,)h(the)g(number)g(of)h(bytes)f(r)o(ead.)k(If)19 +b(the)i(buf)o(fer)d(\002lled)j(up)f(without)888 3933 +y(a)32 b(delimiter)f(character)f(being)i(found,)i Fy(#f)d +FC(is)h(r)o(eturned.)57 b(If)32 b(the)f(port)h(is)g(at)f(eof)888 +4033 y(when)22 b(the)f(r)o(ead)e(starts,)h(the)h(eof)f(object)i(is)f(r) +o(eturned.)888 4166 y(If)h(an)f(integer)h(is)g(r)o(eturned)f(\()p +FB(i.e.)p FC(,)g(the)h(r)o(ead)f(is)h(successfully)g(terminated)f(by)h +(r)o(ead-)888 4266 y(ing)35 b(a)e(delimiter)h(character\),)h(then)f +(the)g FB(handle-delim)e FC(parameter)g(determines)888 +4365 y(how)24 b(the)e(terminating)h(character)e(is)i(handled.)30 +b(It)23 b(is)f(described)g(above,)g(and)g(de-)888 4465 +y(faults)f(to)g Fy('trim)p FC(.)681 4657 y Fy(\(\045read-delimited)o(!) +37 b FB(char-set)15 b(buf)i(gobble?)f([port)f(start)g(end])p +Fy(\))43 b Fu(\000)-14 b(!)43 b FB([char-or-eof-or-#f)14 +b(integer])87 b FC(pr)o(ocedur)o(e)888 4799 y(This)20 +b(low-level)f(delimited)g(r)o(eader)d(uses)k(an)e(alternate)g +(interface.)24 b(It)19 b(r)o(eturns)f(two)888 4898 y(values:)25 +b FB(terminator)c FC(and)f FB(num-r)o(ead)o FC(.)2053 +5147 y(1)-5 b(10)p eop +%%Page: 111 117 +111 116 bop 573 614 a FA(terminator)40 b FC(A)20 b(value)g(describing)h +(why)g(the)g(r)o(ead)e(was)i(terminated:)805 842 y(Character)f(or)g +(eof-object)166 b Fu(\))g FC(Read)21 b(terminated)f(by)h(this)g(value.) +805 941 y Fy(#f)912 b Fu(\))166 b FC(Filled)21 b(buf)o(fer)e(without)j +(\002nding)g(a)e(delimiter)-6 b(.)573 1090 y FA(num-read)39 +b FC(Number)21 b(of)g(characters)e(r)o(ead)g(into)j FB(buf)p +FC(.)573 1256 y(If)31 b(the)g(r)o(ead)f(is)i(successfully)g(terminated) +e(by)i(r)o(eading)e(a)h(delimiter)g(character)-6 b(,)573 +1356 y(then)27 b(the)g FB(gobble?)f FC(parameter)f(determines)i(what)f +(to)h(do)g(with)g(the)g(terminating)573 1456 y(character)-6 +b(.)23 b(If)c(tr)o(ue,)g(the)h(character)e(is)h(r)o(emoved)g(fr)o(om)g +(the)g(input)h(str)o(eam;)e(if)i(false,)573 1555 y(the)29 +b(character)e(is)i(left)g(in)g(the)g(input)g(str)o(eam)f(wher)o(e)h(a)f +(subsequent)h(r)o(ead)f(oper)o(-)573 1655 y(ation)h(will)g(r)o(etrieve) +e(it.)48 b(In)29 b(either)g(case,)g(the)g(character)d(is)j(also)g(the)f +(\002rst)h(value)573 1755 y(r)o(eturned)19 b(by)i(the)g(pr)o(ocedur)o +(e)e(call.)365 1945 y Fy(\(skip-char-set)38 b FB(skip-chars)20 +b([port])p Fy(\))85 b Fu(\000)-14 b(!)87 b FB(integer)697 +b FC(pr)o(ocedur)o(e)573 2087 y(Skip)20 b(characters)f(occurring)i(in)g +(the)g(set)f FB(skip-chars)o FC(;)h(r)o(eturn)e(the)i(number)f(of)h +(char)o(-)573 2186 y(acters)c(skipped.)24 b(The)17 b +FB(skip-chars)g FC(ar)o(gument)g(may)h(be)f(a)g(charset,)g(a)g(string,) +i(a)e(char)o(-)573 2286 y(acter)-6 b(,)19 b(or)i(a)f(character)g(pr)o +(edicate;)e(it)j(is)g(coer)o(ced)f(to)h(a)f(charset.)1740 +5147 y(1)-5 b(1)g(1)p eop +%%Page: 112 118 +112 117 bop 681 1307 a Fx(Chapter)44 b(7)681 1792 y FD(A)-14 +b(wk,)51 b(record)h(I/O,)g(and)g(\002eld)681 2041 y(parsing)681 +2567 y FC(Unix)33 b(pr)o(ograms)g(fr)o(equently)g(pr)o(ocess)g(str)o +(eams)g(of)g(r)o(ecor)o(ds,)i(wher)o(e)e(each)g(r)o(ecor)o(d)f(is)681 +2667 y(delimited)27 b(by)h(a)g(newline,)i(and)d(r)o(ecor)o(ds)f(ar)o(e) +h(br)o(oken)g(into)i(\002elds)f(with)g(other)g(delim-)681 +2767 y(iters)f(\(for)f(example,)h(the)g(colon)h(character)e(in)h +Fy(/etc/passwd)p FC(\).)39 b(Scsh)27 b(has)g(pr)o(ocedur)o(es)681 +2866 y(that)i(allow)h(the)g(pr)o(ogrammer)f(to)h(easily)f(do)h(this)g +(kind)g(of)g(pr)o(ocessing.)52 b(Scsh's)30 b(\002eld)681 +2966 y(parsers)j(can)h(also)h(be)f(used)g(to)h(parse)e(other)i(kinds)g +(of)f(delimited)g(strings,)39 b(such)34 b(as)681 3066 +y(colon-separated)26 b Fy($PATH)e FC(lists.)45 b(These)27 +b(r)o(outines)g(can)f(be)h(used)f(with)i(scsh's)g Fy(awk)d +FC(loop)681 3165 y(constr)o(uct)f(to)g(conveniently)h(perform)e +(pattern-dir)o(ected)e(computation)j(over)g(str)o(eams)681 +3265 y(of)d(r)o(ecor)o(ds.)681 3658 y Fw(7.1)99 b(Record)25 +b(I/O)g(and)f(\002eld)h(parsing)681 3932 y FC(The)f(pr)o(ocedur)o(es)e +(in)i(this)h(section)g(ar)o(e)d(used)i(to)g(r)o(ead)f(r)o(ecor)o(ds)f +(fr)o(om)i(I/O)g(str)o(eams)f(and)681 4031 y(parse)16 +b(them)i(into)g(\002elds.)25 b(A)17 b(r)o(ecor)o(d)e(is)j(de\002ned)f +(as)g(text)g(terminated)g(by)g(some)h(delimiter)681 4131 +y(\(usually)25 b(a)f(newline\).)38 b(A)24 b(r)o(ecor)o(d)g(can)g(be)h +(split)g(into)h(\002elds)e(by)h(using)h(r)o(egular)e(expr)o(es-)681 +4230 y(sions)k(in)f(one)g(of)g(several)f(ways:)37 b(to)27 +b FB(match)e FC(\002elds,)j(to)f FB(separate)g FC(\002elds,)h(or)f(to)g +FB(terminate)681 4330 y FC(\002elds.)41 b(The)25 b(\002eld)h(parsers)f +(can)h(be)f(applied)g(to)h(arbitrary)f(strings)i(\(one)f(common)h(use) +681 4430 y(is)f(splitting)g(envir)o(onment)g(variables)f(such)g(as)h +Fy($PATH)d FC(at)i(colons)i(into)f(its)g(component)681 +4529 y(elements\).)805 4699 y(The)18 b(general)g(delimited-input)g(pr)o +(ocedur)o(es)e(described)h(in)h(chapter)f(6)h(ar)o(e)e(also)i(use-)681 +4799 y(ful)36 b(for)h(r)o(eading)e(simple)i(r)o(ecor)o(ds,)i(such)e(as) +g(single)g(lines,)k(paragraphs)35 b(of)i(text,)j(or)681 +4898 y(strings)21 b(terminated)g(by)f(speci\002c)h(characters.)2053 +5147 y(1)-5 b(12)p eop +%%Page: 113 119 +113 118 bop 365 614 a FA(7.1.1)81 b(Reading)19 b(records)365 +821 y Fy(\(record-reader)38 b FB([delims)15 b(elide-delims?)g +(handle-delim])p Fy(\))42 b Fu(\000)-14 b(!)43 b FB(pr)o(ocedur)o(e)86 +b FC(pr)o(ocedur)o(e)573 946 y(Returns)32 b(a)f(pr)o(ocedur)o(e)e(that) +i(r)o(eads)f(r)o(ecor)o(ds)g(fr)o(om)h(a)f(port.)58 b(The)31 +b(pr)o(ocedur)o(e)e(is)573 1045 y(invoked)21 b(as)f(follows:)756 +1184 y Fy(\()p FB(r)o(eader)43 b([port])n Fy(\))h Fu(\000)-15 +b(!)44 b FB(string)21 b(or)g(eof)573 1322 y FC(A)i(r)o(ecor)o(d)f(is)i +(a)f(sequence)h(of)f(characters)g(terminated)g(by)h(one)g(of)f(the)h +(characters)573 1422 y(in)32 b FB(delims)g FC(or)f(eof.)58 +b(If)32 b FB(elide-delims?)f FC(is)h(tr)o(ue,)i(then)e(a)f(contiguous)j +(sequence)e(of)573 1522 y(delimiter)c(chars)h(ar)o(e)e(taken)h(as)h(a)f +(single)h(r)o(ecor)o(d)e(delimiter)-6 b(.)49 b(If)28 +b FB(elide-delims?)g FC(is)573 1621 y(false,)34 b(then)e(a)g(delimiter) +g(char)f(coming)j(immediately)e(after)f(a)g(delimiter)h(char)573 +1721 y(pr)o(oduces)c(an)i(empty-string)g(r)o(ecor)o(d.)50 +b(The)29 b(r)o(eader)e(consumes)k(the)f(delimiting)573 +1820 y(char\(s\))20 b(befor)o(e)f(r)o(eturning)i(fr)o(om)f(a)g(r)o +(ead.)573 1953 y(The)26 b FB(delims)g FC(set)g(defaults)f(to)i(the)f +(set)g Fu(f)p FC(newline)p Fu(g)p FC(.)41 b(It)26 b(may)g(be)g(a)f +(charset,)i(string,)573 2053 y(character)-6 b(,)49 b(or)44 +b(character)g(pr)o(edicate,)k(and)c(is)h(coer)o(ced)f(to)h(a)f +(charset.)97 b(The)573 2152 y FB(elide-delims?)20 b FC(\003ag)h +(defaults)f(to)h Fy(#f)p FC(.)573 2285 y(The)f FB(handle-delim)f +FC(ar)o(gument)g(contr)o(ols)i(what)f(is)h(done)f(with)h(the)f(r)o +(ecor)o(d's)f(termi-)573 2384 y(nating)i(delimiter)-6 +b(.)805 2525 y Fy('trim)185 b FC(Delimiters)19 b(ar)o(e)e(trimmed.)25 +b(\(The)18 b(default\))805 2624 y Fy('split)141 b FC(Reader)36 +b(r)o(eturns)g(delimiter)g(string)h(as)f(a)1210 2724 +y(second)29 b(ar)o(gument.)49 b(If)29 b(r)o(ecor)o(d)e(is)i(termi-)1210 +2824 y(nated)k(by)h(EOF)-8 b(,)34 b(then)g(the)f(eof)h(object)g(is)1210 +2923 y(r)o(eturned)20 b(as)g(this)i(second)f(ar)o(gument.)805 +3023 y Fy('concat)97 b FC(The)38 b(r)o(ecor)o(d)e(and)h(its)h +(delimiter)g(ar)o(e)e(r)o(e-)1210 3122 y(turned)21 b(as)f(a)g(single)i +(string.)573 3293 y(The)34 b(r)o(eader)e(pr)o(ocedur)o(e)g(r)o(eturned) +h(takes)g(one)i(optional)g(ar)o(gument,)h(the)e(port)573 +3392 y(fr)o(om)21 b(which)h(to)g(r)o(ead,)d(which)j(defaults)f(to)g +(the)h(curr)o(ent)e(input)i(port.)27 b(It)21 b(r)o(eturns)g(a)573 +3492 y(string)g(or)g(eof.)365 3759 y FA(7.1.2)81 b(Parsing)20 +b(\002elds)365 3966 y Fy(\(field-splitter)38 b FB([r)o(egexp)19 +b(num-\002elds])p Fy(\))86 b Fu(\000)-14 b(!)87 b FB(pr)o(ocedur)o(e) +460 b FC(pr)o(ocedur)o(e)365 4066 y Fy(\(infix-splitter)38 +b FB([delim)17 b(num-\002elds)h(handle-delim])p Fy(\))65 +b Fu(\000)-14 b(!)66 b FB(pr)o(ocedur)o(e)87 b FC(pr)o(ocedur)o(e)365 +4165 y Fy(\(suffix-splitter)37 b FB([delim)16 b(num-\002elds)f +(handle-delim])p Fy(\))45 b Fu(\000)-14 b(!)47 b FB(pr)o(ocedur)o(e)87 +b FC(pr)o(ocedur)o(e)365 4265 y Fy(\(sloppy-suffix-sp)o(li)o(tte)o(r)37 +b FB([delim)15 b(num-\002elds)h(handle-delim])p Fy(\))41 +b Fu(\000)-14 b(!)43 b FB(pr)o(ocedur)o(e)87 b FC(pr)o(ocedur)o(e)573 +4389 y(These)21 b(functions)g(r)o(eturn)f(a)h(parser)e(function)j(that) +f(can)f(be)g(used)h(as)f(follows:)756 4528 y Fy(\()p +FB(parser)43 b(string)h([start])o Fy(\))f Fu(\000)-14 +b(!)43 b FB(string-list)573 4699 y FC(The)27 b(r)o(eturned)f(parsers)h +(split)g(strings)h(into)h(\002elds)e(de\002ned)g(by)g(r)o(egular)f +(expr)o(es-)573 4799 y(sions.)g(Y)-8 b(ou)19 b(can)e(parse)h(by)g +(specifying)g(a)g(pattern)f(that)h FB(separates)g FC(\002elds,)h(a)e +(pattern)573 4898 y(that)k FB(terminates)f FC(\002elds,)h(or)g(a)f +(pattern)g(that)h FB(matches)f FC(\002elds:)1737 5147 +y(1)-5 b(13)p eop +%%Page: 114 120 +114 119 bop 1121 601 a FC(Pr)o(ocedur)o(e)748 b(Pattern)p +1071 634 1835 4 v 1121 704 a Fy(field-splitter)509 b +FC(matches)21 b(\002elds)1121 804 y Fy(infix-splitter)509 +b FC(separates)19 b(\002elds)1121 903 y Fy(suffix-splitter)465 +b FC(terminates)20 b(\002elds)1121 1003 y Fy(sloppy-suffix-sp)o(li)o +(tte)o(r)160 b FC(terminates)20 b(\002elds)888 1189 y(These)i(parser)e +(generators)i(ar)o(e)e(contr)o(olled)h(by)h(a)f(range)g(of)h(options,)h +(so)f(that)f(you)888 1288 y(can)31 b(pr)o(ecisely)g(specify)g(what)g +(kind)g(of)h(parsing)f(you)h(want.)57 b(However)-6 b(,)33 +b(these)888 1388 y(options)22 b(default)e(to)h(r)o(easonable)f(values)g +(for)h(general)f(use.)888 1525 y(Defaults:)1121 1605 +y FB(delim)331 b FC(=)84 b Fy("[)43 b(\\t\\n]+|$")95 +b FC(\(suf)o(\002x)20 b(delimiter:)26 b(white)21 b(space)f(or)h(eos\)) +1771 1705 y Fy("[)43 b(\\t\\n]+")183 b FC(\(in\002x)21 +b(delimiter:)26 b(white)21 b(space\))1121 1805 y FB(r)o(e)453 +b FC(=)84 b Fy("[^)42 b(\\t\\n]+")140 b FC(\(non-white-space\))1121 +1904 y FB(num-\002elds)158 b FC(=)84 b Fy(#f)534 b FC(\(as)21 +b(many)g(\002elds)f(as)h(possible\))1121 2004 y FB(handle-delim)81 +b FC(=)j Fy('trim)402 b FC(\(discar)o(d)19 b(delimiter)i(chars\))888 +2102 y(.)12 b(.)g(.)g(which)33 b(means:)45 b(br)o(eak)29 +b(the)i(string)g(at)g(white)g(space,)h(discar)o(ding)e(the)g(white)888 +2202 y(space,)20 b(and)g(parse)g(as)h(many)g(\002elds)g(as)f(possible.) +888 2339 y(The)26 b(r)o(egular)e(expr)o(ession)h FB(delim)f +FC(is)i(used)f(to)h(match)f(\002eld)g(delimiters.)39 +b(It)25 b(can)g(be)888 2439 y(either)16 b(a)g(string)h(or)g(a)e +(compiled)i(r)o(egexp)e(str)o(uctur)o(e)h(\(see)f(the)i +Fy(make-regexp)11 b FC(pr)o(oce-)888 2539 y(dur)o(e\).)31 +b(In)23 b(the)g(separator)e(case,)i(it)g(defaults)f(to)h(a)f(r)o +(egular)g(expr)o(ession)g(matching)888 2638 y(white)j(space;)g(in)g +(the)f(terminator)h(case,)f(it)g(defaults)g(to)g(white)h(space)f(or)g +(end-of-)888 2738 y(string.)888 2875 y(The)f(r)o(egular)f(expr)o +(ession)h FB(r)o(e)h FC(is)f(a)g(r)o(egular)f(expr)o(ession)h(used)f +(to)i(match)f(\002elds.)33 b(It)888 2975 y(defaults)20 +b(to)h(non-white-space.)888 3112 y(The)g(boolean)g FB(handle-delim)f +FC(determines)g(what)h(to)g(do)g(with)h(delimiters.)1121 +3192 y Fy('trim)185 b FC(Delimiters)21 b(ar)o(e)e(thr)o(own)j(away)e +(after)f(parsing.)26 b(\(default\))1121 3292 y Fy('concat)97 +b FC(Delimiters)21 b(ar)o(e)e(appended)h(to)h(the)g(\002eld)f(pr)o +(eceding)g(them.)1121 3391 y Fy('split)141 b FC(Delimiters)21 +b(ar)o(e)e(r)o(eturned)h(as)g(separate)g(elements)h(in)g(the)g(\002eld) +f(list.)888 3528 y(The)31 b FB(num-\002elds)f FC(ar)o(gument)h(used)f +(to)h(cr)o(eate)f(the)g(parser)g(speci\002es)h(how)h(many)888 +3628 y(\002elds)20 b(to)h(parse.)j(If)c Fy(#f)f FC(\(the)h(default\),)e +(the)i(pr)o(ocedur)o(e)e(parses)h(them)i(all.)k(If)19 +b(a)h(pos-)888 3727 y(itive)25 b(integer)g Fz(n)p FC(,)h(exactly)e +(that)h(many)g(\002elds)g(ar)o(e)e(parsed;)i(it)h(is)f(an)f(err)o(or)g +(if)h(ther)o(e)888 3827 y(ar)o(e)g(mor)o(e)h(or)g(fewer)f(than)i +Fz(n)e FC(\002elds)i(in)f(the)g(r)o(ecor)o(d.)40 b(If)26 +b FB(num-\002elds)f FC(is)i(a)e(negative)888 3927 y(integer)20 +b(or)g(zer)o(o,)f(then)i Fu(j)p Fz(n)p Fu(j)f FC(\002elds)g(ar)o(e)e +(parsed,)h(and)h(the)g(r)o(emainder)e(of)i(the)g(string)888 +4026 y(is)k(r)o(eturned)e(in)i(the)g(last)f(element)h(of)f(the)h +(\002eld)f(list;)j(it)d(is)h(an)f(err)o(or)g(if)g(fewer)g(than)888 +4126 y Fu(j)p Fz(n)p Fu(j)e FC(\002elds)g(can)f(be)h(parsed.)888 +4263 y(The)c(\002eld)f(parser)f(pr)o(oduced)g(is)i(a)f(pr)o(ocedur)o(e) +e(that)j(can)f(be)g(employed)g(as)g(follows:)1071 4412 +y Fy(\()p FB(parse)43 b(string)h([start])o Fy(\))f Fn(=)-14 +b Fu(\))44 b FB(string-list)888 4562 y FC(The)30 b(optional)g +FB(start)g FC(ar)o(gument)f(\(default)f(0\))h(speci\002es)h(wher)o(e)f +(in)h(the)g(string)h(to)888 4661 y(begin)21 b(the)g(parse.)k(It)c(is)g +(an)f(err)o(or)g(if)h FB(start)i Fz(>)f Fy(\(string-length)38 +b FB(string)p Fy(\))p FC(.)888 4799 y(The)26 b(parsers)f(r)o(eturned)g +(by)h(the)g(four)f(parser)g(generators)h(implement)g(dif)o(fer)o(ent) +888 4898 y(kinds)c(of)e(\002eld)h(parsing:)2053 5147 +y(1)-5 b(14)p eop +%%Page: 115 121 +115 120 bop 573 614 a Fy(field-splitter)36 b FC(The)20 +b(r)o(egular)g(expr)o(ession)g(speci\002es)h(the)g(actual)f(\002eld.) +573 759 y Fy(suffix-splitter)35 b FC(Delimiters)d(ar)o(e)f(interpr)o +(eted)f(as)h(element)h FB(terminators)p FC(.)58 b(If)756 +859 y(vertical-bar)36 b(is)i(the)g(the)g(delimiter)-6 +b(,)42 b(then)d(the)f(string)h Fy("")e FC(is)h(the)g(empty)756 +958 y(r)o(ecor)o(d)24 b Fy(\(\))p FC(,)k Fy("foo|")c +FC(pr)o(oduces)i(a)g(one-\002eld)g(r)o(ecor)o(d)f Fy(\("foo"\))p +FC(,)g(and)i Fy("foo")756 1058 y FC(is)21 b(an)f(err)o(or)-6 +b(.)756 1180 y(The)20 b(syntax)h(of)g(suf)o(\002x-delimited)f(r)o(ecor) +o(ds)f(is:)961 1349 y Fz(<)p FB(r)o(ecord)p Fz(>)98 b +FC(::=)h Fy("")186 b FC(\(Empty)21 b(r)o(ecor)o(d\))1431 +1448 y Fu(j)134 b Fz(<)p FB(element)p Fz(>)21 b(<)p FB(delim)p +Fz(>)e(<)p FB(r)o(ecord)p Fz(>)756 1637 y FC(It)27 b(is)i(an)e(err)o +(or)g(if)h(a)f(non-empty)i(r)o(ecor)o(d)d(does)i(not)g(end)g(with)h(a)e +(delimiter)-6 b(.)756 1736 y(T)e(o)22 b(make)g(the)g(last)g(delimiter)g +(optional,)h(make)f(sur)o(e)g(the)g(delimiter)g(r)o(egexp)756 +1836 y(matches)e(the)h(end-of-string)g(\(r)o(egexp)e +Fy("$")p FC(\).)573 1981 y Fy(infix-splitter)36 b FC(Delimiters)44 +b(ar)o(e)e(interpr)o(eted)g(as)h(element)g FB(separators)p +FC(.)94 b(If)756 2080 y(comma)21 b(is)g(the)g(delimiter)-6 +b(,)21 b(then)g(the)h(string)f Fy("foo,")e FC(pr)o(oduces)h(a)g +(two-\002eld)756 2180 y(r)o(ecor)o(d)f Fy(\("foo")41 +b(""\))p FC(.)756 2302 y(The)20 b(syntax)h(of)g(in\002x-delimited)g(r)o +(ecor)o(ds)e(is:)961 2471 y Fz(<)p FB(r)o(ecord)p Fz(>)431 +b FC(::=)99 b Fy("")186 b FC(\(For)o(ced)20 b(to)h(be)f(empty)h(r)o +(ecor)o(d\))1764 2570 y Fu(j)134 b Fz(<)p FB(r)o(eal-in\002x-r)o(ecord) +p Fz(>)961 2769 y(<)p FB(r)o(eal-in\002x-r)o(ecord)p +Fz(>)97 b FC(::=)i Fz(<)p FB(element)p Fz(>)21 b(<)p +FB(delim)p Fz(>)e(<)p FB(r)o(eal-in\002x-r)o(ecord)p +Fz(>)1764 2869 y Fu(j)134 b Fz(<)p FB(element)p Fz(>)756 +3057 y FC(Note)52 b(that)g(separator)g(semantics)g(doesn't)h(r)o(eally) +e(allow)i(for)f(empty)756 3157 y(r)o(ecor)o(ds\227the)k(straightforwar) +o(d)h(grammar)g(\()p FB(i.e.)o FC(,)67 b Fz(<)p FB(r)o(eal-in\002x-r)o +(ecord)p Fz(>)p FC(\))756 3257 y(parses)34 b(an)h(empty)g(string)h(as)f +(a)g(singleton)h(list)g(whose)g(one)g(\002eld)f(is)g(the)756 +3356 y(empty)21 b(string,)h Fy(\(""\))p FC(,)d(not)j(as)f(the)g(empty)h +(r)o(ecor)o(d)d Fy(\(\))p FC(.)26 b(This)c(is)g(unfortunate,)756 +3456 y(since)c(it)g(means)g(that)g(in\002x)h(string)g(parsing)f +(doesn't)g(make)g Fy(string-append)756 3555 y FC(and)i +Fy(append)e FC(isomorphic.)27 b(For)21 b(example,)911 +3722 y Fy(\(\(infix-splitter)37 b(":"\))42 b(\(string-append)37 +b FB(x)44 b Fy(":")e FB(y)o Fy(\)\))756 3889 y FC(doesn't)21 +b(always)f(equal)911 4034 y Fy(\(append)40 b(\(\(infix-splitter)d +(":"\))42 b FB(x)p Fy(\))1259 4133 y(\(\(infix-splitter)37 +b(":"\))42 b FB(y)p Fy(\)\))756 4278 y FC(It)23 b(fails)g(when)h +FB(x)e FC(or)i FB(y)e FC(ar)o(e)g(the)h(empty)h(string.)33 +b(T)-8 b(erminator)24 b(semantics)g FB(does)756 4378 +y FC(pr)o(eserve)19 b(a)h(similar)h(isomorphism.)756 +4500 y(However)-6 b(,)32 b(separator)d(semantics)i(is)g(fr)o(equently)g +(what)f(other)h(Unix)g(soft-)756 4599 y(war)o(e)21 b(uses,)i(so)g(to)g +(parse)f(their)h(strings,)h(we)e(need)h(to)g(use)f(it.)32 +b(For)23 b(example,)756 4699 y(Unix)g Fy($PATH)e FC(lists)k(have)e +(separator)f(semantics.)34 b(The)23 b(path)h(list)g Fy("/bin:")c +FC(is)756 4799 y(br)o(oken)h(up)g(into)i Fy(\("/bin")41 +b(""\))p FC(,)20 b(not)i Fy(\("/bin"\))p FC(.)j(Comma-separated)20 +b(lists)756 4898 y(should)h(also)g(be)f(parsed)g(this)i(way)-9 +b(.)1737 5147 y(1)k(15)p eop +%%Page: 116 122 +116 121 bop 681 535 2865 4 v 681 1403 4 868 v 835 657 +a Fk(Recor)o(d)218 b(:)22 b(suf)o(\002x)148 b Fh(:|$)19 +b Fk(suf)o(\002x)288 b(:)23 b(in\002x)419 b(non-:)23 +b(\002eld)p 785 688 2656 4 v 835 752 a Fh("")375 b(\(\))296 +b(\(\))531 b(\(\))h(\(\))835 843 y(":")336 b(\(""\))218 +b(\(""\))453 b(\("")40 b(""\))336 b(\(\))835 934 y("foo:")219 +b(\("foo"\))101 b(\("foo"\))336 b(\("foo")41 b(""\))218 +b(\("foo"\))835 1026 y(":foo")h Fi(err)o(or)226 b Fh(\("")40 +b("foo"\))218 b(\("")40 b("foo"\))219 b(\("foo"\))835 +1117 y("foo:bar")102 b Fi(err)o(or)226 b Fh(\("foo")40 +b("bar"\))101 b(\("foo")41 b("bar"\))101 b(\("foo")41 +b("bar"\))946 1379 y FC(Figur)o(e)21 b(7.1:)j(Using)d(dif)o(fer)o(ent)e +(grammars)h(to)h(split)h(r)o(ecor)o(ds)d(into)j(\002elds.)p +3542 1403 4 868 v 681 1406 2865 4 v 888 1654 a Fy(sloppy-suffix)36 +b FC(The)23 b(same)f(as)g(the)g Fy(suffix)e FC(case,)i(except)f(that)i +(the)f(parser)f(will)1071 1754 y(skip)26 b(an)f(initial)g(delimiter)g +(string)h(if)f(the)g(string)h(begins)g(with)g(one)f(instead)1071 +1853 y(of)33 b(parsing)g(an)f(initial)h(empty)g(\002eld.)62 +b(This)33 b(can)g(be)f(used,)j(for)e(example,)1071 1953 +y(to)27 b(\002eld-split)g(a)f(sequence)i(of)e(English)i(text)f(at)f +(white-space)h(boundaries,)1071 2053 y(wher)o(e)19 b(the)h(string)h +(may)e(begin)h(or)g(end)g(with)g(white)h(space,)e(by)h(using)g(r)o +(egex)1071 2152 y Fy("[)43 b(\\t]+|$")p FC(.)24 b(\(But)d(you)g(would)h +(be)f(better)g(of)o(f)f(using)i Fy(field-splitter)16 +b FC(in)1071 2252 y(this)21 b(case.\))805 2467 y(Figur)o(e)28 +b(7.1)e(shows)j(how)g(the)f(dif)o(fer)o(ent)d(parser)i(grammars)h +(split)g(apart)e(the)i(same)681 2567 y(strings.)103 b(Having)30 +b(to)f(choose)i(between)e(the)g(dif)o(fer)o(ent)e(grammars)i(r)o(equir) +o(es)g(you)h(to)681 2666 y(decide)i(what)h(you)h(want,)i(but)d(at)g +(least)g(you)h(can)e(be)h(pr)o(ecise)f(about)h(what)h(you)f(ar)o(e)681 +2766 y(parsing.)25 b(T)-8 b(ake)20 b(\002fteen)f(seconds)i(and)e(think) +i(it)f(out.)26 b(Say)19 b(what)h(you)g(mean;)g(mean)g(what)681 +2866 y(you)h(say)-9 b(.)681 3015 y Fy(\(join-strings)38 +b FB(string-list)20 b([delimiter)h(grammar])p Fy(\))85 +b Fu(\000)-14 b(!)87 b FB(string)282 b FC(pr)o(ocedur)o(e)888 +3155 y(This)22 b(pr)o(ocedur)o(e)d(is)i(a)g(simple)g(unparser)o(\227it) +f(pastes)h(strings)h(together)f(using)h(the)888 3255 +y(delimiter)f(string.)888 3388 y(The)40 b FB(grammar)f +FC(ar)o(gument)g(is)h(one)h(of)e(the)h(symbols)h Fy(infix)d +FC(\(the)i(default\))e(or)888 3487 y Fy(suffix)p FC(;)30 +b(it)f(determines)g(whether)g(the)g(delimiter)g(string)g(is)g(used)g +(as)f(a)h(separa-)888 3587 y(tor)21 b(or)g(as)g(a)f(terminator)-6 +b(.)888 3719 y(The)20 b(delimiter)f(is)h(the)g(string)g(used)g(to)g +(delimit)g(elements;)g(it)f(defaults)g(to)h(a)f(single)888 +3819 y(space)h Fy(")43 b(")p FC(.)888 3952 y(Example:)1071 +4117 y Fy(\(join-strings)38 b('\("foo")j("bar")g("baz"\))h(":"\))1245 +4217 y Fn(=)-14 b Fu(\))87 b Fy("foo:bar:baz")681 4567 +y FA(7.1.3)81 b(Field)19 b(readers)681 4774 y Fy(\(field-reader)38 +b FB([\002eld-parser)20 b(r)o(ec-r)o(eader])p Fy(\))86 +b Fu(\000)-14 b(!)87 b FB(pr)o(ocedur)o(e)418 b FC(pr)o(ocedur)o(e)888 +4898 y(This)33 b(utility)f(r)o(eturns)g(a)f(pr)o(ocedur)o(e)f(that)i(r) +o(eads)e(r)o(ecor)o(ds)g(with)j(\002eld)f(str)o(uctur)o(e)2053 +5147 y(1)-5 b(16)p eop +%%Page: 117 123 +117 122 bop 573 614 a FC(fr)o(om)27 b(a)f(port.)45 b(The)27 +b(r)o(eader)6 b('s)26 b(interface)g(is)i(designed)f(to)g(make)g(it)h +(useful)f(in)g(the)573 714 y Fy(awk)19 b FC(loop)j(macr)o(o)e +(\(section)h(7.2\).)j(The)d(r)o(eader)d(is)j(used)g(as)f(follows:)756 +865 y Fy(\()p FB(r)o(eader)43 b([port])n Fy(\))h Fn(=)-14 +b Fu(\))86 b FB([raw-r)o(ecord)20 b(parsed-r)o(ecord])42 +b Fy(or)h FB([eof)21 b(\(\)])573 1054 y FC(When)28 b(the)f(r)o(eader)e +(is)j(applied)f(to)g(an)g(input)h(port)g(\(default:)37 +b(the)28 b(curr)o(ent)e(input)573 1154 y(port\),)19 b(it)g(r)o(eads)f +(a)g(r)o(ecor)o(d)g(using)i FB(r)o(ec-r)o(eader)o FC(.)25 +b(If)19 b(this)h(r)o(ecor)o(d)d(isn't)j(the)f(eof)g(object,)g(it)573 +1254 y(is)25 b(parsed)e(with)i FB(\002eld-parser)p FC(.)37 +b(These)24 b(two)h(values\227the)f(r)o(ecor)o(d,)g(and)g(its)h(parsed) +573 1353 y(r)o(epr)o(esentation\227ar)o(e)18 b(r)o(eturned)i(as)g +(multiple)h(values)g(fr)o(om)f(the)h(r)o(eader)-6 b(.)573 +1491 y(When)21 b(called)f(at)g(eof,)h(the)f(r)o(eader)f(r)o(eturns)h +([eof-object)g Fy(\(\))p FC(].)573 1629 y(Although)e(the)g(r)o(ecor)o +(d)e(r)o(eader)f(typically)j(r)o(eturns)f(a)g(string,)h(and)f(the)h +(\002eld-parser)573 1729 y(typically)k(takes)g(a)g(string)h(ar)o +(gument,)f(this)h(is)g(not)g(r)o(equir)o(ed.)29 b(The)22 +b(r)o(ecor)o(d)f(r)o(eader)573 1829 y(can)d(pr)o(oduce,)f(and)g(the)h +(\002eld-parser)f(consume,)i(values)f(of)g(any)g(type.)24 +b(However)-6 b(,)573 1928 y(the)24 b(empty)h(list)g(r)o(eturned)e(as)i +(the)f(parsed)g(value)f(on)j(eof)e(is)h(har)o(dwir)o(ed)d(into)j(the) +573 2028 y(\002eld)20 b(r)o(eader)-6 b(.)573 2166 y(For)21 +b(example,)f(if)g(port)h Fy(p)f FC(is)i(open)f(on)g Fy(/etc/passwd)p +FC(,)16 b(then)756 2317 y Fy(\(\(field-reader)37 b(\(infix-splitter)h +(":")k(7\)\))g(p\))573 2459 y FC(r)o(eturns)20 b(two)i(values:)573 +2589 y Fh("dalbertz:mx3Uaqq0:107:22:Davi)q(d)45 b +(Albertz:/users/dalbertz:/bin/)q(csh")573 2681 y(\("dalbertz")d +("mx3Uaqq0")f("107")f("22")h("David)f(Albertz")h("/users/dalbertz")1044 +2772 y("/bin/csh"\))595 2910 y FC(The)23 b FB(\002eld-parser)f +FC(defaults)g(to)g(the)h(value)f(of)g Fy(\(field-splitter\))p +FC(,)16 b(a)22 b(parser)g(that)573 3010 y(picks)f(out)g(sequences)g(of) +g(non-white-space)g(strings.)573 3148 y(The)g FB(r)o(ec-r)o(eader)f +FC(defaults)g(to)h Fy(read-line)p FC(.)573 3286 y(Figur)o(e)35 +b(7.2)e(shows)k Fy(field-reader)30 b FC(being)35 b(used)g(to)h(r)o(ead) +d(dif)o(fer)o(ent)g(kinds)j(of)573 3385 y(Unix)21 b(r)o(ecor)o(ds.)365 +3676 y FA(7.1.4)81 b(Forward-progress)21 b(guarantees)d(and)i +(empty-string)e(matches)365 3869 y FC(A)j(loop)g(that)g(pulls)g(text)f +(of)o(f)g(a)g(string)i(by)e(r)o(epeatedly)f(matching)i(a)g(r)o(egexp)e +(against)i(that)365 3969 y(string)28 b(can)g(conceivably)f(get)g(stuck) +h(in)g(an)f(in\002nite)i(loop)f(if)f(the)h(r)o(egexp)e(matches)h(the) +365 4068 y(empty)d(string.)36 b(For)24 b(example,)g(the)g(r)o(egexps)e +Fy(^)p FC(,)i Fy($)p FC(,)g Fy(.*)p FC(,)g(and)f Fy(foo|[^f]*)d +FC(can)k(all)f(match)365 4168 y(the)e(empty)g(string.)490 +4301 y(The)29 b(r)o(outines)h(in)g(this)g(package)e(that)i(iterate)e +(thr)o(ough)i(strings)h(with)f(r)o(egular)e(ex-)365 4400 +y(pr)o(essions)23 b(ar)o(e)f(car)o(eful)e(to)j(handle)g(this)g +(empty-string)g(case.)31 b(If)22 b(a)g(r)o(egexp)g(matches)g(the)365 +4500 y(empty)27 b(string,)h(the)f(next)f(sear)o(ch)g(starts,)h(not)h +(fr)o(om)e(the)g(end)g(of)h(the)g(match)f(\(which)h(in)365 +4599 y(the)d(empty)f(string)h(case)f(is)g(also)h(the)f +(beginning\227that's)i(the)e(pr)o(oblem\),)g(but)h(fr)o(om)e(the)365 +4699 y(next)j(character)e(over)-6 b(.)38 b(This)25 b(is)h(the)f(corr)o +(ect)e(behaviour)-6 b(.)38 b(Regexps)25 b(match)g(the)g(longest)365 +4799 y(possible)i(string)g(at)f(a)g(given)g(location,)i(so)f(if)f(the)g +(r)o(egexp)f(matched)h(the)g(empty)h(string)365 4898 +y(at)d(location)i Fz(i)p FC(,)e(then)h(it)g(is)g(guaranteed)e(it)i +(could)g(not)g(have)f(matched)g(a)g(longer)h(pattern)1737 +5147 y(1)-5 b(17)p eop +%%Page: 118 124 +118 123 bop 681 1310 2865 4 v 681 4120 4 2811 v 718 1426 +a Fy(;;;)42 b(/etc/passwd)e(reader)718 1525 y(\(field-reader)e +(\(infix-splitter)g(":")k(7\)\))892 1625 y(;)i(wandy:3xuncWdpK)o(hR.)o +(:7)o(3:2)o(2:)o(Wa)o(ndy)37 b(Saetan:/usr/wand)o(y:)o(/bi)o(n/)o(cs)o +(h)718 1824 y(;;;)42 b(Two)h(ls)g(-l)f(output)f(readers)718 +1924 y(\(field-reader)d(\(infix-splitter)g("[)k(\\t]+")g(8\)\))718 +2024 y(\(field-reader)c(\(infix-splitter)g("[)k(\\t]+")g(-7\)\))892 +2123 y(;)i(-rw-r--r--)83 b(1)43 b(shivers)171 b(22880)42 +b(Sep)g(24)h(12:45)e(scsh.scm)718 2322 y(;;;)h(Internet)f(hostname)f +(reader)718 2422 y(\(field-reader)e(\(field-splitter)g("[^.]+"\)\))892 +2522 y(;)44 b(stat.sinica.edu)o(.tw)718 2721 y(;;;)e(Internet)f(IP)i +(address)d(reader)718 2821 y(\(field-reader)e(\(field-splitter)g +("[^.]+")i(4\)\))892 2920 y(;)k(18.24.0.241)718 3119 +y(;;;)e(Line)g(of)h(integers)718 3219 y(\(let)f(\(\(parser)e +(\(field-splitter)e("[+-]?[0-9]+"\)\)\))805 3319 y(\(field-reader)h(\() +p Fz(\025)f Fy(\(s\))43 b(\(map)f(string->number)37 b(\(parser)k +(s\)\)\)\))892 3418 y(;)j(18)e(24)h(0)g(241)718 3618 +y(;;;)f(Same)g(as)h(above.)718 3717 y(\(let)f(\(\(reader)e +(\(field-reader)f(\(field-splitter)e("[+-]?[0-9]+"\)\)\))o(\))805 +3817 y(\()p Fz(\025)i Fy(maybe-port)h(\(map)h(string->number)d(\(apply) +j(reader)g(maybe-port\)\)\)\))892 3917 y(;)j(Yale)e(beat)g(harvard)e +(26)j(to)g(7.)1305 4096 y FC(Figur)o(e)21 b(7.2:)j(Some)d(examples)f +(of)h Fy(field-reader)p 3542 4120 V 681 4123 2865 4 v +2053 5147 a FC(1)-5 b(18)p eop +%%Page: 119 125 +119 124 bop 365 614 a FC(starting)23 b(with)f(character)f +Fz(i)p FC(.)29 b(So)22 b(we)g(can)g(safely)f(begin)h(our)h(sear)o(ch)e +(for)g(the)h(next)g(match)365 714 y(at)f(char)f Fz(i)e +Fn(+)g(1)p FC(.)490 854 y(W)-5 b(ith)24 b(this)h(pr)o(ovision,)f(every) +f(iteration)h(thr)o(ough)g(the)f(loop)h(makes)g(some)g(forwar)o(d)365 +953 y(pr)o(ogr)o(ess,)c(and)g(the)h(loop)h(is)f(guaranteed)e(to)i +(terminate.)490 1093 y(This)i(has)g(the)h(ef)o(fect)d(you)i(want)g +(with)h(\002eld)f(parsing.)32 b(For)24 b(example,)e(if)h(you)h(split)f +(a)365 1193 y(string)28 b(with)f(the)g(empty)g(pattern,)h(you)f(will)g +(explode)g(the)f(string)i(into)f(its)h(individual)365 +1292 y(characters:)573 1455 y Fy(\(\(suffix-splitte)o(r)37 +b(""\))43 b("foo"\))e Fn(=)-14 b Fu(\))87 b Fy(\("")42 +b("f")g("o")h("o"\))365 1617 y FC(However)-6 b(,)27 b(even)e(though)i +(this)f(boundary)g(case)f(is)g(handled)h(corr)o(ectly)-9 +b(,)25 b(we)h(don't)g(r)o(ec-)365 1717 y(ommend)c(using)f(it.)26 +b(Say)20 b(what)h(you)g(mean\227just)h(use)f(a)f(\002eld)h(splitter:) +573 1879 y Fy(\(\(field-splitter)37 b("."\))42 b("foo"\))f +Fn(=)-14 b Fu(\))87 b Fy(\("f")42 b("o")g("o"\))365 2041 +y FC(Or)-6 b(,)21 b(mor)o(e)f(ef)o(\002ciently)-9 b(,)573 +2204 y Fy(\(\()p Fz(\025)38 b Fy(\(s\))43 b(\(map)e(string)h +(\(string->list)c(s\)\)\))k("foo"\))365 2494 y FA(7.1.5)81 +b(Reader)20 b(limitations)365 2697 y FC(Since)28 b(all)h(of)f(the)h(r)o +(eaders)e(in)i(this)g(package)e(r)o(equir)o(e)h(the)g(ability)h(to)g +(peek)f(ahead)f(one)365 2796 y(char)19 b(in)i(the)e(input)h(str)o(eam,) +f(they)h(cannot)g(be)g(applied)e(to)i(raw)g(integer)f(\002le)h +(descriptors,)365 2896 y(only)j(Scheme)e(input)h(ports.)29 +b(This)22 b(is)g(because)f(Unix)h(doesn't)g(support)g(peeking)g(ahead) +365 2996 y(into)g(input)f(str)o(eams.)365 3312 y Fw(7.2)99 +b(A)-7 b(wk)365 3546 y FC(Scsh)25 b(pr)o(ovides)g(a)f(loop)i(macr)o(o)e +(and)h(a)f(set)h(of)g(\002eld)g(parsers)f(that)h(can)g(be)g(used)g(to)g +(per)o(-)365 3646 y(form)34 b(text)f(pr)o(ocessing)h(very)f(similar)g +(to)h(the)g(A)-6 b(wk)33 b(pr)o(ogramming)g(language.)64 +b(The)365 3745 y(basic)30 b(functionality)h(of)f(A)-6 +b(wk)30 b(is)g(factor)o(ed)e(in)j(scsh)f(into)h(its)g(component)g +(parts.)53 b(The)365 3845 y(contr)o(ol)25 b(str)o(uctur)o(e)g(is)g(pr)o +(ovided)e(by)i(the)g Fy(awk)e FC(loop)j(macr)o(o;)g(the)e(text)h(I/O)g +(and)f(parsers)365 3944 y(ar)o(e)19 b(pr)o(ovided)g(by)h(the)h +(\002eld-r)o(eader)c(subr)o(outine)k(library)f(\(section)g(7.1\).)k +(This)d(factoring)365 4044 y(allows)g(the)f(pr)o(ogrammer)f(to)h +(compose)g(the)g(basic)g(loop)g(str)o(uctur)o(e)f(with)i(any)f(parser)e +(or)365 4144 y(input)i(mechanism)g(at)f(all.)25 b(If)19 +b(the)g(parsers)g(pr)o(ovided)f(by)i(the)f(\002eld-r)o(eader)e(package) +h(ar)o(e)365 4243 y(insuf)o(\002cient,)28 b(the)f(pr)o(ogrammer)f(can)g +(write)h(a)f(custom)h(parser)e(in)j(Scheme)e(and)g(use)g(it)365 +4343 y(with)c(equal)f(ease)f(in)h(the)g(awk)f(framework.)490 +4483 y(A)-6 b(wk-in-scheme)20 b(is)i(given)f(by)f(a)h(loop)g(macr)o(o)f +(called)g Fy(awk)p FC(.)k(It)d(looks)h(like)f(this:)573 +4699 y Fy(\(awk)42 b Fz(<)p FB(next-r)o(ecord)p Fz(>)f(<)p +FB(r)o(ecord&\002eld-vars)p Fz(>)791 4799 y FC([)p Fz(<)p +FB(counter)p Fz(>)p FC(])h Fz(<)p FB(state-var-decls)p +Fz(>)660 4898 y(<)p FB(clause)929 4910 y Fv(1)966 4898 +y Fz(>)h Fy(...\))1737 5147 y FC(1)-5 b(19)p eop +%%Page: 120 126 +120 125 bop 805 614 a FC(The)24 b(body)f(of)g(the)h(loop)g(is)g(a)f +(series)g(of)g(clauses,)h(each)e(one)i(r)o(epr)o(esenting)f(a)f(kind)i +(of)681 714 y(condition/action)j(pair)-6 b(.)40 b(The)25 +b(loop)i(r)o(epeatedly)c(r)o(eads)h(a)i(r)o(ecor)o(d,)e(and)i(then)g +(executes)681 814 y(each)20 b(clause)g(whose)i(condition)g(is)f +(satis\002ed)g(by)f(the)h(r)o(ecor)o(d.)805 939 y(Her)o(e's)i(an)h +(example)f(that)h(r)o(eads)e(lines)j(fr)o(om)e(port)h +Fy(p)g FC(and)f(prints)i(the)f(line)g(number)681 1038 +y(and)c(line)h(of)g(every)f(line)h(containing)h(the)f(string)h(\223)p +Fy(Church-Rosser)p FC(\224)o(:)888 1230 y Fy(\(awk)42 +b(\(read-line\))d(\(ln\))j(lineno)f(\(\))976 1329 y(\("Church-Rosser)o +(")c(\(format)k(#t)i("~d:)f(~s~\045")f(lineno)g(ln\)\)\))681 +1521 y FC(This)18 b(example)e(has)h(just)i(one)e(clause)g(in)h(the)f +(loop)h(body)-9 b(,)18 b(the)f(one)h(that)f(tests)h(for)f(matches)681 +1620 y(against)j(the)h(r)o(egular)f(expr)o(ession)g(\223)p +Fy(Church-Rosser)p FC(\224.)805 1745 y(The)c Fz(<)p FB(next-r)o(ecord)p +Fz(>)e FC(form)j(is)f(an)g(expr)o(ession)g(that)g(is)g(evaluated)f +(each)g(time)h(thr)o(ough)681 1845 y(the)27 b(loop)h(to)g(pr)o(oduce)e +(a)h(r)o(ecor)o(d)f(to)h(pr)o(ocess.)45 b(This)28 b(expr)o(ession)f +(can)g(r)o(eturn)f(multiple)681 1945 y(values;)18 b(these)g(values)g +(ar)o(e)f(bound)h(to)h(the)f(variables)f(given)i(in)f(the)g +Fz(<)p FB(r)o(ecord&\002eld-vars)p Fz(>)681 2044 y FC(list)24 +b(of)g(variables.)35 b(The)24 b(\002rst)g(value)g(r)o(eturned)f(is)h +(assumed)g(to)g(be)g(the)g(r)o(ecor)o(d;)g(when)h(it)681 +2144 y(is)c(the)g(end-of-\002le)f(object,)h(the)g(loop)g(terminates.) +805 2269 y(For)d(example,)f(let's)h(suppose)g(we)f(want)h(to)f(r)o(ead) +f(items)i(fr)o(om)f Fy(/etc/password)p FC(,)12 b(and)681 +2368 y(we)20 b(use)g(the)g Fy(field-reader)c FC(pr)o(ocedur)o(e)i(to)i +(de\002ne)g(a)g(r)o(ecor)o(d)f(parser)g(for)h Fy(/etc/passwd)681 +2468 y FC(entries:)888 2607 y Fy(\(define)41 b(read-passwd)e +(\(field-reader)f(\(infix-splitter)g(":")k(7\)\)\))681 +2746 y FC(binds)22 b Fy(read-passwd)c FC(to)23 b(a)f(pr)o(ocedur)o(e)e +(that)i(r)o(eads)f(in)i(a)f(line)h(of)f(text)g(when)h(it)f(is)h +(called,)681 2846 y(and)39 b(splits)i(the)f(text)f(at)h(colons.)84 +b(It)40 b(r)o(eturns)f(two)i(values:)63 b(the)40 b(entir)o(e)g(line)g +(r)o(ead,)681 2946 y(and)30 b(a)g(seven-element)g(list)h(of)g(the)g +(split-out)g(\002elds.)55 b(\(See)29 b(section)i(7.1)f(for)g(mor)o(e)g +(on)681 3045 y Fy(field-reader)16 b FC(and)k Fy(infix-splitter)p +FC(.\))805 3170 y(So)27 b(if)g(the)g Fz(<)p FB(next-r)o(ecord)p +Fz(>)e FC(form)i(in)g(an)g Fy(awk)f FC(expr)o(ession)g(is)i +Fy(\(read-passwd\))p FC(,)23 b(then)681 3270 y Fz(<)p +FB(r)o(ecord&\002eld-vars)p Fz(>)18 b FC(must)k(be)e(a)g(list)i(of)e +(two)i(variables,)d FB(e.g.)o FC(,)888 3409 y Fy(\(record)41 +b(field-vec\))681 3548 y FC(since)21 b Fy(read-passwd)16 +b FC(r)o(eturns)k(two)i(values.)805 3673 y(Note)27 b(that)f +Fy(awk)g FC(allows)h(us)g(to)f(use)h FB(any)f FC(r)o(ecor)o(d)f(r)o +(eader)f(we)j(want)f(in)h(the)g(loop,)h(r)o(e-)681 3772 +y(turning)k(whatever)e(number)h(of)g(values)f(we)h(like.)57 +b(These)31 b(values)f(don't)i(have)e(to)h(be)681 3872 +y(strings)21 b(or)f(string)h(lists.)26 b(The)21 b(only)g(r)o(equir)o +(ement)e(is)i(that)f(the)h(r)o(ecor)o(d)d(r)o(eader)g(r)o(eturn)i(the) +681 3972 y(eof)g(object)h(as)g(its)g(\002rst)g(value)f(when)i(the)f +(loop)g(should)h(terminate.)805 4097 y(The)33 b Fy(awk)f +FC(loop)i(allows)f(the)g(pr)o(ogrammer)f(to)i(have)e(loop)i(variables.) +61 b(These)32 b(ar)o(e)681 4196 y(declar)o(ed)18 b(and)j(initialised)g +(by)g(the)g Fz(<)p FB(state-var-decls)p Fz(>)d FC(form,)j(a)888 +4335 y Fy(\(\()p FB(var)43 b(init-exp)o Fy(\))g(\()p +FB(var)g(init-exp)o Fy(\))g(...\))681 4475 y FC(list)26 +b(rather)g(like)g(the)g Fy(let)f FC(form.)41 b(Whenever)25 +b(a)h(clause)f(in)i(the)f(loop)g(body)g(executes,)h(it)681 +4574 y(evaluates)19 b(to)j(as)e(many)h(values)g(as)f(ther)o(e)g(ar)o(e) +f(state)i(variables,)e(updating)i(them.)805 4699 y(The)31 +b(optional)g Fz(<)p FB(counter)p Fz(>)f FC(variable)f(is)i(an)g +(iteration)f(counter)-6 b(.)55 b(It)31 b(is)g(bound)g(to)g(0)681 +4799 y(when)21 b(the)g(loop)g(starts.)k(The)c(counter)f(is)h(incr)o +(emented)f(each)g(time)h(a)f(non-eof)h(r)o(ecor)o(d)e(is)681 +4898 y(r)o(ead.)2051 5147 y(120)p eop +%%Page: 121 127 +121 126 bop 490 614 a FC(Ther)o(e)28 b(ar)o(e)f(several)h(kinds)h(of)g +(loop)g(clause.)49 b(When)30 b(evaluating)e(the)h(body)g(of)f(the)365 +714 y(loop,)h Fy(awk)c FC(evaluates)h FB(all)h FC(the)g(clauses)f +(sequentially)-9 b(.)44 b(Unlike)27 b Fy(cond)p FC(,)f(it)h(does)g(not) +g(stop)365 814 y(after)20 b(the)h(\002rst)g(clause)f(is)h(satis\002ed;) +g(it)g(checks)f(them)i(all.)490 1010 y Fu(\017)41 b Fy(\()p +FB(test)i(body)938 1037 y Fv(1)1019 1010 y FB(body)1177 +1037 y Fv(2)1258 1010 y Fy(...\))573 1110 y FC(If)28 +b FB(test)h FC(is)g(tr)o(ue,)i(execute)d(the)h(body)g(forms.)50 +b(The)28 b(last)h(body)g(form)g(is)g(the)g(value)573 +1209 y(of)24 b(the)h(clause.)35 b(The)25 b(test)f(and)g(body)g(forms)h +(ar)o(e)e(evaluated)g(in)h(the)h(scope)f(of)g(the)573 +1309 y(r)o(ecor)o(d)19 b(and)h(state)h(variables.)573 +1440 y(The)g FB(test)f FC(form)h(can)f(be)h(one)g(of:)805 +1558 y(integer:)213 b(The)26 b(test)h(is)g(tr)o(ue)g(for)g(that)f +(iteration)h(of)g(the)g(loop.)44 b(The)1297 1658 y(\002rst)21 +b(iteration)g(is)g(#1.)805 1758 y(string:)258 b(The)23 +b(string)i(is)f(a)f(r)o(egular)g(expr)o(ession.)34 b(The)24 +b(test)g(is)g(tr)o(ue)1297 1857 y(if)c(the)h(r)o(egexp)f(matches)g(the) +h(r)o(ecor)o(d.)805 1957 y(expr)o(ession)100 b(If)38 +b(not)i(an)e(integer)h(or)g(a)f(string,)44 b(the)39 b(test)f(form)h(is) +g(a)1297 2056 y(Scheme)20 b(expr)o(ession)h(that)f(is)h(evaluated.)490 +2234 y Fu(\017)91 b Fy(\(range)128 b FB(start-test)43 +b(stop-test)f(body)1851 2261 y Fv(1)1931 2234 y Fy(...\))623 +2334 y(\(:range)84 b FB(start-test)43 b(stop-test)f(body)1851 +2361 y Fv(1)1931 2334 y Fy(...\))623 2434 y(\(range:)84 +b FB(start-test)43 b(stop-test)f(body)1851 2461 y Fv(1)1931 +2434 y Fy(...\))623 2533 y(\(:range:)e FB(start-test)j(stop-test)f +(body)1851 2560 y Fv(1)1931 2533 y Fy(...\))573 2632 +y FC(These)18 b(clauses)g(become)h(activated)e(when)i +FB(start-test)e FC(is)i(tr)o(ue;)g(they)g(stay)f(active)g(on)573 +2731 y(all)i(further)h(iterations)g(until)g FB(stop-test)f +FC(is)h(tr)o(ue.)573 2862 y(So,)f(to)h(print)g(out)h(the)f(\002rst)g +(ten)f(lines)i(of)f(a)f(\002le,)g(we)h(use)g(the)g(clause:)756 +3001 y Fy(\(:range:)40 b(1)j(10)g(\(display)d(record\)\))573 +3170 y FC(The)24 b(colons)i(contr)o(ol)f(whether)g(or)g(not)g(the)g +(start)f(and)g(stop)h(lines)g(ar)o(e)f(pr)o(ocessed)573 +3270 y(by)d(the)g(clause.)k(For)c(example:)805 3410 y +Fy(\(range)129 b(1)43 b(5)87 b(...\))164 b FC(Lines)83 +b(2)20 b(3)h(4)805 3510 y Fy(\(:range)85 b(1)43 b(5)87 +b(...\))164 b FC(Lines)21 b(1)f(2)g(3)h(4)805 3609 y +Fy(\(range:)85 b(1)43 b(5)87 b(...\))164 b FC(Lines)83 +b(2)20 b(3)h(4)f(5)805 3709 y Fy(\(:range:)41 b(1)i(5)87 +b(...\))164 b FC(Lines)21 b(1)f(2)g(3)h(4)f(5)573 3878 +y(A)g(line)g(can)g(trigger)h(both)g(tests,)f(either)g(simultaneously)i +(starting)f(and)f(stopping)573 3977 y(an)f(active)g(r)o(egion,)h(or)g +(simultaneously)h(stopping)g(one)f(and)f(starting)h(a)f(new)h(one,)573 +4077 y(so)h(ranges)g(can)f(abut)g(seamlessly)-9 b(.)490 +4239 y Fu(\017)41 b Fy(\(else)g FB(body)993 4266 y Fv(1)1074 +4239 y FB(body)1232 4266 y Fv(2)1313 4239 y Fy(...\))573 +4338 y FC(If)22 b(no)h(other)f(clause)g(has)g(executed)f(since)i(the)f +(top)h(of)f(the)g(loop,)h(or)g(since)f(the)h(last)573 +4438 y Fy(else)c FC(clause,)h(this)i(clause)e(executes.)490 +4599 y Fu(\017)41 b Fy(\()p FB(test)i Fy(=>)g FB(exp)o +Fy(\))573 4699 y FC(If)25 b(evaluating)f Fy(test)g FC(pr)o(oduces)g(a)h +(tr)o(ue)g(value,)h(apply)e FB(exp)h FC(to)h(that)f(value.)38 +b(If)25 b FB(test)573 4799 y FC(is)20 b(a)f(r)o(egular)o(-expr)o +(ession)e(string,)j(then)g FB(exp)f FC(is)h(applied)f(to)h(the)g(match) +f(data)g(str)o(uc-)573 4898 y(tur)o(e)h(r)o(eturned)f(by)i(the)g(r)o +(egexp)f(match)g(r)o(outine.)1735 5147 y(121)p eop +%%Page: 122 128 +122 127 bop 805 614 a Fu(\017)41 b Fy(\(after)g FB(body)1352 +641 y Fv(1)1433 614 y Fy(...\))888 714 y FC(This)23 b(clause)f +(executes)f(when)i(the)f(loop)h(encounters)g(EOF)-8 b(.)22 +b(The)g(body)g(forms)h(ex-)888 814 y(ecute)h(in)h(the)f(scope)h(of)f +(the)g(state)g(vars)g(and)g(the)g(r)o(ecor)o(d-count)f(var)-6 +b(,)24 b(if)g(ther)o(e)f(ar)o(e)888 913 y(any)-9 b(.)26 +b(The)20 b(value)g(of)h(the)g(last)g(body)g(form)g(is)g(the)g(value)f +(of)g(the)h(entir)o(e)f(awk)h(form.)888 1042 y(If)f(ther)o(e)f(is)h(no) +g Fy(after)e FC(clause,)h Fy(awk)f FC(r)o(eturns)i(the)g(loop's)g +(state)g(variables)e(as)i(multi-)888 1142 y(ple)h(values.)681 +1389 y FA(7.2.1)81 b(Examples)681 1572 y FC(Her)o(e)26 +b(ar)o(e)g(some)i(examples)f(of)g Fy(awk)f FC(being)i(used)f(to)h(pr)o +(ocess)e(various)i(types)f(of)h(input)681 1671 y(str)o(eam.)888 +1858 y Fy(\(define)41 b($)i(nth\))347 b(;)43 b(Saves)f(typing.)888 +2058 y(;;;)h(Print)e(out)i(the)f(name)g(and)g(home-directory)c(of)43 +b(everyone)d(in)j(/etc/passwd:)888 2157 y(\(let)f(\(\(read-passwd)c +(\(field-reader)h(\(infix-splitter)e(":")42 b(7\)\)\)\))976 +2257 y(\(call-with-inpu)o(t-)o(fil)o(e)37 b("/etc/passwd")1063 +2357 y(\(lambda)j(\(port\))1150 2456 y(\(awk)i(\(read-passwd)c(port\))k +(\(record)f(fields\))f(\(\))1237 2556 y(\(#t)i(\(format)f(#t)i("~a's)e +(home)h(directory)e(is)j(~a~\045")1760 2655 y(\($)g(fields)e(0\))1760 +2755 y(\($)i(fields)e(5\)\)\)\)\)\)\))888 3005 y(;;;)i(Print)e(out)i +(the)f(user-name)e(and)i(home-directory)c(of)43 b(everyone)d(whose)888 +3104 y(;;;)j(name)f(begins)f(with)h("S")888 3204 y(\(let)g +(\(\(read-passwd)c(\(field-reader)h(\(infix-splitter)e(":")42 +b(7\)\)\)\))976 3303 y(\(call-with-inpu)o(t-)o(fil)o(e)37 +b("/etc/passwd")1063 3403 y(\(lambda)j(\(port\))1150 +3503 y(\(awk)i(\(read-passwd)c(port\))k(\(record)f(fields\))f(\(\))1237 +3602 y(\("^S")i(\(format)e(#t)j("~a's)f(home)f(directory)f(is)j +(~a~\045")1847 3702 y(\($)g(fields)e(0\))1847 3802 y(\($)i(fields)e +(5\)\)\)\)\)\)\))888 4051 y(;;;)i(Read)f(a)h(series)e(of)i(integers)d +(from)i(stdin.)f(This)h(expression)d(evaluates)888 4151 +y(;;;)k(to)f(the)h(number)e(of)i(positive)d(numbers)h(that)h(were)f +(read.)h(Note)g(our)888 4250 y(;;;)h("record-reader")37 +b(is)43 b(the)f(standard)e(Scheme)i(READ)f(procedure.)888 +4350 y(\(awk)h(\(read\))f(\(i\))130 b(\(\(npos)41 b(0\)\))976 +4450 y(\(\(>)h(i)h(0\))g(\(+)g(npos)e(1\)\)\))888 4699 +y(;;;)i(Filter)e(--)i(pass)e(only)h(lines)g(containing)d(my)k(name.)888 +4799 y(\(awk)f(\(read-line\))d(\(line\))i(\(\))976 4898 +y(\("Olin")f(\(display)g(line\))i(\(newline\)\)\))2051 +5147 y FC(122)p eop +%%Page: 123 129 +123 128 bop 573 614 a Fy(;;;)42 b(Count)g(the)g(number)f(of)i +(non-comment)c(lines)i(of)i(code)f(in)h(my)g(Scheme)e(source.)573 +714 y(\(awk)h(\(read-line\))d(\(line\))i(\(\(nlines)f(0\)\))660 +814 y(\("^[)i(\\t]*;")f(nlines\))651 b(;)43 b(A)g(comment)e(line.)660 +913 y(\(else)303 b(\(+)43 b(nlines)e(1\)\)\))347 b(;)43 +b(Not)f(a)i(comment)c(line.)573 1196 y(;;;)i(Read)g(numbers,)e +(counting)h(the)h(evens)g(and)g(odds.)573 1295 y(\(awk)g(\(read\))f +(\(val\))g(\(\(evens)g(0\))i(\(odds)e(0\)\))660 1395 +y(\(\(>)h(val)h(0\))f(\(display)f("pos)h("\))86 b(\(values)41 +b(evens)g(odds\)\))g(;)j(Tell)d(me)i(about)660 1494 y(\(\(<)f(val)h +(0\))f(\(display)f("neg)h("\))86 b(\(values)41 b(evens)g(odds\)\))g(;)j +(sign,)d(too.)660 1594 y(\(else)259 b(\(display)41 b("zero)g("\))i +(\(values)e(evens)g(odds\)\))660 1793 y(\(\(even?)g(val\))h(\(values)e +(\(+)j(evens)f(1\))g(odds\)\))660 1893 y(\(else)347 b(\(values)40 +b(evens)303 b(\(+)43 b(odds)f(1\)\)\)\))573 2175 y(;;;)g(Determine)e +(the)i(max)h(length)e(of)i(all)f(the)g(lines)g(in)h(the)f(file.)573 +2275 y(\(awk)g(\(read-line\))d(\(line\))i(\(\(max-len)f(0\)\))660 +2374 y(\(#t)i(\(max)g(max-len)f(\(string-length)d(line\)\)\)\))573 +2657 y(;;;)k(\(This)g(could)f(also)h(be)h(done)f(with)g(REDUCE-PORT:\)) +573 2756 y(\(reduce-port)c(\(current-input-po)o(rt\))f(read-line)1139 +2856 y(\(lambda)k(\(line)h(maxlen\))e(\(max)i(\(string-length)c(line\)) +k(maxlen\)\))1139 2956 y(0\))573 3238 y(;;;)g(Print)g(every)f(line)h +(longer)f(than)h(80)h(chars.)573 3337 y(;;;)f(Prefix)f(each)h(line)g +(with)g(its)g(line)g(#.)573 3437 y(\(awk)g(\(read-line\))d(\(line\))i +(lineno)g(\(\))660 3537 y(\(\(>)h(\(string-length)c(line\))k(80\))704 +3636 y(\(format)e(#t)j("~d:)f(~s~\045")g(lineno)f(line\)\)\))573 +3919 y(;;;)h(Strip)g(blank)f(lines)h(from)g(input.)573 +4018 y(\(awk)g(\(read-line\))d(\(line\))i(\(\))660 4118 +y(\(".")h(\(display)e(line\))i(\(newline\)\)\))573 4400 +y(;;;)g(Sort)g(the)g(entries)f(in)i(/etc/passwd)c(by)k(login)e(name.) +573 4500 y(\(for-each)f(\(lambda)g(\(entry\))h(\(display)f(\(cdr)i +(entry\)\))f(\(newline\)\))432 b(;)43 b(Out)1009 4599 +y(\(sort)e(\(lambda)g(\(x)i(y\))f(\(string)c Fn(0)p FC(;)28 b(a)e(right)h(shift) +g(is)573 3238 y Fz(j)h(<)22 b Fn(0)p FC(.)365 3516 y +Fw(8.2)99 b(List)26 b(procedures)365 3739 y Fy(\(nth)42 +b FB(list)21 b(i)p Fy(\))87 b Fu(\000)-14 b(!)87 b FB(object)1578 +b FC(pr)o(ocedur)o(e)573 3856 y(Returns)22 b(the)h Fz(i)1050 +3826 y Fv(t)p Fo(h)1140 3856 y FC(element)f(of)g FB(list)p +FC(.)29 b(The)22 b(\002rst)g(element)g(\(the)g(car\))f(is)h +Fy(\(nth)42 b FB(list)i Fy(0\))p FC(,)573 3956 y(the)21 +b(second)g(element)g(is)g Fy(\(nth)42 b FB(list)h Fy(1\))p +FC(,)20 b(and)g(so)i(on.)573 4081 y(This)e(pr)o(ocedur)o(e)f(is)h(pr)o +(ovided)f(as)h(it)g(is)g(useful)g(for)g(accessing)g(elements)h(fr)o(om) +e(the)573 4180 y(lists)i(r)o(eturned)f(by)h(the)g(\002eld-r)o(eaders)d +(\(chapter)i(7\).)365 4459 y Fw(8.3)99 b(T)-11 b(op)26 +b(level)365 4682 y Fy(\(repl\))85 b Fu(\000)-14 b(!)87 +b FB(unde\002ned)1590 b FC(pr)o(ocedur)o(e)573 4799 y(This)23 +b(r)o(uns)h(a)e(Scheme)h(48)f(r)o(ead-eval-print)e(loop,)k(r)o(eading)e +(forms)h(fr)o(om)g(the)g(cur)o(-)573 4898 y(r)o(ent)d(input)h(port,)g +(and)f(writing)i(their)f(values)f(to)h(the)g(curr)o(ent)f(output)h +(port.)1735 5147 y(125)p eop +%%Page: 126 132 +126 131 bop 888 614 a FC(If)25 b(you)h(wish)f(to)h(try)f(something)i +(danger)o(ous,)e(and)f(want)h(to)h(be)f(able)f(to)h(r)o(ecover)888 +714 y(your)c(shell)h(state,)e(you)h(can)g(fork)f(of)o(f)g(a)g(subshell) +i(with)g(the)e(following)j(form:)1071 853 y Fy(\(run)42 +b(\(begin)f(\(repl\)\)\))888 991 y FC(.)12 b(.)g(.)g(or)-6 +b(,)21 b(r)o(ephrased)e(for)i(the)g(pr)o(oceduralists:)1071 +1130 y Fy(\(wait)42 b(\(fork)f(repl\)\))2051 5147 y FC(126)p +eop +%%Page: 127 133 +127 132 bop 365 1266 a Fx(Chapter)45 b(9)365 1709 y FD(Running)53 +b(scsh)365 2194 y FC(Scsh)23 b(is)g(curr)o(ently)f(implemented)h(on)h +(top)f(of)g(Scheme)f(48,)g(a)g(fr)o(eely-available)e(Scheme)365 +2293 y(implementation)i(written)f(by)f(Jonathan)g(Rees)h(and)f(Richar)o +(d)g(Kelsey)-9 b(.)25 b(Scheme)20 b(48)f(uses)365 2393 +y(a)33 b(byte-code)g(interpr)o(eter)f(for)h(good)h(code)g(density)-9 +b(,)36 b(portability)e(and)f(medium)h(ef)o(\002-)365 +2493 y(ciency)-9 b(.)26 b(It)20 b(is)i(R4RS.)e(It)h(also)g(has)g(a)f +(module)h(system)h(designed)e(by)h(Jonathan)g(Rees.)490 +2621 y(Scsh's)k(design)h(is)g(not)f(Scheme)g(48)g(speci\002c,)h +(although)g(the)f(curr)o(ent)g(implementa-)365 2720 y(tion)k(is)e +(necessarily)g(so.)46 b(Scsh)27 b(is)h(intended)f(to)h(be)f +(implementable)h(in)f(other)h(Scheme)365 2820 y(implementations.)37 +b(The)24 b(Scheme)g(48)f(virtual)h(machine)g(that)g(scsh)h(uses)g(is)f +(a)g(specially)365 2920 y(modi\002ed)k(version;)i(standar)o(d)c(Scheme) +g(48)g(virtual)h(machines)h(cannot)f(be)g(used)g(with)365 +3019 y(the)21 b(scsh)h(heap)e(image.)490 3147 y(Ther)o(e)37 +b(ar)o(e)f(several)h(dif)o(fer)o(ent)f(ways)i(to)h(invoke)f(scsh.)78 +b(Y)-8 b(ou)39 b(can)e(r)o(un)i(it)f(as)g(an)365 3247 +y(interactive)30 b(Scheme)g(system,)k(with)d(a)f(standar)o(d)f(r)o +(ead-eval-print)e(interaction)k(loop.)365 3347 y(Scsh)38 +b(can)f(also)h(be)f(invoked)h(as)f(the)g(interpr)o(eter)g(for)g(a)g +(shell)h(script)f(by)h(putting)g(a)365 3446 y(\223)p +Fy(#!/usr/local/bin)o(/s)o(csh)f(-s)p FC(\224)19 b(line)i(at)g(the)g +(top)g(of)f(the)h(shell)h(script.)490 3575 y(Descending)h(a)g(level,)f +(it)i(is)f(also)g(possible)g(to)h(invoke)f(the)g(underlying)h(virtual)e +(ma-)365 3674 y(chine)k(byte-code)f(interpr)o(eter)g(dir)o(ectly)g(on)h +(dumped)f(heap)h(images.)40 b(Scsh)26 b(pr)o(ograms)365 +3774 y(can)i(be)f(pr)o(e-compiled)f(to)i(byte-codes)f(and)g(dumped)g +(as)g(raw)-8 b(,)29 b(binary)f(heap)f(images.)365 3873 +y(W)-6 b(riting)28 b(heap)e(images)h(strips)g(out)h(unused)f(portions)h +(of)f(the)g(scsh)g(r)o(untime)h(\(such)f(as)365 3973 +y(the)19 b(compiler)-6 b(,)20 b(the)f(debugger)-6 b(,)18 +b(and)g(other)i(complex)f(subsystems\),)h(r)o(educing)e(memory)365 +4073 y(demands)25 b(and)g(saving)h(loading)g(and)f(compilation)i +(times.)40 b(The)25 b(heap)g(image)h(format)365 4172 +y(allows)j(for)f(an)h(initial)g Fy(#!/usr/local/li)o(b/s)o(cs)o(h/s)o +(cs)o(hvm)22 b FC(trigger)28 b(on)h(the)f(\002rst)h(line)365 +4272 y(of)23 b(the)f(image,)h(making)g(heap)f(images)g(dir)o(ectly)g +(executable)f(as)h(another)h(kind)g(of)f(shell)365 4372 +y(script.)490 4500 y(Finally)-9 b(,)24 b(scsh's)h(static)e(linker)h +(system)h(allows)f(dumped)f(heap)g(images)h(to)g(be)f(com-)365 +4599 y(piled)c(to)h(a)f(raw)g(Unix)g(a.out\(5\))e(format,)i(which)i +(can)e(be)g(linked)g(into)h(the)g(text)f(section)h(of)365 +4699 y(the)h(vm)g(binary)-9 b(.)26 b(This)21 b(pr)o(oduces)f(a)h(tr)o +(ue)g(Unix)g(executable)e(binary)i(\002le.)26 b(Since)21 +b(the)g(byte)365 4799 y(codes)i(comprising)h(the)e(pr)o(ogram)g(ar)o(e) +g(in)h(the)f(\002le's)h(text)g(section,)g(they)g(ar)o(e)e(not)j(traced) +365 4898 y(or)f(copied)g(by)f(the)h(garbage)f(collector)-6 +b(,)23 b(do)g(not)g(occupy)g(space)f(in)h(the)g(vm's)h(heap,)e(and)1735 +5147 y(127)p eop +%%Page: 128 134 +128 133 bop 681 614 a FC(do)16 b(not)g(need)g(to)g(be)g(loaded)f(and)h +(linked)g(at)f(startup)h(time.)24 b(This)17 b(r)o(educes)d(the)i(pr)o +(ogram's)681 714 y(startup)k(time,)h(memory)g(r)o(equir)o(ements,)f +(and)h(paging)g(over)o(head.)805 854 y(This)h(chapter)e(will)h(cover)f +(these)h(various)g(ways)g(of)g(invoking)h(scsh)f(pr)o(ograms.)681 +1169 y Fw(9.1)99 b(Scsh)25 b(command-line)f(switches)681 +1403 y FC(When)f(the)g(scsh)g(top-level)f(starts)h(up,)g(it)g(scans)f +(the)h(command)g(line)g(for)g(switches)g(that)681 1503 +y(contr)o(ol)i(its)h(behaviour)-6 b(.)38 b(These)25 b(ar)o(guments)g +(ar)o(e)e(r)o(emoved)i(fr)o(om)f(the)h(command)h(line;)681 +1602 y(the)35 b(r)o(emaining)f(ar)o(guments)h(can)f(be)h(accessed)e(as) +i(the)f(value)g(of)h(the)g(scsh)g(variable)681 1702 y +Fy(command-line-arg)o(um)o(ent)o(s)p FC(.)681 1992 y +FA(9.1.1)81 b(Scripts)19 b(and)h(programs)681 2194 y +FC(The)d(scsh)h(command-line)g(switches)g(pr)o(ovide)e(sophisticated)i +(support)f(for)g(the)h(authors)681 2294 y(of)28 b(shell)i(scripts)f +(and)f(pr)o(ograms;)k(they)d(also)g(allow)g(the)g(pr)o(ogrammer)f(to)h +(write)g(pr)o(o-)681 2393 y(grams)21 b(that)f(use)h(the)g(Scheme)f(48)g +(module)h(system.)805 2533 y(Ther)o(e)34 b(is)h(a)f(dif)o(fer)o(ence)e +(between)i(a)h FB(script)p FC(,)i(which)e(performs)g(its)g(action)g +FB(as)f(it)h(is)681 2633 y(loaded)p FC(,)d(and)f(a)g +FB(pr)o(ogram)p FC(,)h(which)g(is)g(loaded/linked,)h(and)e(then)g +(performs)g(its)h(action)681 2732 y(by)24 b(having)h(contr)o(ol)g +(transferr)o(ed)e(to)i(an)f(entry)h(point)h(\()p FB(e.g.)n +FC(,)g(the)f Fy(main\(\))d FC(function)j(in)g(C)681 2832 +y(pr)o(ograms\))20 b(that)g(was)h(de\002ned)f(by)h(the)g(load/link)h +(operation.)805 2971 y(A)g FB(script)p FC(,)f(by)g(the)h(above)f +(de\002nition,)i(cannot)f(be)f(compiled)h(by)g(the)g(simple)g(mecha-) +681 3071 y(nism)i(of)g(loading)f(it)h(into)g(a)f(scsh)h(pr)o(ocess)f +(and)g(dumping)h(out)g(a)f(heap)f(image\227it)i(exe-)681 +3171 y(cutes)c(as)h(it)g(loads.)k(It)c(does)g(not)g(have)g(a)f +(top-level)g Fy(main\(\))p FC(-type)e(entry)j(point.)805 +3310 y(It)g(is)g(mor)o(e)f(\003exible)h(and)f(useful)g(to)h(implement)h +(a)e(system)h(as)f(a)h(pr)o(ogram)e(than)i(as)g(a)681 +3410 y(script.)29 b(Pr)o(ograms)21 b(can)h(be)g(compiled)g +(straightforwar)o(dly;)f(they)h(can)g(also)g(export)g(pr)o(o-)681 +3509 y(cedural)g(interfaces)g(for)h(use)g(by)g(other)g(Scheme)g +(packages.)32 b(However)-6 b(,)23 b(scsh)h(supports)681 +3609 y(both)d(the)g(script)g(and)f(the)h(pr)o(ogram)f(style)h(of)g(pr)o +(ogramming.)681 3899 y FA(9.1.2)81 b(Inserting)19 b(interpreter)g +(triggers)h(into)g(scsh)g(programs)681 4101 y FC(When)g(Unix)f(tries)h +(to)g(execute)e(an)i(executable)e(\002le)i(whose)g(\002rst)g(16)f(bits) +h(ar)o(e)e(the)i(charac-)681 4201 y(ter)d(pair)f(\223)p +Fy(#!)p FC(\224,)g(it)i(tr)o(eats)e(the)i(\002le)f(not)h(as)f +(machine-code)g(to)h(be)f(dir)o(ectly)f(executed)g(by)i(the)681 +4301 y(native)26 b(pr)o(ocessor)-6 b(,)28 b(but)f(as)g(sour)o(ce)f +(code)h(to)g(be)g(executed)f(by)h(some)g(interpr)o(eter)-6 +b(.)43 b(The)681 4400 y(interpr)o(eter)22 b(to)h(use)h(is)f +(speci\002ed)g(immediately)h(after)e(the)h(\223)p Fy(#!)p +FC(\224)f(sequence)h(on)h(the)g(\002rst)681 4500 y(line)k(of)g(the)h +(sour)o(ce)e(\002le)h(\(along)h(with)f(one)h(optional)g(initial)f(ar)o +(gument\).)47 b(The)28 b(kernel)681 4599 y(r)o(eads)20 +b(in)i(the)f(name)h(of)f(the)h(interpr)o(eter)-6 b(,)20 +b(and)h(executes)g(that)g(instead.)28 b(The)21 b(interpr)o(eter)681 +4699 y(is)e(passed)g(the)h(sour)o(ce)e(\002lename)i(as)f(its)g(\002rst) +h(ar)o(gument,)f(with)h(the)f(original)h(ar)o(guments)681 +4799 y(following.)29 b(Consult)22 b(the)g(Unix)g(man)f(page)g(for)g +(the)h Fy(exec)e FC(system)i(call)f(for)g(mor)o(e)h(infor)o(-)681 +4898 y(mation.)2051 5147 y(128)p eop +%%Page: 129 135 +129 134 bop 490 614 a FC(Scsh)29 b(allows)h(Scheme)f(pr)o(ograms)g(to)g +(have)g(these)g(triggers)h(placed)e(on)i(their)f(\002rst)365 +714 y(line.)48 b(Scsh)28 b(tr)o(eats)f(the)h(character)f(sequence)h +(\223)p Fy(#!)p FC(\224)e(as)i(a)f(block-comment)i(sequence,)3192 +684 y Fv(1)365 814 y FC(and)41 b(skips)h(all)g(following)h(characters)d +(until)i(it)g(r)o(eads)e(the)h(comment-terminating)365 +913 y(sequence)34 b(newline/exclamation-point/sharp-sign/newline)i(\()p +FB(i.e.)p FC(,)g(the)d(sequence)365 1013 y(\223)p Fy(!#)p +FC(\224)19 b(occurring)i(on)h(its)f(own)h(line\).)490 +1142 y(In)f(this)g(way)-9 b(,)21 b(the)f(pr)o(ogrammer)g(can)h(arrange) +e(for)i(an)g(initial)573 1341 y Fy(#!/usr/local/bin)o(/s)o(csh)37 +b(-s)573 1441 y(!#)365 1640 y FC(header)31 b(appearing)f(in)i(a)f +(Scheme)g(pr)o(ogram)g(to)h(be)f(ignor)o(ed)g(when)h(the)f(pr)o(ogram)g +(is)365 1740 y(loaded)20 b(into)i(scsh.)365 2003 y FA(9.1.3)81 +b(Module)20 b(system)365 2193 y FC(Scsh)e(uses)f(the)h(Scheme)f(48)f +(module)i(system,)g(which)h(de\002nes)e FB(packages)p +FC(,)g FB(structur)o(es)p FC(,)h(and)365 2292 y FB(interfaces)p +FC(.)365 2491 y FA(Package)40 b FC(A)25 b(package)f(is)i(an)f(envir)o +(onment\227that)h(is,)h(a)e(set)g(of)h(variable/value)e(bind-)573 +2591 y(ings.)h(Y)-8 b(ou)17 b(can)f(evaluate)f(Scheme)h(forms)h(inside) +f(a)g(package,)g(or)h(load)f(a)f(\002le)i(into)g(a)573 +2691 y(package.)23 b(Packages)17 b(export)h(sets)g(of)g(bindings;)h +(these)f(sets)g(ar)o(e)e(called)h FB(structur)o(es)p +FC(.)365 2863 y FA(Structure)40 b FC(A)20 b(str)o(uctur)o(e)g(is)h(a)f +(named)g(view)g(on)h(a)f(package\227a)f(set)i(of)f(bindings.)26 +b(Other)573 2963 y(packages)15 b(can)h FB(open)g FC(the)g(str)o(uctur)o +(e,)g(importing)h(its)g(bindings)g(into)g(their)f(envir)o(on-)573 +3062 y(ment.)28 b(Packages)21 b(can)g(pr)o(ovide)f(mor)o(e)i(than)f +(one)h(str)o(uctur)o(e,)f(r)o(evealing)g(dif)o(fer)o(ent)573 +3162 y(portions)h(of)e(the)h(package's)f(envir)o(onment.)365 +3335 y FA(Interface)40 b FC(An)29 b(interface)e(is)i(the)f +(\223type\224)g(of)g(a)g(str)o(uctur)o(e.)48 b(An)28 +b(interface)g(is)h(the)f(set)h(of)573 3434 y(names)g(exported)g(by)g(a) +f(str)o(uctur)o(e.)51 b(These)29 b(names)g(can)g(also)g(be)g(marked)g +(with)573 3534 y(other)21 b(static)h(information)g(\()p +FB(e.g.)o FC(,)f(advisory)g(type)h(declarations,)e(or)i(syntax)f(infor) +o(-)573 3633 y(mation\).)365 3832 y(Mor)o(e)d(information)i(on)g(the)f +(the)g(Scheme)g(48)f(module)h(system)h(can)f(be)g(found)g(in)g(the)g +(\002le)365 3932 y Fy(module.ps)e FC(in)22 b(the)e Fy(doc)g +FC(dir)o(ectory)g(of)h(the)g(Scheme)f(48)g(and)g(scsh)h(r)o(eleases.) +490 4061 y(Pr)o(ogramming)33 b(Scheme)g(with)g(a)g(module)g(system)g +(is)g(dif)o(fer)o(ent)e(fr)o(om)i(pr)o(ogram-)365 4161 +y(ming)20 b(in)e(older)g(Scheme)g(implementations,)i(and)e(the)h +(associated)e(development)h(pr)o(ob-)365 4261 y(lems)36 +b(ar)o(e)d(consequently)j(dif)o(fer)o(ent.)66 b(In)35 +b(Schemes)g(that)g(lack)f(modular)h(abstraction)365 4360 +y(mechanisms,)26 b(everything)f(is)f(accessible;)h(the)f(major)h(pr)o +(oblem)f(is)g(pr)o(eventing)g(name-)365 4460 y(space)e(con\003icts.)32 +b(In)22 b(Scheme)h(48,)e(name-space)g(con\003icts)j(vanish;)g(the)e +(major)h(pr)o(oblem)365 4560 y(is)29 b(that)g(not)g(all)g(bindings)h +(ar)o(e)d(accessible)h(fr)o(om)g(every)h(place.)48 b(It)29 +b(takes)f(a)g(little)i(extra)365 4659 y(work)22 b(to)f(specify)f(what)h +(packages)f(export)g(which)i(values.)p 365 4742 1146 +4 v 450 4796 a Fq(1)485 4819 y Ft(Why)17 b(a)f(block-comment)h(instead) +f(of)h(an)g(end-of-line)f(delimited)g(comment?)k(See)d(the)e(section)j +(on)e(meta-)365 4898 y(ar)o(gs.)1735 5147 y FC(129)p +eop +%%Page: 130 136 +130 135 bop 805 614 a FC(It)20 b(may)g(take)f(you)h(a)f(little)h(while) +g(to)g(get)g(used)f(to)h(the)g(new)g(style)g(of)f(pr)o(ogram)g(devel-) +681 714 y(opment.)26 b(Although)21 b(scsh)h(can)e(be)g(used)g(without)i +(r)o(eferring)e(to)h(the)f(module)h(system)g(at)681 814 +y(all,)k(we)f(r)o(ecommend)g(taking)h(the)g(time)g(to)g(learn)f(and)g +(use)g(it.)37 b(The)24 b(ef)o(fort)g(will)h(pay)f(of)o(f)681 +913 y(in)d(the)g(constr)o(uction)h(of)f(modular)-6 b(,)20 +b(factorable)g(pr)o(ograms.)681 1384 y FA(Module)f(warning)681 +1680 y FC(Pr)o(ogrammers)34 b(who)i(open)g(both)g(the)f +Fy(scheme)d FC(and)j Fy(scsh)f FC(str)o(uctur)o(es)g(in)i(their)f(own) +681 1780 y(packages)20 b(should)h(make)g(sur)o(e)f(to)h(always)f(put)h +(the)g Fy(scsh)e FC(r)o(efer)o(ence)f(\002rst.)731 2192 +y(Do)j(this:)1184 b(Not)21 b(this:)814 2279 y Fy(\(define-structu)o(re) +37 b(web-server)901 2344 y(\(open)k(scsh)1162 2413 y(scheme)1162 +2464 y(net-hax)1162 2524 y(.)1162 2557 y(.)1162 2590 +y(.\))901 2655 y(\(file)g(web\)\))2283 2279 y(\(define-structur)o(e)d +(web-server)2370 2344 y(\(open)k(scheme)2632 2413 y(scsh)2632 +2464 y(net-hax)2632 2524 y(.)2632 2557 y(.)2632 2590 +y(.)o(\))2370 2655 y(\(file)g(web\)\))731 2755 y FC(Open)21 +b Fy(scsh)e FC(befor)o(e)g Fy(scheme)p FC(.)515 b(Not)21 +b Fy(scsh)e FC(after)h Fy(scheme)p FC(.)681 3088 y(Or)o(dering)j(the)h +(two)h(packages)d(like)j(this)f(is)g(necessary)g(because)f(scsh)h +(overrides)f(some)681 3187 y(of)c(the)g(standar)o(d)f(R4RS)h(Scheme)g +(de\002nitions)h(exported)f(by)g(the)g Fy(scheme)e FC(package)h(with) +681 3287 y(its)30 b(own)h(de\002nitions.)53 b(For)30 +b(example,)h(scsh's)g(versions)f(of)g(the)g(R4RS)g(I/O)g(functions)681 +3387 y(such)25 b(as)f Fy(display)d FC(and)j Fy(write)e +FC(take)i(integer)g(\002le)h(descriptors)f(as)g(ar)o(guments,)h(as)f +(well)681 3486 y(as)i(Scheme)h(ports.)44 b(If)26 b(you)h(open)h(the)f +Fy(scheme)d FC(str)o(uctur)o(e)i(befor)o(e)g(the)h Fy(scsh)e +FC(str)o(uctur)o(e,)681 3586 y(you'll)c(get)g(the)g(standar)o(d)e +(Scheme)i(48)e(de\002nitions,)j(which)g(is)f(not)g(what)g(you)h(want.) +681 4057 y FA(9.1.4)81 b(Switches)681 4353 y FC(The)21 +b(scsh)g(top-level)f(takes)h(command-line)g(switches)g(in)h(the)f +(following)h(format:)888 4626 y Fy(scsh)42 b([)p FB(meta-ar)o(g)n +Fy(])h([)p FB(switch)1797 4638 y Fo(i)1868 4626 y Fy(...])f([)p +FB(end-option)g(ar)o(g)2642 4653 y Fv(1)2723 4626 y Fy(...)g +FB(ar)o(g)3007 4653 y Fo(n)3052 4626 y Fy(])681 4898 +y FC(wher)o(e)2051 5147 y(130)p eop +%%Page: 131 137 +131 136 bop 623 692 a FB(meta-ar)o(g:)159 b Fy(\\)20 +b FB(script-\002le-name)623 892 y(switch:)240 b Fy(-e)20 +b FB(entry-point)404 b FC(Specify)20 b(top-level)h(entry-point.)1103 +991 y Fy(-o)f FB(structur)o(e)479 b FC(Open)21 b(str)o(uctur)o(e)f(in)i +(curr)o(ent)e(package.)1103 1091 y Fy(-m)g FB(structur)o(e)479 +b FC(Switch)21 b(to)g(package.)1103 1191 y Fy(-n)f FB(new-package)361 +b FC(Switch)21 b(to)g(new)g(package.)1103 1390 y Fy(-lm)e +FB(module-\002le-name)165 b FC(Load)20 b(module)h(into)h(con\002g)g +(package.)1103 1489 y Fy(-l)e FB(\002le-name)481 b FC(Load)20 +b(\002le)h(into)h(curr)o(ent)e(package.)1103 1589 y Fy(-dm)764 +b FC(Do)22 b(script)e(module.)1103 1689 y Fy(-ds)764 +b FC(Do)22 b(script.)623 1888 y FB(end-option:)98 b Fy(-s)20 +b FB(script)1103 1988 y Fy(-sfd)f FB(num)1103 2087 y +Fy(-c)h FB(exp)1103 2187 y Fy(--)365 2354 y FC(These)29 +b(command-line)h(switches)f(essentially)h(pr)o(ovide)e(a)g(little)i +(linker)f(language)g(for)365 2453 y(linking)35 b(a)d(shell)i(script)f +(or)g(a)g(pr)o(ogram)f(together)h(with)h(Scheme)f(48)f(modules.)63 +b(The)365 2553 y(command-line)23 b(pr)o(ocessor)g(serially)f(opens)h +(str)o(uctur)o(es)g(and)f(loads)g(code)h(into)g(a)f(given)365 +2653 y(package.)30 b(Switches)23 b(that)f(side-ef)o(fect)f(a)h(package) +f(operate)h(on)h(a)f(particular)f(\223curr)o(ent\224)365 +2752 y(package;)29 b(ther)o(e)d(ar)o(e)g(switches)i(to)f(change)g(this) +h(package.)43 b(\(These)27 b(switches)g(pr)o(ovide)365 +2852 y(functionality)38 b(equivalent)e(to)h(the)g(interactive)f +Fy(,open)e(,load)g(,in)i FC(and)g Fy(,new)e FC(com-)365 +2951 y(mands.\))57 b(Except)30 b(wher)o(e)h(indicated,)i(switches)f +(specify)f(actions)h(that)f(ar)o(e)f(executed)365 3051 +y(in)25 b(a)f(left-to-right)h(or)o(der)-6 b(.)36 b(The)24 +b(initial)h(curr)o(ent)f(package)f(is)i(the)g(user)g(package,)f(which) +365 3151 y(is)29 b(completely)g(empty)g(and)f(opens)h(\(imports)g(the)f +(bindings)i(of\))e(the)g(R4RS)h(and)f(scsh)365 3250 y(str)o(uctur)o +(es.)490 3393 y(If)i(the)g(Scheme)g(pr)o(ocess)g(is)g(started)g(up)g +(in)g(an)h(interactive)e(mode,)k(then)d(the)h(cur)o(-)365 +3493 y(r)o(ent)21 b(package)g(in)h(for)o(ce)f(at)g(the)h(end)f(of)h +(switch)g(scanning)h(is)f(the)g(one)g(inside)g(which)g(the)365 +3593 y(interactive)e(r)o(ead-eval-print)e(loop)k(is)f(started.)490 +3736 y(The)f(command-line)h(switch)g(pr)o(ocessor)f(works)h(in)g(two)g +(passes:)k(it)20 b(\002rst)h(parses)e(the)365 3836 y(switches,)26 +b(building)f(a)f(list)h(of)f(actions)h(to)g(perform,)f(then)h(the)g +(actions)g(ar)o(e)e(performed)365 3935 y(serially)-9 +b(.)48 b(The)29 b(switch)g(list)g(is)g(terminated)f(by)g(one)h(of)g +(the)f FB(end-option)f FC(switches.)50 b(The)365 4035 +y FB(ar)o(g)474 4062 y Fo(i)520 4035 y FC(ar)o(guments)17 +b(occurring)h(after)f(an)h(end-option)g(switch)h(ar)o(e)d(passed)h(to)h +(the)g(scsh)g(pr)o(o-)365 4134 y(gram)j(as)g(the)g(value)g(of)g +Fy(command-line-arg)o(um)o(ent)o(s)15 b FC(and)20 b(the)i(tail)f(of)g +(the)g(list)h(r)o(eturned)365 4234 y(by)i Fy(\(command-line\))p +FC(.)j(That)c(is,)g(an)g FB(end-option)f FC(switch)i(separates)e +(switches)i(that)f(con-)365 4334 y(tr)o(ol)30 b(the)h(scsh)g +(\223machine\224)f(fr)o(om)f(the)i(actual)e(ar)o(guments)h(being)h +(passed)f(to)g(the)h(scsh)365 4433 y(pr)o(ogram)20 b(that)h(r)o(uns)h +(on)f(that)g(machine.)490 4577 y(The)g(following)h(switches)f(and)g +(end)f(options)i(ar)o(e)e(de\002ned:)490 4799 y Fu(\017)41 +b Fy(-o)i FB(struct)573 4898 y FC(Open)21 b(the)g(str)o(uctur)o(e)f(in) +h(the)g(curr)o(ent)f(package.)1735 5147 y(131)p eop +%%Page: 132 138 +132 137 bop 805 614 a Fu(\017)41 b Fy(-n)i FB(package)888 +714 y FC(Make)20 b(and)h(enter)g(a)g(new)g(package.)26 +b(The)21 b(package)f(has)h(an)g(associated)g(str)o(uctur)o(e)888 +814 y(named)f FB(package)f FC(with)j(an)e(empty)g(export)g(list.)26 +b(If)20 b FB(package)f FC(is)i(the)f(string)i(\223)p +Fy(#f)p FC(\224,)c(the)888 913 y(new)j(package)f(is)h(anonmyous,)h +(with)g(no)f(associated)f(named)h(str)o(uctur)o(e.)888 +1044 y(The)k(new)h(package)e(initially)i(opens)f(no)h(other)f(str)o +(uctur)o(es,)h(not)g(even)f(the)g(R4RS)888 1143 y(bindings.)h(Y)-8 +b(ou)18 b(must)g(follow)g(a)f(\223)p Fy(-n)42 b(foo)p +FC(\224)15 b(switch)j(with)g(\223)p Fy(-o)43 b(scheme)p +FC(\224)14 b(to)k(access)888 1243 y(the)j(standar)o(d)e(identi\002ers)i +(such)g(as)g Fy(car)e FC(and)i Fy(define)p FC(.)805 1404 +y Fu(\017)41 b Fy(-m)i FB(struct)888 1503 y FC(Change)27 +b(the)g(curr)o(ent)f(package)f(to)i(the)g(package)f(underlying)h(str)o +(uctur)o(e)f FB(struct)p FC(.)888 1603 y(\(The)21 b Fy(-m)f +FC(stands)g(for)h(\223module.\224\))805 1764 y Fu(\017)41 +b Fy(-lm)i FB(module-\002le-name)888 1864 y FC(Load)21 +b(the)g(speci\002ed)g(\002le)h(into)g(scsh's)g(con\002g)g(package)e +(\227)i(the)f(\002le)h(must)f(contain)888 1963 y(sour)o(ce)d(written)g +(in)h(the)f(Scheme)g(48)f(module)i(language)e(\(\223load)g +(module\224\).)24 b(Does)888 2063 y(not)e(alter)e(the)h(curr)o(ent)f +(package.)805 2224 y Fu(\017)41 b Fy(-l)i FB(\002le-name)888 +2323 y FC(Load)20 b(the)h(speci\002ed)g(\002le)g(into)g(the)g(curr)o +(ent)f(package.)805 2484 y Fu(\017)41 b Fy(-c)i FB(exp)888 +2584 y FC(Evaluate)28 b(expr)o(ession)h FB(exp)f FC(in)i(the)f(curr)o +(ent)g(package)f(and)g(exit.)51 b(This)29 b(is)h(called)888 +2684 y Fy(-c)c FC(after)f(a)g(common)j(shell)f(convention)g(\(see)f(sh) +g(and)g(csh\).)42 b(The)26 b(expr)o(ession)g(is)888 2783 +y(evaluated)f(in)i(the)f(the)h(curr)o(ent)f(package)f(\(and)g(hence)i +(is)f(af)o(fected)e(by)j Fy(-m)p FC('s)e(and)888 2883 +y Fy(-n)p FC('s.\))888 3013 y(When)d(the)f(scsh)g(top-level)g(constr)o +(ucts)h(the)f(scsh)h(command-line)f(in)h(this)g(case,)e(it)888 +3113 y(takes)j Fy("scsh")e FC(to)j(be)f(the)g(pr)o(ogram)g(name.)32 +b(This)24 b(switch)g(terminates)g(ar)o(gument)888 3212 +y(scanning;)e(following)g(ar)o(gs)e(become)h(the)f(tail)h(of)g(the)g +(command-line)g(list.)805 3373 y Fu(\017)41 b Fy(-e)i +FB(entry-point)888 3473 y FC(Specify)28 b(an)g(entry)g(point)h(for)f(a) +g(pr)o(ogram.)47 b(The)28 b FB(entry-point)f FC(is)h(a)g(variable)f +(that)888 3573 y(is)i(taken)g(fr)o(om)f(the)h(curr)o(ent)f(package)f +(in)i(for)o(ce)f(at)g(the)h(end)f(of)h(switch)g(evalua-)888 +3672 y(tion.)44 b(The)26 b(entry)g(point)i(does)e(not)h(have)f(to)h(be) +f(exported)f(by)i(the)f(package)g(in)h(a)888 3772 y(str)o(uctur)o(e;)19 +b(it)f(can)g(be)g(internal)g(to)g(the)g(package.)24 b(The)18 +b(top)g(level)g(passes)g(contr)o(ol)h(to)888 3871 y(the)k(entry)g +(point)h(by)f(applying)g(it)g(to)g(the)g(command-line)g(list)h(\(so)e +(pr)o(ograms)h(ex-)888 3971 y(ecuting)d(in)g(private)e(packages)g(can)h +(r)o(efer)o(ence)e(their)i(command-line)g(ar)o(guments)888 +4071 y(without)26 b(opening)f(the)f Fy(scsh)f FC(package)g(to)i(access) +e(the)i Fy(\(command-line\))18 b FC(pr)o(oce-)888 4170 +y(dur)o(e\).)24 b(Note)19 b(that,)g(like)h(the)f(list)h(r)o(eturned)d +(by)j(the)f Fy(\(command-line\))13 b FC(pr)o(ocedur)o(e,)888 +4270 y(the)21 b(list)f(passed)g(to)g(the)h(entry)f(point)h(includes)f +(the)h(name)f(of)g(the)g(pr)o(ogram)g(being)888 4370 +y(executed)28 b(\(as)g(the)h(\002rst)h(element)f(of)g(the)g(list\),)i +(not)e(just)h(the)f(ar)o(guments)g(to)g(the)888 4469 +y(pr)o(ogram.)888 4599 y(A)21 b Fy(-e)g FC(switch)h(can)f(occur)g +(anywher)o(e)g(in)g(the)h(switch)g(list,)g(but)f(it)h(is)f(the)h +FB(last)f FC(action)888 4699 y(performed)k(by)h(switch)g(scanning)g(if) +g(it)g(occurs.)40 b(\(W)-8 b(e)25 b(violate)g(or)o(dering)h(her)o(e)e +(as)888 4799 y(the)31 b(shell-script)f Fy(#!)g FC(mechanism)h(pr)o +(events)e(you)i(fr)o(om)f(putting)h(the)f FB(-e)g FC(switch)888 +4898 y(last,)21 b(wher)o(e)f(it)h(belongs.\))2051 5147 +y(132)p eop +%%Page: 133 139 +133 138 bop 490 614 a Fu(\017)41 b Fy(-s)i FB(script)573 +714 y FC(Specify)28 b(a)h(\002le)h(to)g(load.)51 b(A)29 +b Fy(-ds)f FC(\(do-script\))h(or)g Fy(-dm)g FC(\(do-module\))f(switch)j +(oc-)573 814 y(curring)26 b(earlier)e(in)j(the)e(switch)i(list)f(gives) +g(the)g(place)f(wher)o(e)g(the)h(script)g(should)573 +913 y(be)h(loaded.)46 b(If)27 b(ther)o(e)g(is)i(no)f +Fy(-ds)e FC(or)i Fy(-dm)f FC(switch,)j(then)e(the)g(script)g(is)g +(loaded)f(at)573 1013 y(the)d(end)f(of)h(switch)g(scanning,)h(into)f +(the)g(module)g(that)g(is)g(curr)o(ent)e(at)h(the)h(end)g(of)573 +1112 y(switch)d(scanning.)573 1243 y(W)-8 b(e)16 b(use)h(the)f +Fy(-ds)g FC(switch)h(to)g(violate)f(left-to-right)g(switch)h(execution) +g(or)o(der)e(as)h(the)573 1343 y Fy(-s)g FC(switch)j(is)e +FB(r)o(equir)o(ed)h FC(to)g(be)f(last)g(\(because)g(of)g(the)g +Fy(#!)g FC(machinery\),)h(independent)573 1443 y(of)j(when/wher)o(e)g +(in)g(the)g(switch-pr)o(ocessing)g(or)o(der)f(it)h(should)g(be)g +(loaded.)573 1574 y(When)29 b(the)f(scsh)h(top-level)f(constr)o(ucts)h +(the)f(scsh)h(command-line)g(in)f(this)h(case,)573 1673 +y(it)j(takes)g FB(script)f FC(to)i(be)e(the)h(pr)o(ogram)g(name.)59 +b(This)32 b(switch)h(terminates)f(switch)573 1773 y(parsing;)19 +b(following)h(ar)o(gs)e(ar)o(e)f(ignor)o(ed)i(by)f(the)h +(switch-scanner)g(and)f(ar)o(e)f(passed)573 1872 y(thr)o(ough)k(to)g +(the)g(pr)o(ogram)f(as)h(the)g(tail)f(of)h(the)g(command-line)g(list.) +490 2035 y Fu(\017)41 b Fy(-sfd)h FB(num)573 2134 y FC(Loads)36 +b(the)g(script)h(fr)o(om)f(\002le)g(descriptor)g FB(num)p +FC(.)72 b(This)37 b(switch)g(is)g(like)g(the)f Fy(-s)573 +2234 y FC(switch,)24 b(except)f(that)g(the)g(script)h(is)f(loaded)g(fr) +o(om)g(one)g(of)h(the)f(pr)o(ocess')g(open)g(in-)573 +2333 y(put)18 b(\002le)f(descriptors.)25 b(For)18 b(example,)f(to)h +(have)f(the)h(script)g(loaded)f(fr)o(om)g(standar)o(d)573 +2433 y(input,)k(specify)f Fy(-sfd)42 b(0)p FC(.)490 2595 +y Fu(\017)f Fy(--)573 2695 y FC(T)-8 b(erminate)39 b(ar)o(gument)f +(scanning)i(and)e(start)h(up)g(scsh)g(in)g(interactive)g(mode.)573 +2794 y(If)c(the)h(ar)o(gument)g(list)g(just)h(r)o(uns)g(out,)i(without) +f(either)d(a)h(terminating)g Fy(-s)f FC(or)573 2894 y +Fy(--)j FC(ar)o(g,)43 b(then)d(scsh)f(also)h(starts)f(up)g(in)h +(interactive)e(mode,)44 b(with)c(an)f(empty)573 2994 +y Fy(command-line-arg)o(um)o(ent)o(s)28 b FC(list)35 +b(\(for)f(example,)j(simply)e(entering)f Fy(scsh)f FC(at)h(a)573 +3093 y(shell)21 b(pr)o(ompt)g(with)g(no)h(ar)o(gs)e(at)g(all\).)573 +3224 y(When)29 b(the)f(scsh)h(top-level)f(constr)o(ucts)h(the)f(scsh)h +(command-line)g(in)f(this)h(case,)573 3324 y(it)e(takes)f +Fy("scsh")e FC(to)j(be)f(the)g(pr)o(ogram)g(name.)43 +b(This)27 b(switch)g(terminates)g(switch)573 3423 y(parsing;)19 +b(following)h(ar)o(gs)e(ar)o(e)f(ignor)o(ed)i(by)f(the)h +(switch-scanner)g(and)f(ar)o(e)f(passed)573 3523 y(thr)o(ough)k(to)g +(the)g(pr)o(ogram)f(as)h(the)g(tail)f(of)h(the)g(command-line)g(list.) +490 3685 y Fu(\017)41 b Fy(-ds)573 3785 y FC(Specify)27 +b(when)i(to)g(load)f(the)h(script)f(\(\223do-script\224\).)47 +b(If)28 b(this)h(switch)g(occurs,)h(the)573 3884 y(switch)23 +b(list)f FB(must)g FC(be)g(terminated)f(by)h(a)g Fy(-s)42 +b FB(script)22 b FC(switch.)30 b(The)22 b(script)g(is)g(loaded)573 +3984 y(into)f(the)g(package)f(that)h(is)g(curr)o(ent)f(at)g(the)h +Fy(-ds)f FC(switch.)490 4146 y Fu(\017)41 b Fy(-dm)573 +4246 y FC(As)18 b(above,)g(but)h(the)f(curr)o(ent)g(module)h(is)f +(ignor)o(ed.)25 b(The)18 b(script)h(is)f(loaded)g(into)h(the)573 +4345 y Fy(config)14 b FC(package)h(\(\223do-module\224\),)g(and)h +(hence)h(must)g(be)f(written)h(in)f(the)h(Scheme)573 +4445 y(48)31 b(module)h(language.)59 b(This)33 b(switch)g(doesn't)g(af) +o(fect)d(the)i(curr)o(ent)f(module\227)573 4545 y(after)26 +b(executing)h(this)h(switch,)i(the)d(curr)o(ent)g(module)h(is)f(the)h +(same)f(as)g(as)g(it)h(was)573 4644 y(befor)o(e.)573 +4775 y(This)16 b(switch)h(is)g(pr)o(ovided)e(to)h(make)g(it)g(easy)g +(to)g(write)g(shell)h(scripts)f(in)h(the)f(Scheme)573 +4875 y(48)k(module)h(language.)1735 5147 y(133)p eop +%%Page: 134 140 +134 139 bop 681 614 a FA(9.1.5)81 b(The)20 b(meta)f(argument)681 +809 y FC(The)32 b(scsh)i(switch)f(parser)f(takes)g(a)g(special)g +(command-line)h(switch,)j(a)d(single)g(back-)681 908 +y(slash)20 b(called)e(the)i(\223meta-ar)o(gument,\224)d(which)k(is)f +(useful)f(for)g(shell)h(scripts.)26 b(If)19 b(the)h(initial)681 +1008 y(command-line)j(ar)o(gument)g(is)h(a)f(\223)p Fy(\\)p +FC(\224)e(ar)o(gument,)j(followed)f(by)g(a)g(\002lename)h(ar)o(gument) +681 1108 y FB(fname)p FC(,)e(scsh)h(will)h(open)e(the)h(\002le)g +FB(fname)f FC(and)g(r)o(ead)f(mor)o(e)h(ar)o(guments)g(fr)o(om)g(the)h +(second)681 1207 y(line)29 b(of)g(this)h(\002le.)51 b(This)29 +b(list)h(of)f(ar)o(guments)g(will)h(then)f(r)o(eplace)f(the)h(\223)p +Fy(\\)p FC(\224)f(ar)o(gument\227)681 1307 y FB(i.e.)p +FC(,)21 b(the)g(new)h(ar)o(guments)f(ar)o(e)f(inserted)h(in)h(fr)o(ont) +f(of)g FB(fname)p FC(,)g(and)g(the)g(ar)o(gument)g(parser)681 +1407 y(r)o(esumes)27 b(ar)o(gument)g(scanning.)48 b(This)28 +b(is)g(used)g(to)g(over)o(come)f(a)g(limitation)i(of)f(the)g +Fy(#!)681 1506 y FC(featur)o(e:)23 b(the)c Fy(#!)g FC(line)h(can)f +(only)i(specify)e(a)g(single)h(ar)o(gument)f(after)f(the)i(interpr)o +(eter)-6 b(.)24 b(For)681 1606 y(example,)i(we)h(might)g(hope)g(the)f +(following)i(scsh)f(script,)g Fy(ekko)p FC(,)f(would)h(implement)g(a) +681 1705 y(simple-minded)21 b(version)g(of)g(the)g(Unix)f +Fy(echo)f FC(pr)o(ogram:)888 1911 y Fy(#!/usr/local/bin/)o(sc)o(sh)37 +b(-e)43 b(main)f(-s)888 2011 y(!#)888 2110 y(\(define)f(\(main)h +(args\))976 2210 y(\(map)f(\()p Fz(\025)e Fy(\(arg\))j(\(display)e +(arg\))i(\(display)e(")j("\)\))1193 2310 y(\(cdr)f(args\)\))976 +2409 y(\(newline\)\))681 2615 y FC(The)21 b(idea)e(would)j(be)e(that)h +(the)g(command)888 2767 y Fy(ekko)42 b(Hi)h(there.)681 +2919 y FC(would)21 b(by)g(expanded)e(by)i(the)g Fy(exec\(2\))d +FC(kernel)i(call)h(into)888 3125 y Fy(/usr/local/bin/sc)o(sh)37 +b(-e)43 b(main)f(-s)h(ekko)e(Hi)i(there.)681 3331 y FC(In)17 +b(theory)-9 b(,)18 b(this)f(would)h(cause)e(scsh)i(to)f(start)f(up,)i +(load)e(in)i(\002le)f Fy(ekko)p FC(,)f(call)g(the)h(entry)g(point)681 +3430 y(on)k(the)g(command-line)g(list)888 3583 y Fy(\(main)42 +b('\("ekko")e("Hi")i("there."\)\))681 3735 y FC(and)20 +b(exit.)805 3868 y(Unfortunately)-9 b(,)34 b(the)e(Unix)g +Fy(exec\(2\))d FC(syscall's)j(support)g(for)g(scripts)g(is)g(not)g +(very)681 3968 y(general)c(or)g(well-designed.)49 b(It)29 +b(will)g(not)g(handle)f(multiple)h(ar)o(guments;)j(the)d +Fy(#!)f FC(line)681 4068 y(is)g(usually)g(r)o(equir)o(ed)e(to)i +(contain)g(no)g(mor)o(e)g(than)f(32)g(characters;)i(it)f(is)g(not)g(r)o +(ecursive.)681 4167 y(If)c(these)g(r)o(estrictions)h(ar)o(e)e +(violated,)h(most)i(Unix)e(systems)h(will)g(not)g(pr)o(ovide)f +(accurate)681 4267 y(err)o(or)19 b(r)o(eporting,)i(but)f(either)h(fail) +f(silently)-9 b(,)21 b(or)g(simply)g(incorr)o(ectly)g(implement)g(the)g +(de-)681 4366 y(sir)o(ed)f(functionality)-9 b(.)26 b(These)20 +b(ar)o(e)g(the)h(facts)f(of)g(Unix)h(life.)805 4500 y(In)k(the)g +Fy(ekko)f FC(example)g(above,)h(our)g Fy(#!)f FC(trigger)h(line)g(has)g +(thr)o(ee)f(ar)o(guments)g(\(\223)p Fy(-e)p FC(\224,)681 +4599 y(\223)p Fy(main)p FC(\224,)j(and)g(\223)p Fy(-s)p +FC(\224\),)h(so)g(it)h(will)g(not)f(work.)48 b(The)28 +b(meta-ar)o(gument)f(is)i(how)f(we)h(work)681 4699 y(ar)o(ound)18 +b(this)h(pr)o(oblem.)25 b(W)-8 b(e)19 b(must)g(instead)f(invoke)i(the)f +(scsh)g(interpr)o(eter)e(with)j(the)f(sin-)681 4799 y(gle)j +Fy(\\)g FC(ar)o(gument,)g(and)g(put)g(the)g(r)o(est)g(of)g(the)h(ar)o +(guments)f(on)h(line)f(two)h(of)g(the)f(pr)o(ogram.)681 +4898 y(Her)o(e's)e(the)h(corr)o(ect)e(pr)o(ogram:)2051 +5147 y(134)p eop +%%Page: 135 141 +135 140 bop 573 614 a Fy(#!/usr/local/bin)o(/s)o(csh)37 +b(\\)573 714 y(-e)43 b(main)f(-s)573 814 y(!#)573 913 +y(\(define)f(\(main)g(args\))660 1013 y(\(map)h(\()p +Fz(\025)d Fy(\(arg\))i(\(display)g(arg\))g(\(display)g(")i("\)\))878 +1112 y(\(cdr)f(args\)\))660 1212 y(\(newline\)\))365 +1429 y FC(Now)-8 b(,)22 b(the)f(invocation)g(starts)g(as)573 +1591 y Fy(ekko)42 b(Hi)h(there.)365 1754 y FC(and)21 +b(is)g(expanded)e(by)i(exec\(2\))e(into)573 1970 y Fy(/usr/local/bin/s) +o(cs)o(h)38 b(\\)43 b(ekko)f(Hi)g(there.)365 2187 y FC(When)17 +b(scsh)h(starts)e(up,)h(it)g(expands)f(the)h(\223)p Fy(\\)p +FC(\224)e(ar)o(gument)h(into)i(the)f(ar)o(guments)f(r)o(ead)f(fr)o(om) +365 2286 y(line)21 b(two)h(of)f Fy(ekko)p FC(,)d(pr)o(oducing)j(this)g +(ar)o(gument)g(list:)573 2503 y Fy(-e)43 b(main)f(-s)g(ekko)p +573 2516 654 4 v 42 w(Hi)h(there.)922 2603 y Fu(")573 +2702 y FC(Expanded)19 b(fr)o(om)43 b Fy(\\)g(ekko)365 +2919 y FC(W)-5 b(ith)22 b(this)g(ar)o(gument)e(list,)h(pr)o(ocessing)g +(pr)o(oceeds)e(as)i(we)g(intended.)365 3209 y FA(Secondary)f(argument)f +(syntax)365 3412 y FC(Scsh)h(uses)g(a)f(very)g(simple)h(grammar)f(to)h +(encode)g(the)f(extra)g(ar)o(guments)g(on)i(the)e(second)365 +3512 y(line)k(of)g(the)g(scsh)g(script.)31 b(The)22 b(only)i(special)e +(characters)f(ar)o(e)g(space,)h(tab,)g(newline,)i(and)365 +3611 y(backslash.)490 3828 y Fu(\017)41 b FC(Each)e(space)g(character)f +(terminates)h(an)h(ar)o(gument.)81 b(This)41 b(means)e(that)h(two)573 +3928 y(spaces)20 b(in)h(a)g(r)o(ow)f(intr)o(oduce)h(an)f(empty-string)h +(ar)o(gument.)490 4114 y Fu(\017)41 b FC(The)18 b(tab)g(character)f(is) +i(not)g(permitted)f(\(unless)g(you)h(quote)g(it)g(with)g(the)g +(backslash)573 4214 y(character)26 b(described)g(below\).)46 +b(This)28 b(is)g(to)g(pr)o(event)f(the)h(insidious)g(bug)g(wher)o(e)573 +4313 y(you)19 b(believe)g(you)h(have)e(six)h(space)g(characters,)e(but) +j(you)f(r)o(eally)f(have)h(a)f(tab)h(char)o(-)573 4413 +y(acter)-6 b(,)19 b(and)i FB(vice-versa)p FC(.)490 4599 +y Fu(\017)41 b FC(The)25 b(newline)g(character)f(terminates)g(an)h(ar)o +(gument,)g(like)g(the)g(space)f(character)-6 b(,)573 +4699 y(and)26 b(also)h(terminates)g(the)g(ar)o(gument)f(sequence.)44 +b(This)27 b(means)g(that)g(an)f(empty)573 4799 y(line)j(parses)e(to)i +(the)g(singleton)h(list)f(whose)g(one)g(element)f(is)h(the)g(empty)f +(string:)573 4898 y Fy(\(""\))p FC(.)c(The)c(grammar)h(doesn't)g(admit) +f(the)h(empty)g(list.)1735 5147 y(135)p eop +%%Page: 136 142 +136 141 bop 805 614 a Fu(\017)41 b FC(The)35 b(backslash)g(character)e +(is)i(the)g(escape)f(character)-6 b(.)66 b(It)35 b(escapes)f +(backslash,)888 714 y(space,)d(tab,)h(and)d(newline,)j(turning)f(of)o +(f)e(their)h(special)f(functions,)k(and)c(allow-)888 +814 y(ing)k(them)f(to)g(be)f(included)h(in)g(ar)o(guments.)58 +b(The)33 b(A)t Ft(N)t(S)t(I)h FC(C)e(escape)f(sequences)888 +913 y(\()p Fy(\\b)p FC(,)36 b Fy(\\n)p FC(,)g Fy(\\r)d +FC(and)g Fy(\\t)p FC(\))g(ar)o(e)f(also)i(supported;)40 +b(these)34 b(also)g(pr)o(oduce)f(ar)o(gument-)888 1013 +y(constituents\227)p Fy(\\n)28 b FC(doesn't)f(act)g(like)g(a)f +(terminating)i(newline.)45 b(The)26 b(escape)g(se-)888 +1112 y(quence)31 b Fy(\\)p FB(nnn)g FC(for)f FB(exactly)g +FC(thr)o(ee)f(octal)i(digits)g(r)o(eads)e(as)h(the)h(character)e(whose) +890 1212 y(A)t Ft(S)t(C)t(I)t(I)21 b FC(code)d(is)h FB(nnn)p +FC(.)25 b(It)18 b(is)h(an)f(err)o(or)f(if)h(backslash)g(is)h(followed)f +(by)h(just)f(one)h(or)f(two)888 1312 y(octal)26 b(digits:)36 +b Fy(\\3Q)25 b FC(is)h(an)f(err)o(or)-6 b(.)40 b(Octal)26 +b(escapes)f(ar)o(e)f(always)i(constituent)h(chars.)888 +1411 y(Backslash)f(followed)g(by)f(other)h(chars)g(is)g(not)g(allowed)g +(\(so)g(we)f(can)h(extend)f(the)888 1511 y(escape-code)19 +b(space)h(later)g(if)h(we)g(like\).)805 1722 y(Y)-8 b(ou)21 +b(have)e(to)g(constr)o(uct)h(these)g(line-two)g(ar)o(gument)f(lines)h +(car)o(efully)-9 b(.)23 b(In)d(particular)-6 b(,)681 +1822 y(bewar)o(e)22 b(of)h(trailing)h(spaces)e(at)h(the)h(end)f(of)g +(the)h(line\227they'll)g(give)g(you)f(extra)g(trailing)681 +1921 y(empty-string)e(ar)o(guments.)k(Her)o(e's)20 b(an)h(example:)888 +2079 y Fy(#!/bin/interprete)o(r)37 b(\\)888 2178 y(foo)43 +b(bar)86 b(quux\\)41 b(yow)681 2336 y FC(would)21 b(pr)o(oduce)f(the)h +(ar)o(guments)888 2493 y Fy(\("foo")41 b("bar")h("")h("quux)e(yow"\)) +681 2775 y FA(9.1.6)81 b(Examples)805 2974 y Fu(\017)41 +b Fy(scsh)h(-dm)h(-m)f(myprog)f(-e)i(top)g(-s)f(myprog.scm)888 +3074 y FC(Load)19 b Fy(myprog.scm)c FC(into)20 b(the)f +Fy(config)e FC(package,)h(then)i(shift)f(to)h(the)f Fy(myprog)e +FC(pack-)888 3173 y(age)26 b(and)f(call)g Fy(\(top)42 +b('\("myprog.scm"\)\))p FC(,)20 b(then)27 b(exit.)40 +b(This)26 b(sort)g(of)g(invocation)888 3273 y(is)21 b(typically)g(used) +g(in)g Fy(#!)f FC(script)h(lines)g(\(see)f(below\).)805 +3455 y Fu(\017)41 b Fy(scsh)h(-c)h('\(display)d("Hello,)h(world."\)') +888 3555 y FC(A)21 b(simple)g(pr)o(ogram.)805 3737 y +Fu(\017)41 b Fy(scsh)h(-o)h(bigscheme)888 3837 y FC(Start)53 +b(up)g(interactively)f(in)i(the)f(user)g(package)f(after)g(opening)j +(str)o(uctur)o(e)888 3936 y Fy(bigscheme)p FC(.)805 4118 +y Fu(\017)41 b Fy(scsh)h(-o)h(bigscheme)d(--)j(Three)e(args)h(passed) +888 4218 y FC(Start)24 b(up)g(interactively)g(in)h(the)g(user)f +(package)f(after)g(opening)i Fy(bigscheme)p FC(.)33 b(The)888 +4318 y Fy(command-line-args)e FC(variable)36 b(in)i(the)g(scsh)g +(package)f(is)h(bound)g(to)g(the)f(list)888 4417 y Fy(\("Three")k +("args")g("passed"\))p FC(,)g(and)f(the)g Fy(\(command-line\))35 +b FC(pr)o(ocedur)o(e)j(r)o(e-)888 4517 y(turns)22 b(the)e(list)i +Fy(\("scsh")40 b("Three")h("args")g("passed"\))p FC(.)805 +4699 y Fu(\017)g FC(Pr)o(ogram)21 b Fy(ekko)888 4799 +y FC(This)g(shell)g(script,)f(called)f Fy(ekko)p FC(,)g(implements)i(a) +e(version)i(of)f(the)g(Unix)g Fy(echo)f FC(pr)o(o-)888 +4898 y(gram:)2051 5147 y(136)p eop +%%Page: 137 143 +137 142 bop 756 614 a Fy(#!/usr/local/bi)o(n/)o(scs)o(h)37 +b(-s)756 714 y(!#)756 814 y(\(for-each)i(\()p Fz(\025)g +Fy(\(arg\))j(\(display)e(arg\))i(\(display)e(")j("\)\))1191 +913 y(command-line-args)o(\))573 1207 y FC(Note)21 b(this)h(short)g(pr) +o(ogram)e(is)i(an)f(example)f(of)h(a)g FB(script)p FC(\227it)g +(executes)g(as)f(it)i(loads.)573 1307 y(The)f(Unix)f(r)o(ule)h(for)g +(executing)f Fy(#!)g FC(shell)i(scripts)f(causes)756 +1520 y Fy(ekko)41 b(Hello,)h(world.)573 1732 y FC(to)21 +b(expand)f(as)756 1945 y Fy(/usr/local/bin/)o(sc)o(sh)37 +b(-s)43 b(ekko)f(Hello,)f(world.)490 2223 y Fu(\017)g +FC(Pr)o(ogram)20 b Fy(ekko)573 2322 y FC(This)29 b(is)h(the)f(same)f +(pr)o(ogram,)i FB(not)f FC(as)f(a)h(script.)50 b(W)-6 +b(riting)29 b(it)g(this)h(way)f(makes)f(it)573 2422 y(possible)20 +b(to)h(compile)f(the)g(pr)o(ogram)g(\(and)f(then,)h(for)g(instance,)g +(dump)g(it)g(out)g(as)g(a)573 2522 y(heap)g(image\).)756 +2751 y Fy(#!/usr/local/bi)o(n/)o(scs)o(h)37 b(\\)756 +2850 y(-e)42 b(top)h(-s)756 2950 y(!#)756 3050 y(\(define)d(\(top)i +(args\))843 3149 y(\(for-each)e(\()p Fz(\025)e Fy(\(arg\))k(\(display)e +(arg\))i(\(display)e(")j("\)\))1279 3249 y(\(cdr)e(args\)\)\))573 +3478 y FC(The)28 b Fy(exec\(2\))c FC(expansion)k(of)g(the)g +Fy(#!)f FC(line)h(together)g(with)g(the)g(scsh)g(expansion)573 +3578 y(of)33 b(the)h(\223)p Fy(\\)43 b(ekko)p FC(\224)31 +b(meta-ar)o(gument)i(\(see)g(section)h(9.1.5\))d(gives)j(the)g +(following)573 3678 y(command-line)21 b(expansion:)756 +3907 y Fy(ekko)41 b(Hello,)h(world.)930 4006 y Fn(=)-14 +b Fu(\))87 b Fy(/usr/local/bin/s)o(cs)o(h)37 b(\\)44 +b(ekko)390 b(Hello,)41 b(world.)930 4106 y Fn(=)-14 b +Fu(\))87 b Fy(/usr/local/bin/s)o(cs)o(h)37 b(-e)43 b(top)g(-s)f(ekko)g +(Hello,)f(world.)490 4400 y Fu(\017)g FC(Pr)o(ogram)20 +b Fy(sort)573 4500 y FC(This)d(is)f(a)g(pr)o(ogram)f(to)i(r)o(eplace)e +(the)h(Unix)g Fy(sort)f FC(utility\227sorting)j(lines)e(r)o(ead)f(fr)o +(om)573 4599 y(stdin,)28 b(and)d(printing)i(the)g(r)o(esults)f(on)h +(stdout.)42 b(Note)26 b(that)g(the)h(sour)o(ce)f(code)f(de-)573 +4699 y(\002nes)g(a)f(general)g(sorting)h(package,)f(which)i(is)e +(useful)h(\(1\))e(as)h(a)g(Scheme)g(module)573 4799 y(exporting)f(sort) +g(pr)o(ocedur)o(es)e(to)i(other)h(Scheme)e(code,)h(and)f(\(2\))g(as)g +(a)h(standalone)573 4898 y(pr)o(ogram)d(invoked)h(fr)o(om)f(the)h +Fy(top)f FC(pr)o(ocedur)o(e.)1735 5147 y(137)p eop +%%Page: 138 144 +138 143 bop 1071 614 a Fy(#!/usr/local/bin)o(/sc)o(sh)37 +b(\\)1071 714 y(-dm)42 b(-m)h(sort-toplevel)38 b(-e)43 +b(top)f(-s)1071 814 y(!#)1071 1013 y(;;;)g(This)g(is)h(a)g(sorting)e +(module.)g(TOP)h(procedure)e(exports)1071 1112 y(;;;)i(the)h +(functionality)38 b(as)43 b(a)g(Unix)f(program)e(akin)i(to)h +(sort\(1\).)1071 1212 y(\(define-structur)o(es)37 b(\(\(sort-struct)h +(\(export)j(sort-list)2858 1312 y(sort-vector!\)\))1943 +1411 y(\(sort-toplevel)d(\(export)i(top\)\)\))1158 1511 +y(\(open)i(scheme\))1158 1710 y(\(begin)f(\(define)g(\(sort-list)e +(elts)j(<=\))h(...\))1463 1810 y(\(define)e(\(sort-vec!)e(vec)k(<=\))86 +b(...\))1463 2009 y(;;)43 b(Parse)f(the)g(command)f(line)h(and)1463 +2109 y(;;)h(sort)f(stdin)f(to)i(stdout.)1463 2208 y(\(define)e(\(top)h +(args\))1594 2308 y(...\)\)\))888 2491 y FC(The)18 b(expansion)h(below) +g(shows)g(how)g(the)f(command-line)h(scanner)f(\(1\))f(loads)h(the)888 +2583 y(con\002g)i(\002le)g Fy(sort)d FC(\(written)i(in)h(the)f(Scheme)g +(48)f(module)i(language\),)e(\(2\))g(switches)888 2674 +y(to)33 b(the)f(package)f(underlying)i(the)f Fy(sort-toplevel)27 +b FC(str)o(uctur)o(e,)34 b(\(3\))d(calls)h Fy(\(top)888 +2765 y('\("sort")41 b("foo")g("bar"\)\))18 b FC(in)j(the)g(package,)f +(and)g(\002nally)h(\(4\))f(exits.)888 2997 y Fh(sort)40 +b(foo)g(bar)888 3089 y Fc(=)-13 b Fb(\))79 b Fh(/usr/local/bin/scsh)43 +b(\\)d(sort)1177 b(foo)40 b(bar)888 3180 y Fc(=)-13 b +Fb(\))79 b Fh(/usr/local/bin/scsh)43 b(-dm)d(-m)g(sort-toplevel)i(-e)e +(top)f(-s)h(sort)g(foo)g(bar)888 3352 y FC(An)21 b(alternate)f(method)h +(would)g(have)g(used)f(a)1071 3513 y Fy(-n)43 b(#f)g(-o)f +(sort-toplevel)888 3674 y FC(sequence)21 b(of)g(switches)h(to)f +(specify)f(a)g(top-level)h(package.)805 3869 y(Note)d(that)g(the)g +(sort)g(example)g(can)f(be)h(compiled)g(into)g(a)g(Unix)g(pr)o(ogram)f +(by)h(loading)681 3969 y(the)25 b(\002le)g(into)h(an)f(scsh)g(pr)o +(ocess,)g(and)g(dumping)g(a)g(heap)f(with)i(top-level)f +Fy(top)p FC(.)37 b(Even)24 b(if)681 4068 y(we)18 b(don't)h(want)g(to)g +(export)f(the)h(sort's)g(functionality)h(as)e(a)g(subr)o(outine)h +(library)-9 b(,)18 b(it)g(is)h(still)681 4168 y(useful)f(to)h(write)f +(the)g(sort)h(pr)o(ogram)e(with)i(the)g(module)f(language.)25 +b(The)18 b(command)h(line)681 4267 y(design)k(allows)g(us)g(to)g(r)o +(un)g(this)g(pr)o(ogram)f(as)h(either)f(an)g(interpr)o(eted)g(script)g +(\(given)h(the)681 4367 y Fy(#!)d FC(ar)o(gs)g(in)h(the)g(header\))e +(or)i(as)f(a)h(compiled)g(heap)f(image.)681 4616 y FA(9.1.7)81 +b(Process)20 b(exit)f(values)681 4799 y FC(Scsh)i(ignor)o(es)h(the)g +(value)f(pr)o(oduced)f(by)i(its)g(top-level)g(computation)g(when)g +(determin-)681 4898 y(ing)g(its)g(exit)f(status)h(code.)27 +b(If)21 b(the)h(top-level)f(computation)h(completed)g(with)g(no)g(err)o +(ors,)2051 5147 y(138)p eop +%%Page: 139 145 +139 144 bop 365 614 a FC(scsh)21 b(dies)e(with)i(exit)f(code)f(0.)25 +b(For)20 b(example,)f(a)g(scsh)i(pr)o(ocess)e(whose)i(top-level)e(is)h +(spec-)365 714 y(i\002ed)h(by)f(a)g Fy(-c)43 b FB(exp)20 +b FC(or)g(a)g Fy(-e)43 b FB(entry)20 b FC(entry)h(point)g(ignor)o(es)g +(the)f(value)g(pr)o(oduced)f(by)i(eval-)365 814 y(uating)f +FB(exp)f FC(and)g(calling)g FB(entry)p FC(,)h(r)o(espectively)-9 +b(.)24 b(If)19 b(these)g(computations)i(terminate)e(with)365 +913 y(no)j(err)o(ors,)d(the)i(scsh)h(pr)o(ocess)e(exits)h(with)g(an)g +(exit)f(code)h(of)g(0.)490 1061 y(T)-8 b(o)21 b(r)o(eturn)f(a)g +(speci\002c)h(exit)g(status,)f(use)h(the)g Fy(exit)e +FC(pr)o(ocedur)o(e)g(explicitly)-9 b(,)20 b FB(e.g.)p +FC(,)573 1160 y Fy(scsh)42 b(-c)h(\\)660 1260 y("\(exit)e +(\(status:exit-val)c(\(run)42 b(\(|)h(\(fmt\))e(\(mail)h +(shivers\)\)\)\)\)")365 1596 y Fw(9.2)99 b(The)25 b(scsh)h(virtual)f +(machine)365 1840 y FC(T)-8 b(o)31 b(r)o(un)f(the)g(Scheme)f(48)g +(implementation)i(of)f(scsh,)j(you)d(r)o(un)g(a)g(specially)f +(modi\002ed)365 1940 y(copy)e(of)g(the)g(Scheme)f(48)g(virtual)g +(machine)h(with)h(a)e(scsh)h(heap)g(image.)43 b(The)27 +b(scsh)g(bi-)365 2039 y(nary)22 b(is)h(actually)f(nothing)i(but)e(a)g +(small)h(cover)f(pr)o(ogram)f(that)i(invokes)g(the)f(byte-code)365 +2139 y(interpr)o(eter)28 b(on)j(the)e(scsh)h(heap)f(image)h(for)f(you.) +52 b(This)30 b(allows)h(you)f(to)g(simply)g(start)365 +2238 y(up)23 b(an)g(interactive)g(scsh)h(fr)o(om)e(a)h(command)g(line,) +h(as)f(well)h(as)e(write)i(shell)f(scripts)h(that)365 +2338 y(begin)d(with)h(the)f(simple)g(trigger)573 2512 +y Fy(#!/usr/local/bin)o(/s)o(csh)37 b(-s)490 2734 y FC(Y)-8 +b(ou)26 b(can)f(also)h(dir)o(ectly)e(execute)h(the)g(virtual)g +(machine,)h(which)h(takes)e(its)g(own)i(set)365 2834 +y(of)21 b(command-line)h(switches..)27 b(For)21 b(example,)f(this)i +(command)f(starts)g(the)g(vm)h(up)f(with)365 2934 y(a)g(1Mwor)o(d)e +(heap)h(\(split)h(into)h(two)f(semispaces\):)573 3108 +y Fy(scshvm)41 b(-o)i(scshvm)e(-h)i(1000000)d(-i)j(scsh.image)c(arg1)j +(arg2)g(...)365 3282 y FC(The)34 b(vm)f(peels)g(of)o(f)g(initial)h(vm)f +(ar)o(guments)g(up)h(to)f(the)h Fy(-i)e FC(heap)h(image)g(ar)o(gument,) +365 3382 y(which)46 b(terminates)g(vm)f(ar)o(gument)g(parsing.)99 +b(The)45 b(r)o(est)f(of)i(the)f(ar)o(guments)g(ar)o(e)365 +3481 y(passed)d(of)o(f)g(to)h(the)f(scsh)h(top-level.)91 +b(Scsh's)43 b(top-level)f(r)o(emoves)g(scsh)h(switches,)365 +3581 y(as)k(discussed)h(in)f(the)h(pr)o(evious)f(section;)61 +b(the)47 b(r)o(est)g(show)h(up)f(as)g(the)h(value)f(of)365 +3681 y Fy(command-line-argu)o(me)o(nts)o FC(.)490 3828 +y(Dir)o(ectly)25 b(executing)g(the)g(vm)h(can)e(be)h(useful)g(to)h +(specify)f(non-standar)o(d)f(switches,)365 3928 y(or)g(invoke)g(the)g +(virtual)f(machine)g(on)h(special)f(heap)g(images,)h(which)h(can)e +(contain)h(pr)o(e-)365 4027 y(compiled)d(scsh)h(pr)o(ograms)e(with)h +(their)g(own)h(top-level)e(pr)o(ocedur)o(es.)365 4337 +y FA(9.2.1)81 b(VM)21 b(arguments)365 4550 y FC(The)g(vm)g(takes)f(ar)o +(guments)h(in)g(the)g(following)h(form:)573 4724 y Fy(scshvm)41 +b([)p FB(meta-ar)o(g)n Fy(])i([)p FB(vm-options)1729 +4694 y Fv(+)1784 4724 y Fy(])g([)p FB(end-option)f(scheme-ar)o(gs)o +Fy(])365 4898 y FC(wher)o(e)1735 5147 y(139)p eop +%%Page: 140 146 +140 145 bop 938 601 a FB(meta-ar)o(g:)159 b Fy(\\)43 +b FB(\002lename)938 800 y(vm-option)n FC(:)113 b Fy(-h)43 +b FB(heap-size-in-words)1418 900 y Fy(-s)g FB(stack-size-in-words)1418 +1000 y Fy(-o)g FB(object-\002le-name)938 1199 y(end-option:)98 +b Fy(-i)43 b FB(image-\002le-name)1418 1298 y Fy(--)805 +1471 y FC(The)36 b(vm's)g(meta-switch)f(\223)p Fy(\\)43 +b FB(\002lename)p FC(\224)35 b(is)h(handled)f(the)h(same)f(as)g(scsh's) +i(meta-)681 1571 y(switch,)21 b(and)f(serves)h(the)g(same)f(purpose.) +681 1832 y FA(VM)g(options)681 2020 y FC(The)f Fy(-o)42 +b FB(object-\002le-name)19 b FC(switch)h(tells)f(the)g(vm)g(wher)o(e)g +(to)g(\002nd)g(r)o(elocation)g(information)681 2120 y(for)27 +b(its)i(for)o(eign-function)f(calls.)47 b(Scsh)28 b(will)g(use)g(a)g +(pr)o(e-compiled)e(default)h(if)h(it)g(is)g(not)681 2220 +y(speci\002ed.)c(Scsh)19 b FB(must)g FC(have)f(this)i(information)g(to) +f(r)o(un,)h(since)f(scsh's)h(syscall)f(interfaces)681 +2319 y(ar)o(e)g(done)i(with)h(for)o(eign-function)e(calls.)805 +2448 y(The)i Fy(-h)g FC(and)f Fy(-s)h FC(options)h(tell)g(the)f(vm)g +(how)h(much)g(space)e(to)i(allocate)e(for)h(the)h(heap)681 +2547 y(and)i(stack.)39 b(The)25 b(heap)g(size)f(value)h(is)h(the)f +(total)h(number)f(of)g(wor)o(ds)g(allocated)g(for)g(the)681 +2647 y(heap;)30 b(this)f(space)e(is)h(then)g(split)g(into)g(two)h +(semi-spaces)e(for)g(Scheme)h(48's)f(stop-and-)681 2747 +y(copy)21 b(collector)-6 b(.)681 3008 y FA(End)20 b(options)681 +3196 y FC(End)31 b(options)h(terminate)f(ar)o(gument)g(parsing.)57 +b(The)31 b Fy(-i)f FC(switch)i(is)g(followed)g(by)f(the)681 +3295 y(name)23 b(of)h(a)f(heap)g(image)h(for)f(the)h(vm)g(to)g +(execute.)33 b(The)23 b FB(image-\002le-name)g FC(string)h(is)g(also) +681 3395 y(taken)d(to)i(be)e(the)h(name)g(of)g(the)g(pr)o(ogram)f +(being)h(executed)f(by)h(the)g(VM;)f(this)i(name)f(be-)681 +3495 y(comes)e(the)h(head)e(of)h(the)g(ar)o(gument)g(list)g(passed)g +(to)g(the)g(heap)g(image's)g(top-level)g(entry)681 3594 +y(point.)25 b(The)17 b(tail)g(of)g(the)g(ar)o(gument)g(list)g(is)h +(constr)o(ucted)f(fr)o(om)g(all)g(following)i(ar)o(guments.)805 +3723 y(The)k Fy(--)f FC(switch)h(terminates)g(ar)o(gument)f(parsing)h +(without)h(giving)g(a)e(speci\002c)h(heap)681 3822 y(image;)k(the)e(vm) +h(will)g(start)f(up)g(using)h(a)f(default)f(heap)h(\(whose)g(location)h +(is)g(compiled)681 3922 y(into)g(the)f(vm\).)38 b(All)25 +b(the)h(following)g(ar)o(guments)f(comprise)g(the)h(tail)f(of)g(the)g +(list)h(passed)681 4022 y(of)o(f)20 b(to)h(the)g(heap)f(image's)h +(top-level)f(pr)o(ocedur)o(e.)805 4150 y(Notice)g(that)g(you)g(ar)o(e)f +(not)h(allowed)g(to)g(pass)f(ar)o(guments)h(to)g(the)g(heap)f(image's)h +(top-)681 4250 y(level)g(pr)o(ocedur)o(e)f(\()p FB(e.g.)o +FC(,)i(scsh\))g(without)h(delimiting)f(them)g(with)h +Fy(-i)e FC(or)h Fy(--)f FC(\003ags.)681 4511 y FA(9.2.2)81 +b(Inserting)19 b(interpreter)g(triggers)h(into)g(heap)g(images)681 +4699 y FC(Scheme)i(48's)g(heap)g(image)h(format)f(allows)h(for)g(an)f +(informational)h(header:)29 b(when)23 b(the)681 4799 +y(vm)18 b(loads)g(in)h(a)f(heap)g(image,)g(it)g(ignor)o(es)h(all)f +(data)f(occurring)h(befor)o(e)f(the)i(\002rst)f(contr)o(ol-L)681 +4898 y(character)23 b(\()r(A)t Ft(S)t(C)t(I)t(I)k FC(12\).)35 +b(This)26 b(means)e(that)h(you)g(can)f(insert)h(a)f(\223)p +Fy(#!)p FC(\224)f(trigger)h(line)h(into)h(a)2051 5147 +y(140)p eop +%%Page: 141 147 +141 146 bop 365 614 a FC(heap)16 b(image,)h(making)g(it)f(a)g(form)g +(of)g(executable)f(\223shell)h(script.\224)24 b(Since)16 +b(the)g(vm)h(r)o(equir)o(es)365 714 y(multiple)23 b(ar)o(guments)e(to)h +(be)g(given)g(on)g(the)g(command)g(line,)h(you)f(must)g(use)g(the)g +(meta-)365 814 y(switch.)27 b(Her)o(e's)20 b(an)g(example)g(heap-image) +g(header:)573 1009 y Fy(#!/usr/local/lib)o(/s)o(csh)o(/s)o(csh)o(vm)37 +b(\\)573 1109 y(-o)43 b(/usr/local/lib/)o(scs)o(h/)o(scs)o(hv)o(m)37 +b(-i)573 1209 y(...)42 b FB(Y)-9 b(our)21 b(heap)f(image)g(goes)h(her)o +(e)44 b Fy(...)365 1535 y FA(9.2.3)81 b(Inserting)20 +b(a)g(double-level)e(trigger)i(into)g(Scheme)f(programs)365 +1722 y FC(If)j(you'r)o(e)f(a)g(ner)o(d,)g(you)h(may)g(enjoy)h(doing)f +(a)f(double-level)h(machine)g(shift)g(in)g(the)g(trig-)365 +1822 y(ger)f(line)g(of)g(your)g(Scheme)f(pr)o(ograms)g(with)i(the)f +(following)h(magic:)573 2009 y Fh(#!/usr/local/lib/scsh/scshvm)45 +b(\\)573 2101 y(-o)40 b(/usr/local/lib/scsh/scshvm)45 +b(-i)39 b(/usr/local/lib/scsh/scsh.ima)q(ge)45 b(-s)573 +2192 y(!#)573 2283 y(...)40 b Fi(Y)-8 b(our)18 b(Scheme)h(pr)o(ogram)h +(goes)f(her)o(e)39 b Fh(...)365 2636 y Fw(9.3)99 b(Compiling)26 +b(scsh)f(programs)365 2854 y FC(Scsh)30 b(allows)h(you)f(to)g(cr)o +(eate)e(a)i(heap)f(image)h(with)g(your)h(own)f(top-level)g(pr)o(ocedur) +o(e.)365 2954 y(Adding)21 b(the)g(pair)f(of)g(lines)573 +3150 y Fy(#!/usr/local/lib)o(/s)o(csh)o(/s)o(csh)o(vm)37 +b(\\)573 3249 y(-o)43 b(/usr/local/lib/)o(scs)o(h/)o(scs)o(hv)o(m)37 +b(-i)365 3445 y FC(to)21 b(the)g(top)g(of)g(the)g(heap)f(image)h(will)g +(turn)g(it)g(into)h(an)f(executable)e(Unix)i(\002le.)490 +3572 y(Y)-8 b(ou)22 b(can)e(cr)o(eate)f(heap)h(images)h(with)h(the)f +(following)h(two)f(pr)o(ocedur)o(es.)365 3724 y Fy(\(dump-scsh-progra)o +(m)37 b FB(main)21 b(fname)p Fy(\))87 b Fu(\000)-15 b(!)88 +b FB(unde\002ned)585 b FC(pr)o(ocedur)o(e)573 3867 y(This)28 +b(pr)o(ocedur)o(e)e(writes)i(out)g(a)f(scsh)i(heap)e(image.)46 +b(When)28 b(the)g(heap)g(image)f(is)573 3967 y(executed)f(by)i(the)g +(Scheme)f(48)g(vm,)i(it)f(will)g(call)g(the)g FB(main)f +FC(pr)o(ocedur)o(e,)g(passing)573 4066 y(it)d(the)h(vm's)g(ar)o(gument) +f(list.)37 b(When)24 b Fy(main)f FC(r)o(eturns)h(an)g(integer)g(value)g +Fz(i)p FC(,)h(the)f(vm)573 4166 y(exits)16 b(with)i(exit)e(status)g +Fz(i)p FC(.)24 b(The)16 b(Scheme)g(vm)h(will)g(parse)f(command-line)h +(switches)573 4265 y(as)30 b(described)f(in)i(section)g(9.2.1;)i(r)o +(emaining)e(ar)o(guments)f(form)g(the)h(tail)f(of)g(the)573 +4365 y(command-line)19 b(list)g(that)g(is)f(passed)g(to)h +Fy(main)p FC(.)k(\(The)c(head)f(of)g(the)h(list)g(is)g(the)g(name)573 +4465 y(of)h(the)g(pr)o(ogram)f(being)h(executed)f(by)h(the)g(vm.\))25 +b(Further)20 b(ar)o(gument)f(parsing)h(\(as)573 4564 +y(described)g(for)g(scsh)h(in)h(section)f(9.1.4\))e(is)i(not)g +(performed.)573 4699 y(The)33 b(heap)g(image)h(cr)o(eated)d(by)i +Fy(dump-scsh-program)27 b FC(has)33 b(unused)h(code)f(and)573 +4799 y(data)26 b(pr)o(uned)g(out,)j(so)e(small)h(pr)o(ograms)e(compile) +h(to)h(much)f(smaller)g(heap)f(im-)573 4898 y(ages.)1735 +5147 y(141)p eop +%%Page: 142 148 +142 147 bop 681 614 a Fy(\(dump-scsh)39 b FB(fname)p +Fy(\))87 b Fu(\000)-14 b(!)87 b FB(unde\002ned)1125 b +FC(pr)o(ocedur)o(e)888 754 y(This)20 b(pr)o(ocedur)o(e)e(writes)i(out)g +(a)f(heap)g(image)g(with)i(the)f(standar)o(d)d(scsh)k(top-level.)888 +853 y(When)32 b(the)f(image)g(is)g(r)o(esumed)f(by)h(the)g(vm,)j(it)d +(will)h(parse)e(and)g(execute)g(scsh)888 953 y(command-line)22 +b(switches)f(as)g(described)e(in)i(section)h(9.1.4.)888 +1085 y(Y)-8 b(ou)31 b(can)f(use)g(this)g(pr)o(ocedur)o(e)e(to)i(write)g +(out)g(custom)h(scsh)f(heap)f(images)h(that)888 1184 +y(have)21 b(speci\002c)f(packages)g(pr)o(eloaded)f(and)h(start)h(up)f +(in)i(speci\002c)e(packages.)805 1350 y(Unfortunately)-9 +b(,)18 b(Scheme)f(48)f(does)h(not)h(support)g(separate)e(compilation)i +(of)f(Scheme)681 1449 y(\002les)25 b(or)f(Scheme)g(modules.)37 +b(The)25 b(only)g(way)f(to)h(compile)g(is)g(to)g(load)f(sour)o(ce)g +(and)g(then)681 1549 y(dump)30 b(out)h(a)f(heap)g(image.)54 +b(One)31 b(occasionally)g(hears)f(r)o(umours)h(that)g(this)g(is)g +(being)681 1648 y(addr)o(essed)18 b(by)j(the)g(Scheme)g(48)e +(development)i(team.)681 1925 y Fw(9.4)99 b(Statically)26 +b(linking)f(heap)g(images)681 2139 y FC(The)32 b(static)g(heap)g +(linker)h(converts)f(a)g(Scheme)g(48)f(bytecode)h(image)g(contained)h +(in)g(a)681 2239 y(.image)25 b(\002le)h(to)h(a)e(C)h(r)o(epr)o +(esentation.)40 b(This)26 b(C)g(code)g(is)g(then)h(compiled)f(and)f +(linked)i(in)681 2338 y(with)j(a)f(virtual)g(machine,)i(pr)o(oducing)f +(a)e(single)j(executable.)50 b(Some)29 b(of)g(the)h(bene\002ts)681 +2438 y(ar)o(e:)805 2625 y Fu(\017)41 b FC(Instantaneous)22 +b(start-up)e(time.)805 2789 y Fu(\017)41 b FC(Impr)o(oved)16 +b(paging;)h(scsh)g(images)f(can)g(be)f(shar)o(ed)g(between)h(dif)o(fer) +o(ent)e(pr)o(ocesses.)805 2953 y Fu(\017)41 b FC(V)-8 +b(astly)21 b(r)o(educed)d(GC)j(copying\227the)g(whole)g(initial)g +(image)f(is)h(moved)f(out)h(of)f(the)888 3053 y(heap,)g(and)h(neither)g +(traced)e(nor)i(copied.)805 3217 y Fu(\017)41 b FC(Result)22 +b(pr)o(ogram)e(no)h(longer)h(depends)e(on)h(the)g(\002lesystem)h(for)e +(its)h(initial)h(image.)805 3404 y(The)f(static)g(heap)f(linker)h +(takes)f(ar)o(guments)h(in)g(the)g(following)h(form:)888 +3543 y Fy(scsh-hlink)40 b FB(image)j(executable)h Fy([)p +FB(option)e Fy(...])681 3682 y FC(It)20 b(r)o(eads)f(in)h(the)h(heap)e +(image)h FB(image)p FC(,)g(translates)f(it)i(into)g(C)f(code,)f +(compiles)i(the)g(C)f(code,)681 3781 y(and)c(links)i(it)f(against)f +(the)h(scsh)g(vm,)h(pr)o(oducing)e(the)h(standalone)g(binary)f(\002le)h +FB(executable)p FC(.)805 3897 y(Each)27 b(C)g(\002le)g(r)o(epr)o +(esents)e(part)i(of)g(the)g(heap)f(image)h(as)g(a)f(constant)i(C)f +Fy(long)e FC(vector)681 3989 y(that)20 b(looks)i(something)h(like)e +(this:)681 4168 y Fh(const)79 b(long)41 b(p116[]={0x882,0x24,0x19,)1465 +4259 y(0x882,\(long\)\(&p19[785]\)+7,\(l)q(ong\))q(\(&p1)q(19[12)q +(5]\)+)q(7,)1465 4350 y(0x882,\(long\)\(&p119[128]\)+7,\()q(long)q +(\)\(&p)q(119[1)q(31]\))q(+7,)1465 4442 y +(0x882,\(long\)\(&p102[348]\)+7,\()q(long)q(\)\(&p)q(3[114)q(]\)+7)q(,) +1465 4533 y(0xfc2,0x2030200,0x7100209,0x)q(1091)q(002,)q(0x1c0)q(75a,) +1465 4624 y(0x882,\(long\)\(&p29[1562]\)+7,\()q(long)q(\)\(&p)q(119[1)q +(37]\))q(+7,)1465 4716 y(0x882,\(long\)\(&p78[692]\)+7,\(l)q(ong\))q +(\(&p1)q(19[14)q(0]\)+)q(7,)1622 4807 y(.)1622 4898 y(.)2051 +5147 y FC(142)p eop +%%Page: 143 149 +143 148 bop 1307 614 a Fh(.)1150 706 y(};)490 893 y FC(T)-7 +b(ranslating)21 b(to)g(a)g(C)g(declaration)f(gives)h(us)g(fr)o(eedom)f +(fr)o(om)h(the)g(various)g(object-\002le)365 993 y(formats.)669 +963 y Fv(2)735 993 y FC(Note)h(that)g(the)f(const)i(declaration)e +(allows)h(the)g(compiler)g(to)g(put)g(this)h(array)365 +1092 y(in)e(the)f(text)f(pages)h(of)g(the)g(executable.)k(The)19 +b(heap)h(is)g(split)g(into)h(parts)f(because)f(many)h(C)365 +1192 y(compilers)i(cannot)f(handle)f(multi-megabyte)h(initialised)g +(vector)g(declarations.)490 1316 y(The)g(allowed)f(options)i(to)f(the)g +(heap)g(linker)g(ar)o(e:)490 1504 y Fu(\017)41 b Fy(--temp)g +FB(dir)573 1603 y FC(The)27 b(temporary)f(dir)o(ectory)g(to)i(hold)f +(.c)g(and)f(.o)h(\002les.)44 b(The)27 b(default)f(is)h(typically)573 +1703 y(con\002gur)o(ed)h(to)h(be)f Fy(/usr/tmp)p FC(,)f(and)h(can)g(be) +g(overridden)g(by)g(the)h(envir)o(onment)573 1803 y(variable)19 +b Fy(TMPDIR)p FC(.)f(Example:)756 1941 y Fy(--temp)41 +b(/tmp)490 2112 y Fu(\017)g Fy(--cc)h FB(command)573 +2212 y FC(The)25 b(command)g(to)h(r)o(un)g(the)f(C)g(compiler)-6 +b(.)38 b(The)25 b(default)g(can)f(be)h(overridden)f(by)573 +2311 y(the)d(envir)o(onment)g(variable)f Fy(CC)p FC(.)f(Example:)756 +2450 y Fy(--cc)41 b("gcc)h(-g)h(-O")490 2621 y Fu(\017)e +Fy(--ld)h FB(command)573 2720 y FC(The)33 b(ar)o(guments)g(to)g(r)o(un) +h(the)g(C)f(compiler)g(as)g(a)g(linker)-6 b(.)63 b(The)33 +b(default)f(can)h(be)573 2820 y(overridden)20 b(by)h(the)g(envir)o +(onment)g(variable)e Fy(LDFLAGS)p FC(.)f(Example:)756 +2959 y Fy(--ld)41 b("-Wl,-E")490 3129 y Fu(\017)g Fy(--libs)g +FB(libs)573 3229 y FC(The)25 b(libraries)f(needed)g(to)h(link)h(the)e +(VM)h(and)f(heap.)37 b(The)25 b(default)f(can)g(be)h(over)o(-)573 +3329 y(ridden)20 b(by)h(the)g(envir)o(onment)g(variable)f +Fy(LIBS)p FC(.)e(Example:)756 3467 y Fy(--libs)41 b("-ldld)g(-lld)h +(-lm")490 3655 y FC(Be)20 b(warned)g(that)h(the)g(curr)o(ent)f(heap)g +(linker)h(has)g(many)g(shortcomings.)490 3842 y Fu(\017)41 +b FC(It)30 b(is)g(extr)o(emely)e(slow)-8 b(.)54 b(Really)-9 +b(,)32 b(r)o(eally)c(slow)-8 b(.)54 b(T)-7 b(ranslating)29 +b(the)h(standar)o(d)e(scsh)573 3941 y(heap)42 b(image)h(into)g(a)f +(standalone)h(binary)f(takes)h(well)g(over)f(an)h(hour)g(on)g(a)573 +4041 y(40Mb/133Mhz)26 b(Pentium)31 b(system.)54 b(A)30 +b(memory-starved)f(486)f(could)i(take)g(all)573 4141 +y(night.)490 4305 y Fu(\017)41 b FC(It)c(cannot)g(be)f(applied)g(to)i +(itself.)73 b(The)37 b(curr)o(ent)f(implementation)i(works)f(by)573 +4405 y(r)o(eplacing)i(some)i(of)f(the)g(heap-dumping)g(code.)83 +b(This)40 b(means)h(you)f(cannot)573 4504 y(load)j(the)g(heap-linker)g +(code)g(into)h(a)f(scsh)g(system)h(and)f(subsequently)i(use)573 +4604 y Fy(dump-scsh-progra)o(m)15 b FC(to)21 b(cr)o(eate)e(a)h +(heap-linker)g(heap)h(image.)490 4768 y Fu(\017)41 b +FC(The)21 b(interface)e(leaves)h(a)h(lot)g(to)g(be)f(desir)o(ed.)p +365 4821 1146 4 v 450 4875 a Fq(2)485 4898 y Ft(This)c(idea)h(is)g(due) +f(to)h(Jonathan)f(Rees.)1735 5147 y FC(143)p eop +%%Page: 144 150 +144 149 bop 988 614 a FA(\226)41 b FC(It)19 b(r)o(equir)o(es)f(the)h +(heap)g(image)g(to)g(be)g(r)o(efer)o(enced)d(by)j(a)f(\002le-name;)i +(the)f(linker)1071 714 y(will)i(not)h(allow)f(you)g(to)h(feed)d(it)i +(the)g(input)g(heap)g(image)f(on)i(a)e(port.)988 848 +y FA(\226)41 b FC(The)21 b(heap-image)f(is)h(linked)g(against)f(the)h +(vm)g(contained)g(in)1226 948 y Fy(/usr/local/lib/sc)o(sh)o(/li)o(bs)o +(cs)o(hvm)o(.a)1071 1048 y FC(This)g(is)g(wir)o(ed)f(in)i(at)e(the)h +(time)g(scsh)g(is)g(installed)g(on)h(your)f(system.)988 +1182 y FA(\226)41 b FC(Ther)o(e)20 b(is)h(no)g(Scheme)g(pr)o(ocedural)e +(interface.)805 1351 y Fu(\017)41 b FC(The)28 b(pr)o(ogram)f(pr)o +(oduced)f(uses)h(the)h(default)e(VM)h(ar)o(gv)g(parser)f +Fy(process_args)888 1451 y FC(fr)o(om)36 b(the)g(scsh)h(sour)o(ce)f +(\002le)g Fy(main.c)e FC(to)i(pr)o(ocess)g(the)g(command)h(line)f +(befor)o(e)888 1550 y(handing)25 b(it)g(of)o(f)e(to)i(the)f(heap)g +(image's)g(top-level)g(pr)o(ocedur)o(e.)34 b(This)25 +b(is)g(not)g(what)888 1650 y(you)d(want)f(for)f(many)h(pr)o(ograms.)888 +1784 y(The)28 b(system)g(needs)f(to)g(be)g(changed)g(to)h(allow)g +(users)f(to)h(override)e(this)i(default)888 1884 y(with)22 +b(their)f(own)g(VM)g(ar)o(gument)f(parsers.)805 2053 +y Fu(\017)41 b FC(A)28 b(possible)i(pr)o(oblem)e(is)h(the)f(Unix)h +(limits)h(on)f(the)f(number)h(of)g(command)g(line)888 +2152 y(ar)o(guments.)58 b(The)32 b(heap-linker)f(calls)g(the)h(C)f +(linker)h(with)h(a)e(lar)o(ge)f(number)i(of)888 2252 +y(object)19 b(\002les.)25 b(Its)19 b(conceivable)f(that)g(on)h(some)g +(Unix)f(systems)i(this)f(could)f(fail)g(now)888 2352 +y(or)32 b(if)g(scsh)h(gr)o(ows)f(in)g(the)g(futur)o(e.)58 +b(The)32 b(solution)h(could)f(be)g(to)g(cr)o(eate)f(library)888 +2451 y(ar)o(chives)26 b(of)h(a)f(few)g(dozen)h(\002les)g(and)f(then)h +(link)h(the)f(r)o(esult)f(few)g(dozen)h(library)888 2551 +y(ar)o(chives)20 b(to)h(make)g(the)g(executable.)805 +2746 y(In)f(spite)g(of)g(these)g(many)g(shortcomings,)i(we)e(ar)o(e)e +(pr)o(oviding)i(the)g(static)f(linker)h(as)g(it)681 2845 +y(stands)h(in)g(this)g(r)o(elease)f(so)h(that)g(people)f(may)h(get)g +(some)g(experience)f(with)h(it.)805 2972 y(Her)o(e)f(is)h(an)g(example) +f(of)g(how)i(one)f(might)h(use)f(the)g(heap)f(linker:)1237 +3167 y Fy(scsh-hlink)39 b(scsh.image)h(fastscsh)805 3389 +y FC(W)-8 b(e'd)21 b(love)g(it)g(if)f(someone)i(would)g(dive)e(into)h +(the)g(sour)o(ce)g(and)f(impr)o(ove)g(it.)681 3672 y +Fw(9.5)99 b(Standard)24 b(\002le)h(locations)681 3889 +y FC(Because)20 b(the)h(scshvm)h(binary)f(is)h(intended)f(to)g(be)g +(used)g(for)g(writing)h(shell)g(scripts,)f(it)h(is)681 +3989 y(important)i(that)f(the)h(binary)f(be)g(installed)h(in)g(a)f +(standar)o(d)e(place,)i(so)h(that)g(shell)g(scripts)681 +4088 y(can)g(dependably)f(r)o(efer)g(to)i(it.)37 b(The)25 +b(standar)o(d)e(dir)o(ectory)g(for)i(the)f(scsh)i(tr)o(ee)d(should)i +(be)681 4188 y Fy(/usr/local/lib/s)o(cs)o(h/)p FC(.)19 +b(Whenever)h(possible,)i(the)e(vm)h(should)h(be)e(located)h(in)888 +4330 y Fy(/usr/local/lib/sc)o(sh)o(/sc)o(sh)o(vm)681 +4472 y FC(and)f(a)g(scsh)i(heap)e(image)h(should)g(be)g(located)f(in) +888 4614 y Fy(/usr/local/lib/sc)o(sh)o(/sc)o(sh)o(.im)o(ag)o(e)681 +4756 y FC(The)h(top-level)f(scsh)h(pr)o(ogram)f(should)i(be)e(located)h +(in)888 4898 y Fy(/usr/local/lib/sc)o(sh)o(/sc)o(sh)2051 +5147 y FC(144)p eop +%%Page: 145 151 +145 150 bop 365 614 a FC(with)22 b(a)e(symbolic)i(link)f(to)h(it)f(fr)o +(om)573 753 y Fy(/usr/local/bin/s)o(cs)o(h)490 916 y +FC(The)30 b(Scheme)g(48)f(image)h(format)f(allows)i(heap)e(images)i(to) +f(have)g Fy(#!)f FC(triggers,)j(so)365 1016 y Fy(scsh.image)17 +b FC(should)k(have)g(a)f Fy(#!)g FC(trigger)h(of)f(the)h(following)h +(form:)573 1207 y Fy(#!/usr/local/lib)o(/s)o(csh)o(/s)o(csh)o(vm)37 +b(\\)573 1307 y(-o)43 b(/usr/local/lib/)o(scs)o(h/)o(scs)o(hv)o(m)37 +b(-i)573 1406 y(...)42 b FB(heap)20 b(image)g(goes)h(her)o(e)43 +b Fy(...)1735 5147 y FC(145)p eop +%%Page: 146 152 +146 151 bop 681 1263 a Fx(Chapter)44 b(10)681 1704 y +FD(Changes)52 b(from)g(the)g(previous)681 1953 y(release)681 +2411 y FC(This)30 b(section)h(details)f(changes)g(that)g(have)g(been)f +(made)h(in)g(scsh)h(since)f(the)g(pr)o(evious)681 2511 +y(r)o(elease.)805 2636 y(Scsh)f(is)g(now)h(much)f(mor)o(e)g(r)o(obust.) +49 b(All)29 b(known)h(bugs)f(have)f(been)h(\002xed.)49 +b(Ther)o(e)681 2736 y(have)34 b(been)g(many)g(impr)o(ovements)h(and)f +(extensions)h(made.)65 b(W)-8 b(e)34 b(have)g(also)h(made)681 +2835 y(made)20 b(some)h(incompatible)g(changes.)805 2961 +y(The)32 b(sections)i(below)e(brie\003y)h(describe)e(these)h(new)h +(featur)o(es)d(and)i(changes;)38 b(the)681 3061 y(r)o(elevant)19 +b(sections)j(of)f(the)g(manual)f(give)h(the)g(full)g(details.)681 +3341 y Fw(10.1)99 b(New)24 b(features)681 3556 y FC(This)d(r)o(elease)e +(incorporates)i(several)f(new)h(featur)o(es)e(into)j(scsh.)805 +3766 y Fu(\017)41 b FC(Contr)o(ol)21 b(of)g(buf)o(fer)o(ed)d(I/O)888 +3866 y(Scsh)25 b(now)g(allows)h(you)f(to)g(contr)o(ol)g(the)g(buf)o +(fering)e(policy)i(used)g(for)f(doing)h(I/O)888 3966 +y(on)d(a)e(Scheme)g(port.)805 4133 y Fu(\017)41 b FC(Her)o(e-strings) +888 4233 y(Scsh)26 b(now)h(has)f(a)f(new)i(lexical)e(featur)o(e,)g +Fy(#<<)p FC(,)h(that)g(pr)o(ovides)f(the)h(ability)g(to)g(en-)888 +4332 y(ter)k(long,)j(multi-line)d(string)h(constants)f(in)h(scsh)f(pr)o +(ograms.)52 b(Such)30 b(a)f(string)i(is)888 4432 y(called)21 +b(a)h(\223her)o(e)e(string,\224)i(by)g(analogy)g(to)h(the)f(common)h +(shell)g(\223her)o(e)d(document\224)888 4532 y Fy(<<)g +FC(r)o(edir)o(ection.)805 4699 y Fu(\017)41 b FC(Delimited)21 +b(r)o(eaders)e(and)i(r)o(ead-line)888 4799 y(Scsh)32 +b(now)g(has)f(a)g(powerful)g(set)g(of)h(delimited)f(r)o(eaders.)55 +b(These)31 b(can)g(be)g(used)888 4898 y(to)23 b(r)o(ead)f(input)h +(delimited)f(by)h(a)f(newline)i(character)d(\()p Fy(read-line)p +FC(\),)e(a)j(blank)h(line)2051 5147 y(146)p eop +%%Page: 147 153 +147 152 bop 573 614 a FC(\()p Fy(read-paragraph)p FC(\))o(,)19 +b(or)25 b(the)f(occurr)o(ence)f(of)i(any)f(character)f(in)h(an)h +(arbitrary)e(set)573 714 y(\()p Fy(read-delimited)p FC(\))o(.)573 +855 y(While)k(these)f(pr)o(ocedur)o(es)f(can)h(be)g(applied)g(to)h(any) +f(Scheme)h(input)g(port,)g(ther)o(e)573 955 y(is)37 b(native-code)e +(support)i(for)f(performing)h(delimited)f(r)o(eads)f(on)i(Unix)f(input) +573 1055 y(sour)o(ces,)i(so)d(doing)h(block)f(input)g(with)h(these)f +(pr)o(ocedur)o(es)e(should)i(be)g(much)573 1154 y(faster)20 +b(than)h(the)f(equivalent)h(character)o(-at-a-time)c(Scheme)k(code.)490 +1337 y Fu(\017)41 b FC(New)21 b(system)g(calls)573 1437 +y(W)-5 b(ith)32 b(the)g(sole)g(exception)f(of)g(signal)h(handlers,)i +(scsh)e(now)g(has)g(all)f(of)i(P)t Ft(O)t(S)t(I)t(X)r +FC(.)573 1536 y(This)21 b(r)o(elease)e(intr)o(oduces)672 +1719 y FA(\226)42 b Fy(select)p FC(,)672 1860 y FA(\226)g +FC(full)20 b(terminal)h(device)f(contr)o(ol,)672 2002 +y FA(\226)42 b FC(support)20 b(for)h(pseudo-terminal)f(\223pty\224)g +(devices,)672 2143 y FA(\226)42 b FC(\002le)20 b(locking,)672 +2284 y FA(\226)42 b FC(pr)o(ocess)20 b(timing,)672 2426 +y FA(\226)42 b Fy(set-file-times)p FC(,)672 2567 y FA(\226)g +Fy(seek)19 b FC(and)h Fy(tell)p FC(.)573 2750 y(Note)d(that)g(having)g +Fy(select)p FC(,)e(pseudo-terminals,)i(and)f(tty)h(device)f(contr)o(ol) +h(means)573 2849 y(that)23 b(it)h(is)g(now)g(possible)h(to)e(implement) +i(inter)o(esting)e(network)i(pr)o(otocols,)f(such)573 +2949 y(as)c(telnet)h(servers)f(and)h(clients,)g(dir)o(ectly)f(in)h +(Scheme.)490 3132 y Fu(\017)41 b FC(New)21 b(command-line)g(switches) +573 3232 y(Ther)o(e)32 b(is)h(a)g(new)g(set)g(of)g(command-line)h +(switches)g(that)e(make)h(it)h(possible)f(to)573 3331 +y(write)26 b(shell)h(scripts)f(using)i(the)e(Scheme)g(48)f(module)i +(system.)43 b(Scripts)26 b(can)g(use)573 3431 y(the)j(new)h +(command-line)g(switches)g(to)g(open)f(dependent)g(modules)h(and)f +(load)573 3530 y(dependent)16 b(sour)o(ce)g(code.)23 +b(Scripts)16 b(can)g(also)h(be)f(written)h(in)g(the)f(Scheme)g(48)g +(mod-)573 3630 y(ule)i(language,)h(which)g(allows)h(you)f(to)g(use)g +(it)f(both)i(as)e(a)g(standalone)h(shell)g(script,)573 +3730 y(and)i(as)f(a)h(code)g(module)g(that)g(can)g(be)g(loaded)f(and)h +(used)g(by)g(other)h(Scheme)e(pr)o(o-)573 3829 y(grams.)490 +4012 y Fu(\017)41 b FC(Static)20 b(heap)g(linking)573 +4112 y(Ther)o(e)d(is)h(a)f(new)h(facility)g(that)g(allows)g(you)g(to)g +(compile)h(a)e(heap)g(image)h(to)g(a)f Fy(.o)g FC(\002le)573 +4211 y(that)26 b(can)g(be)f(linked)i(with)g(the)f(scsh)h(virtual)e +(machine.)42 b(This)27 b(pr)o(oduces)e(a)h(stan-)573 +4311 y(dalone)33 b(executable)g(binary)-9 b(,)36 b(makes)e(startup)g +(time)g(near)o(-instantaneous,)i(and)573 4411 y(gr)o(eatly)19 +b(impr)o(oves)g(memory)i(performance\227the)e(initial)h(heap)f(image)h +(is)g(placed)573 4510 y(in)k(the)g(pr)o(ocess')f(text)h(pages,)f(wher)o +(e)g(it)h(is)g(shar)o(ed)f(by)g(dif)o(fer)o(ent)f(scsh)i(pr)o(ocesses,) +573 4610 y(and)c(does)h(not)g(occupy)g(space)f(in)i(the)e(r)o(un-time)i +(heap.)756 4805 y Fl(Oops:)79 b Fk(The)26 b(static)g(heap)g(linker)f +(was)h(not)h(documented)e(and)h(installed)g(in)756 4897 +y(time)18 b(for)g(this)h(r)o(elease.)1735 5147 y FC(147)p +eop +%%Page: 148 154 +148 153 bop 681 614 a Fw(10.2)99 b(Incompatible)24 b(improvements)681 +828 y FC(Some)30 b(featur)o(es)e(of)j(scsh)f(have)g(been)g(impr)o(oved) +f(in)i(ways)f(that)g(ar)o(e)f(not)i(backwar)o(ds-)681 +928 y(compatible)19 b(with)h(pr)o(evious)f(r)o(eleases.)24 +b(These)19 b(changes)h(should)g(not)g(af)o(fect)d(most)k(code;)681 +1028 y(however)-6 b(,)20 b(please)g(note)i(the)e(changes)h(and)g +(modify)g(your)g(code)f(accor)o(dingly)-9 b(.)805 1213 +y Fu(\017)41 b FC(New)21 b(pr)o(ocess-object)f(data-type)g(r)o(eturned) +f(by)i Fy(fork)888 1312 y FC(Pr)o(evious)h(r)o(eleases)e(wer)o(e)g(pr)o +(one)h(to)h(\002ll)g(up)f(the)h(kernel's)f(pr)o(ocess)g(table)g(if)g(a) +g(pr)o(o-)888 1412 y(gram)26 b(forked)f(lar)o(ge)f(numbers)i(of)g(pr)o +(ocesses)f(and)g(subsequently)i(failed)e(to)h(use)888 +1512 y Fy(wait)16 b FC(to)h(r)o(eclaim)g(the)g(entries)g(in)h(the)f +(kernel's)g(pr)o(ocess)g(table.)24 b(\(This)17 b(is)h(a)e(pr)o(oblem) +888 1611 y(in)22 b(standar)o(d)d(C)h(envir)o(onments,)i(as)e(well.\)) +888 1740 y(Scsh)27 b(0.4)f(intr)o(oduces)h(a)g(new)g(mechanism)h(for)f +(automatically)g(managing)g(sub-)888 1839 y(pr)o(ocesses.)36 +b(Pr)o(ocesses)24 b(ar)o(e)e(no)j(longer)g(r)o(epr)o(esented)d(by)i(an) +g(integer)h(pr)o(ocess)e(id,)888 1939 y(which)31 b(is)f(impossible)g +(to)g(garbage-collect,)g(but)g(by)f(an)h(abstract)e(pr)o(ocess)h(data) +888 2039 y(type)d(that)g(encapsulates)g(the)g(pr)o(ocess)g(id.)41 +b(All)26 b(pr)o(ocesses)g(ar)o(e)e(r)o(epr)o(esented)g(us-)888 +2138 y(ing)31 b(the)f(new)g(data)e(str)o(uctur)o(es;)34 +b(see)29 b(the)h(r)o(elevant)f(section)h(of)g(the)g(manual)f(for)888 +2238 y(further)21 b(details.)805 2395 y Fu(\017)41 b +FC(Better)20 b(stdio/curr)o(ent-port)h(synchr)o(onisation)888 +2495 y(The)i Fy(\(begin)41 b(...\))20 b FC(pr)o(ocess)i(form)g(now)h +(does)g(a)e Fy(stdio->stdports)16 b FC(call)22 b(befor)o(e)888 +2594 y(executing)i(its)g(body)-9 b(.)35 b(This)24 b(means)g(that)g(the) +g(Scheme)f(code)h(in)g(the)g(body)g(\223sees\224)888 +2694 y(any)i(external)e(r)o(edir)o(ections.)38 b(For)25 +b(example,)h(it)f(means)g(that)g(if)g(a)g Fy(begin)e +FC(form)j(in)888 2793 y(the)h(middle)g(of)f(a)g(pipeline)h(performs)f +(I/O)h(on)h(the)f(curr)o(ent)e(input)i(and)g(output)888 +2893 y(ports,)18 b(it)f(will)g(be)f(communicating)i(with)f(its)g(upstr) +o(eam)f(and)g(downstr)o(eam)g(pipes.)888 2993 y FB(E.g.)o +FC(,)j(this)h(code)f(works)g(as)g(intended)g(without)h(the)f(need)g +(for)g(explicit)f(synchr)o(oni-)888 3092 y(sation:)888 +3269 y Fy(\(run)42 b(\(|)h(\(gunzip\))1237 3369 y(;;)g(Kill)f(line)g(1) +h(and)f(insert)f(doubled-sided)1237 3468 y(;;)i(code)f(at)g(head)g(of)h +(Postscript.)1237 3568 y(\(begin)e(\(read-line\))e(;)k(Eat)g(first)e +(line.)1542 3668 y(\(display)f("\045!PS-Adobe-2.0\\\\)o(n"\))1542 +3767 y(\(display)g("statusdict)f(/setduplexmode)f(known)k("\))1542 +3867 y(\(display)e("{statusdict)f(begin)j(true)f("\))1542 +3967 y(\(display)f("setduplexmode)e(end})k(if\\n"\))1542 +4066 y(\(exec-epf)e(\(cat\)\)\))1237 4166 y(\(lpr\)\))1106 +4265 y(\(<)j(paper.ps\)\))888 4442 y FC(Arranging)35 +b(for)f(the)g Fy(begin)f FC(pr)o(ocess)h(form)g(to)h(synchr)o(onise)g +(the)g(curr)o(ent)e(I/O)888 4542 y(ports)d(with)g(stdio)g(means)f(that) +h(all)f(pr)o(ocess)g(forms)g(now)h(see)g(their)f(epf)5 +b('s)28 b(r)o(edi-)888 4642 y(r)o(ections.)805 4799 y +Fu(\017)41 b Fy(file-match)17 b FC(mor)o(e)j(r)o(obust)888 +4898 y(The)h Fy(file-match)16 b FC(pr)o(ocedur)o(e)i(now)k(catches)e +(any)g(err)o(or)g(condition)h(signalled)g(by)2051 5147 +y(148)p eop +%%Page: 149 155 +149 154 bop 573 614 a FC(a)22 b(match)g(pr)o(ocedur)o(e,)e(and)i(tr)o +(eats)f(it)h(as)g(if)g(the)h(pr)o(ocedur)o(e)d(had)i(simply)h(r)o +(eturned)573 714 y Fy(#f)p FC(,)h FB(i.e.)p FC(,)g(match)g(failur)o(e.) +35 b(This)24 b(means)g Fy(file-match)c FC(no)25 b(longer)g(gets)f +(blown)h(out)573 814 y(of)18 b(the)h(water)e(by)i(trying)g(to)f(apply)g +(a)g(function)h(like)g Fy(file-directory?)12 b FC(to)19 +b(a)e(dan-)573 913 y(gling)22 b(symlink,)g(and)e(other)h(r)o(elated)e +(OS)i(err)o(ors.)490 1095 y Fu(\017)41 b FC(Standar)o(d)18 +b(input)k(now)f(unbuf)o(fer)o(ed)573 1194 y(Scsh's)d(startup)g(code)f +(now)i(makes)f(the)g(initial)g(curr)o(ent)f(input)i(port)f(\(corr)o +(espond-)573 1294 y(ing)24 b(to)h(\002le)f(descriptor)f(0\))g(unbuf)o +(fer)o(ed.)33 b(This)24 b(keeps)g(the)g(shell)h(fr)o(om)e +(\223stealing\224)573 1394 y(input)e(meant)g(for)g(subpr)o(ocesses.)26 +b(However)-6 b(,)20 b(it)h(does)g(slow)h(down)g(character)o(-at-)573 +1493 y(a-time)i(input)h(pr)o(ocessing.)36 b(If)24 b(you)h(ar)o(e)e +(writing)i(a)f(pr)o(ogram)g(that)g(is)h(tolerant)g(of)573 +1593 y(buf)o(fer)o(ed)18 b(input,)j(and)g(wish)h(the)f(ef)o(\002ciency) +f(gains,)h(you)h(can)e(r)o(eset)g(the)i(buf)o(fering)573 +1693 y(policy)f(yourself.)490 1874 y Fu(\017)41 b FC(\223writeable\224) +19 b(now)j(spelled)e(\223writable\224)573 1974 y(W)-8 +b(e)27 b(inconsistently)h(spelled)f Fy(file-writable?)21 +b FC(and)26 b Fy(file-not-writabl)o(e?)20 b FC(in)573 +2073 y(the)25 b(manual)f(and)h(the)g(implementation.)38 +b(W)-8 b(e)25 b(have)f(now)i(standar)o(dised)d(on)i(the)573 +2173 y(common)g(spelling)f(\223writable\224)d(in)j(both.)34 +b(The)23 b(older)g(bindings)h(still)g(exist)f(in)h(r)o(e-)573 +2273 y(lease)c(0.4,)f(but)i(will)h(go)f(away)f(in)h(futur)o(e)f(r)o +(eleases.)490 2454 y Fu(\017)41 b Fy(char-set-member?)14 +b FC(r)o(eplaced)573 2554 y(W)-8 b(e)21 b(have)f(de-r)o(eleased)e(the)j +Fy(char-set-member?)14 b FC(pr)o(ocedur)o(e.)24 b(The)d(scsh)g(0.3)f +(ver)o(-)573 2654 y(sion)i(of)e(this)i(pr)o(ocedur)o(e)d(took)i(ar)o +(guments)g(in)g(the)g(following)h(or)o(der:)756 2810 +y Fy(\(char-set-membe)o(r?)37 b FB(char)43 b(char-set)o +Fy(\))573 2967 y FC(This)17 b(ar)o(gument)g(or)o(der)f(is)h(in)h(accor) +o(dance)d(with)j(standar)o(d)d(mathematical)i(useage)573 +3067 y(\()p FB(i.e.)o FC(,)31 b Fz(x)38 b Fu(2)h Fz(S)5 +b FC(\),)30 b(and)e(also)h(consistent)h(with)g(the)f(R4RS)g +Fy(member)p FC(,)f Fy(memq)f FC(and)h Fy(memv)573 3167 +y FC(pr)o(ocedur)o(es.)59 b(It)33 b(is,)j(however)-6 +b(,)35 b(exactly)d(opposite)h(fr)o(om)g(the)f(ar)o(gument)h(or)o(der) +573 3266 y(used)23 b(by)h(the)g Fy(char-set-member?)18 +b FC(in)24 b(MIT)f(Scheme's)h(character)o(-set)e(library)-9 +b(.)34 b(If)573 3366 y(we)27 b(left)g(things)h(as)f(they)g(wer)o(e,)h +(we)f(risked)g(pr)o(oblems)f(with)i(code)f(ported)g(over)573 +3465 y(fr)o(om)j(MIT)g(Scheme.)54 b(On)31 b(the)f(other)h(hand,)h +(changing)g(to)e(conformance)h(with)573 3565 y(MIT)c(Scheme)h(meant)f +(inconsistency)j(with)f(common)g(mathematical)e(notation)573 +3665 y(and)f(other)h(long-standing)h(Scheme)f(pr)o(ocedur)o(es.)42 +b(Either)26 b(way)h(was)g(bound)g(to)573 3764 y(intr)o(oduce)20 +b(confusion.)573 3905 y(W)-8 b(e've)34 b(taken)g(the)h(appr)o(oach)e +(of)i(simply)g(r)o(emoving)g(the)f Fy(char-set-member?)573 +4005 y FC(pr)o(ocedur)o(e)19 b(altogether)-6 b(,)20 b(and)g(r)o +(eplacing)g(it)h(with)h(a)e(new)h(pr)o(ocedur)o(e:)756 +4161 y Fy(\(char-set-conta)o(in)o(s?)37 b FB(cset)44 +b(char)o Fy(\))573 4318 y FC(Note)21 b(that)f(the)h(ar)o(gument)g(or)o +(der)e(is)i(consistent)h(with)g(the)f(name.)490 4500 +y Fu(\017)41 b Fy(file-attributes)14 b FC(now)22 b Fy(file-info)573 +4599 y FC(In)17 b(keeping)g(with)g(the)g(general)f(convention)i(in)f +(scsh)g(of)f(naming)i(pr)o(ocedur)o(es)d(that)573 4699 +y(r)o(etrieve)33 b(information)i(about)f(system)h(r)o(esour)o(ces)f +Fy(...-info)d FC(\()p FB(e.g.)o FC(,)37 b Fy(tty-info)p +FC(,)573 4799 y Fy(user-info)p FC(,)16 b Fy(group-info)p +FC(\),)f(the)20 b Fy(file-attributes)14 b FC(pr)o(ocedur)o(e)k(is)i +(now)h(named)573 4898 y Fy(file-info)p FC(.)1735 5147 +y(149)p eop +%%Page: 150 156 +150 155 bop 888 614 a FC(W)-8 b(e)17 b(continue)h(to)g(export)e(a)h +Fy(file-attributes)10 b FC(binding)18 b(for)f(the)g(curr)o(ent)f(r)o +(elease,)888 714 y(but)21 b(it)g(will)h(go)f(away)f(in)h(futur)o(e)f(r) +o(eleases.)805 901 y Fu(\017)41 b FC(Renaming)22 b(of)f(I/O)g(synchr)o +(onisation)h(pr)o(ocedur)o(es)888 1000 y(The)108 b Fy(\(stdio->stdport) +o(s)38 b FB(thunk)o Fy(\))107 b FC(pr)o(ocedur)o(e)e(has)i(been)g(r)o +(enamed)888 1100 y Fy(with-stdio-ports*)o FC(;)35 b(ther)o(e)f(is)h +(now)g(a)f(corr)o(esponding)h Fy(with-stdio-port)o(s)888 +1200 y FC(special)54 b(form.)126 b(The)55 b Fy(stdio->stdports)48 +b FC(pr)o(ocedur)o(e)k(is)j(now)g(a)f(nullary)888 1299 +y(pr)o(ocedur)o(e)19 b(that)i(side-ef)o(fects)e(the)h(curr)o(ent)g(set) +h(of)g(curr)o(ent)f(I/O)h(port)g(bindings.)805 1486 y +Fu(\017)41 b FC(New)21 b(meta-ar)o(g)e(line-two)j(syntax)888 +1586 y(Scsh)g(now)h(uses)e(a)h(simpli\002ed)g(grammar)f(for)h +(describing)f(command-line)h(ar)o(gu-)888 1685 y(ments)29 +b(r)o(ead)e(by)h(the)g(\223meta-ar)o(g\224)e(switch)j(fr)o(om)f(line)g +(two)h(of)f(a)g(shell)h(script.)47 b(If)888 1785 y(you)26 +b(wer)o(e)f(using)h(this)g(featur)o(e)e(in)h(pr)o(evious)g(r)o +(eleases,)g(the)h(thr)o(ee)f(incompatible)888 1885 y(changes)19 +b(of)g(which)h(to)f(be)f(awar)o(e)f(ar)o(e:)23 b(\(1\))18 +b(tab)g(is)h(no)g(longer)h(allowed)e(as)h(an)f(ar)o(gu-)888 +1984 y(ment)24 b(delimiter)-6 b(,)23 b(\(2\))f(a)g(r)o(un)i(of)f(space) +f(characters)g(is)h(not)h(equivalent)f(to)h(a)e(single)888 +2084 y(space,)e(\(3\))g(empty)h(ar)o(guments)f(ar)o(e)f(written)j(a)e +(dif)o(fer)o(ent)e(way)-9 b(.)681 2401 y Fw(10.3)99 b +(Backwards-compatible)25 b(improvements)681 2636 y FC(Some)c(existing)h +(featur)o(es)d(in)j(scsh)f(have)g(been)g(impr)o(oved)f(in)i(ways)f +(that)g(will)h(not)g(ef)o(fect)681 2735 y(existing)f(code.)805 +2974 y Fu(\017)41 b FC(Impr)o(oved)20 b(err)o(or)g(r)o(eporting)888 +3074 y(Exception)d(handlers)f(that)g(print)g(out)h(err)o(or)e(messages) +i(and)f(warnings)h(now)g(print)888 3173 y(their)32 b(messages)g(on)g +(the)g(err)o(or)f(output)h(port,)j(instead)c(of)h(the)g(curr)o(ent)f +(output)888 3273 y(port.)26 b(Pr)o(evious)19 b(r)o(eleases)f(used)i +(the)g(curr)o(ent)f(output)h(port,)f(a)h(pr)o(oblem)f(inherited)888 +3373 y(fr)o(om)i(Scheme)f(48.)888 3516 y(Pr)o(evious)f(scsh)g(r)o +(eleases)e(\003ushed)i(the)g(Scheme)f(48)f(debugging)i(tables)f(when)h +(cr)o(e-)888 3616 y(ating)28 b(the)f(standar)o(d)f(scsh)h(heap)g +(image.)45 b(This)28 b(trimmed)f(the)g(size)g(of)g(the)h(heap)888 +3715 y(image,)23 b(but)f(made)g(err)o(or)f(messages)i(much)g(less)f +(compr)o(ehensible.)31 b(W)-8 b(e)22 b(now)h(r)o(e-)888 +3815 y(tain)c(the)g(debugging)g(tables.)25 b(This)19 +b(bloats)g(the)g(heap)g(image)f(up)h(by)g(about)g(600kb.)888 +3914 y(And)i(worth)g(it,)g(too.)888 4058 y(\(W)-8 b(e)27 +b(also)f(have)h(some)g(new)g(techniques)g(for)g(eliminating)g(the)g(r)o +(un-time)g(mem-)888 4157 y(ory)c(penalty)f(imposed)h(by)g(these)f(lar)o +(ge)g(heap)g(images.)31 b(Scsh's)22 b(new)h(static-heap)888 +4257 y(technology)34 b(allows)f(for)f(this)h(data)e(to)i(be)f(linked)g +(into)h(the)g(text)f(pages)g(of)g(the)888 4357 y(vm's)26 +b(binary)-9 b(,)27 b(wher)o(e)e(it)g(will)i(not)f(be)f(touched)h(by)g +(the)f(GC)h(or)g(otherwise)g(af)o(fect)888 4456 y(the)21 +b(memory)h(system)f(until)h(it)f(is)g(r)o(efer)o(enced.\))888 +4599 y(Finally)-9 b(,)26 b(scsh)g(now)f(generates)f(mor)o(e)h +(informative)g(err)o(or)e(messages)i(for)g(syscall)888 +4699 y(err)o(ors.)k(For)22 b(example,)f(a)g(\002le-open)h(err)o(or)f +(pr)o(eviously)h(told)g(you)h(what)f(the)g(err)o(or)888 +4799 y(was)29 b(\()p FB(e.g.)o FC(,)g(\223Permission)h(denied,\224)f +(or)f(\223No)g(such)h(\002le)f(or)h(dir)o(ectory\224\),)f(but)g(not)888 +4898 y(which)22 b(\002le)f(you)g(had)g(tried)f(to)h(open.)26 +b(W)-8 b(e've)20 b(impr)o(oved)h(this.)2051 5147 y(150)p +eop +%%Page: 151 157 +151 156 bop 490 614 a Fu(\017)41 b FC(Closing)22 b(a)e(port)h(twice)g +(allowed)573 714 y(Scsh)k(used)g(to)h(generate)e(an)h(err)o(or)f(if)h +(you)h(attempted)f(to)g(close)h(a)e(port)i(that)f(had)573 +814 y(alr)o(eady)20 b(been)i(closed.)29 b(This)23 b(is)f(now)h +(allowed.)29 b(The)22 b(close)g(pr)o(ocedur)o(e)f(r)o(eturns)g(a)573 +913 y(boolean)g(to)g(indicate)f(whether)h(the)g(port)g(had)f(alr)o +(eady)f(been)i(closed)g(or)g(not.)490 1079 y Fu(\017)41 +b FC(Better)20 b(time)h(pr)o(ecision)573 1179 y(The)33 +b Fy(time+ticks)d FC(pr)o(ocedur)o(e)h(now)k(r)o(eturns)e(sub-second)h +(pr)o(ecision)f(on)h(OS's)573 1279 y(that)21 b(support)g(it.)490 +1445 y Fu(\017)41 b FC(Nicer)20 b(print-methods)i(for)e(basic)g +(data-types)573 1544 y(Scsh's)e(standar)o(d)f(r)o(ecor)o(d)f(types)j +(now)g(print)f(mor)o(e)g(informatively)-9 b(.)25 b(For)19 +b(example,)573 1644 y(a)j(pr)o(ocess)h(object)g(includes)g(the)g(pr)o +(ocess)f(id)h(in)g(its)g(printed)g(r)o(epr)o(esentation:)28 +b(the)573 1743 y(pr)o(ocess)20 b(object)h(for)g(pr)o(ocess)f(id)h(2653) +e(prints)i(as)f Fy(#{proc)41 b(2653})p FC(.)1735 5147 +y(151)p eop +%%Page: 152 158 +152 157 bop 805 614 a FC(\277)2051 5147 y(152)p eop +%%Page: 153 159 +153 158 bop 365 1262 a Fx(Chapter)45 b(1)-6 b(1)365 1702 +y FD(T)-23 b(odo)365 2159 y FC(W)-8 b(e'd)18 b(love)f(to)h(have)f(have) +g(people)h(implement)g(these)g(subsystems)g(and)f(fold)h(them)g(into) +365 2258 y(the)j(scsh)h(r)o(elease:)490 2447 y Fu(\017)41 +b FC(Mor)o(e)20 b(network)h(pr)o(otocols.)26 b(T)-8 b(elnet)21 +b(and)f(ftp)h(would)g(be)f(the)h(most)h(important.)490 +2612 y Fu(\017)41 b FC(An)21 b(ILU)f(interface.)490 2776 +y Fu(\017)41 b FC(An)21 b(RPC)g(system,)g(with)g(\223tail-r)o +(ecursion.\224)490 2941 y Fu(\017)41 b FC(Interfaces)20 +b(to)h(r)o(elational)f(db's.)25 b(This)c(would)h(be)e(quite)h(useful)g +(for)g(W)-8 b(eb)20 b(servers.)365 3130 y(Manual)g(hacking:)490 +3319 y Fu(\017)41 b FC(The)17 b(L)750 3301 y Fa(A)783 +3319 y FC(T)820 3338 y(E)860 3319 y(X)h(hackery)f(needs)h(yet)f +(another)h(serious)g(pass.)24 b(Most)18 b(importantly)-9 +b(,)19 b(long)573 3418 y(pr)o(ocedur)o(e)g(\223declarations\224)g(need) +h(to)h(be)g(br)o(oken)f(acr)o(oss)g(two)i(lines.)490 +3583 y Fu(\017)41 b FC(Fix)21 b(up)f(0-or)o(-mor)o(e)f(and)i(1-or)o +(-mor)o(e)e(parameter)g(typesetting,)i(with)g(subscripts.)490 +3748 y Fu(\017)41 b FC(Parameter)19 b(subscripts)i(need)g(to)g(be)f +(made)g(r)o(eal)g(subscripts.)490 3913 y Fu(\017)41 b +FC(Soup)27 b(up)f(the)h(markup)g(pr)o(ocessor)-6 b(,)27 +b(and)g(r)o(edo)f(manual)g(in)i(markup.)43 b(Generate)573 +4012 y(LaT)-8 b(eX,)17 b(HTML,)f(and)h(info)h(versions.)25 +b(Alternatively)-9 b(,)18 b(persuade)e(some)i(kind)g(soul)573 +4112 y(to)j(hand-port)f(manual)h(to)g(HTML)f(or)h(info.)365 +4301 y(Job)g(contr)o(ol,)g(after)e Fy(jcontrol.scm)365 +4425 y FC(Static)h(heaps;)h(fast)f(startup.)365 4550 +y(Gnu)i(r)o(eadline)d(lib.)365 4674 y(Interr)o(upt)i(system.)365 +4799 y(Make)h(it)h(all)f(coexist)h(with)g(S48)f(thr)o(eads)f(as)h(well) +h(as)g(can)f(be)g(done)h(for)f(Unix.)31 b(The)23 b(DEC)365 +4898 y(SRC)e(tech)g(r)o(eport)f(gives)h(a)f(good)h(discussion)h(of)f +(the)g(issues.)1735 5147 y(153)p eop +%%Page: 154 160 +154 159 bop 681 614 a FC(T)-8 b(esting)21 b(br)o(oken)g +(symlinks\227new)i(value)d(for)g FB(chase?)g FC(\003ag?)681 +739 y(Rename)h(and)f(r)o(elease)f Fy(ensure-file-name-)o(is)o(-)p +Fu(f)o Fy(non)o(,)p Fu(g)o Fy(di)o(rec)o(to)o(ry)p FC(.)681 +863 y(Mor)o(e)g(informative)i(errno)g(exception)g(packets)f(&)g +(documentation)i(for)e(them.)681 988 y(Other)i(things)h(should)g(be)f +(available:)k(hash)d(tables,)e(sort,)i(list)f(utils,)h(pattern)e +(matchers.)681 1088 y(But)g(things)h(start)f(to)h(overload.)27 +b(The)21 b(module)h(system)g(is)f(the)h(appr)o(opriate)d(way)i(to)h +(use)681 1187 y(these.)681 1312 y(Need)c(to)h(do)g(\002le-contr)o(ol)h +(\()p FB(i.e.)o FC(,)f Fy(fcntl\(\))p FC(\).)j Fy(fcntl)17 +b FC(is)i(ugly)-9 b(.)25 b(Better)19 b(to)g(have)g(a)f(pr)o(ocedur)o(e) +681 1411 y(for)i(each)h(dif)o(fer)o(ent)d(operation.)2051 +5147 y(154)p eop +%%Page: 155 161 +155 160 bop 365 1095 a FD(Index)365 1513 y Fy(\045read-delimited!)p +FC(,)14 b(1)-5 b(10)365 1706 y(*temp-\002le-template*,)20 +b(49)365 1899 y Fy(->uid)p FC(,)f(61)365 2000 y Fy(->username)p +FC(,)e(61)365 2193 y Fy(\045exec)p FC(,)i(52)365 2293 +y Fy(\045exit)p FC(,)g(52)365 2393 y Fy(\045fork)p FC(,)g(53)365 +2493 y Fy(\045fork/pipe)p FC(,)e(53)365 2593 y Fy(\045fork/pipe+)p +FC(,)f(54)365 2694 y Fy(&)p FC(,)k(13)365 2794 y Fy(&&)p +FC(,)g(20)365 2894 y Fy(interrupt/alarm)p FC(,)15 b(64)365 +2994 y Fy(interrupt/alrm)p FC(,)g(64)365 3094 y Fy(interrupt/chld)p +FC(,)g(64)365 3195 y Fy(interrupt/cont)p FC(,)g(64)365 +3295 y Fy(interrupt/hup)p FC(,)g(64)365 3395 y Fy(interrupt/info)p +FC(,)g(64)365 3495 y Fy(interrupt/int)p FC(,)g(64)365 +3596 y Fy(interrupt/io)p FC(,)h(64)365 3696 y Fy(interrupt/keyboar)o(d) +p FC(,)e(64)365 3796 y Fy(interrupt/memory-)o(sh)o(ort)o(ag)o(e)p +FC(,)g(64)365 3896 y Fy(interrupt/poll)p FC(,)h(64)365 +3996 y Fy(interrupt/prof)p FC(,)g(64)365 4097 y Fy(interrupt/pwr)p +FC(,)g(64)365 4197 y Fy(interrupt/quit)p FC(,)g(64)365 +4297 y Fy(interrupt/term)p FC(,)g(64)365 4397 y Fy(interrupt/tstp)p +FC(,)g(64)365 4497 y Fy(interrupt/urg)p FC(,)g(64)365 +4598 y Fy(interrupt/usr1)p FC(,)g(64)365 4698 y Fy(interrupt/usr2)p +FC(,)g(64)365 4798 y Fy(interrupt/vtalrm)p FC(,)f(64)365 +4898 y Fy(interrupt/winch)p FC(,)h(64)1943 1513 y Fy(interrupt/xcpu)p +FC(,)f(64)1943 1616 y Fy(interrupt/xfsz)p FC(,)g(64)1943 +1718 y Fy(signal/abrt)p FC(,)i(65)1943 1821 y Fy(signal/alrm)p +FC(,)g(64)1943 1924 y Fy(signal/bus)p FC(,)g(65)1943 +2026 y Fy(signal/chld)p FC(,)g(64)1943 2129 y Fy(signal/cont)p +FC(,)g(64)1943 2231 y Fy(signal/emt)p FC(,)g(65)1943 +2334 y Fy(signal/fpe)p FC(,)g(65)1943 2436 y Fy(signal/hup)p +FC(,)g(64)1943 2539 y Fy(signal/ill)p FC(,)g(65)1943 +2642 y Fy(signal/info)p FC(,)g(64)1943 2744 y Fy(signal/int)p +FC(,)g(64)1943 2847 y Fy(signal/iot)p FC(,)g(65)1943 +2949 y Fy(signal/io)p FC(,)h(64)1943 3052 y Fy(signal/kill)p +FC(,)f(65)1943 3154 y Fy(signal/pipe)p FC(,)g(65)1943 +3257 y Fy(signal/poll)p FC(,)g(64)1943 3360 y Fy(signal/prof)p +FC(,)g(64)1943 3462 y Fy(signal/pwr)p FC(,)g(64)1943 +3565 y Fy(signal/quit)p FC(,)g(64)1943 3667 y Fy(signal/segv)p +FC(,)g(65)1943 3770 y Fy(signal/stop)p FC(,)g(65)1943 +3873 y Fy(signal/sys)p FC(,)g(65)1943 3975 y Fy(signal/term)p +FC(,)g(64)1943 4078 y Fy(signal/trap)p FC(,)g(65)1943 +4180 y Fy(signal/tstp)p FC(,)g(64)1943 4283 y Fy(signal/ttin)p +FC(,)g(65)1943 4385 y Fy(signal/ttou)p FC(,)g(65)1943 +4488 y Fy(signal/urg)p FC(,)g(64)1943 4591 y Fy(signal/usr1)p +FC(,)g(64)1943 4693 y Fy(signal/usr2)p FC(,)g(64)1943 +4796 y Fy(signal/vtalrm)p FC(,)f(64)1943 4898 y Fy(signal/winch)p +FC(,)g(64)1735 5147 y(155)p eop +%%Page: 156 162 +156 161 bop 681 614 a Fy(signal/xcpu)p FC(,)16 b(64)681 +715 y Fy(signal/xfsz)p FC(,)g(64)681 907 y Fy(accept-connectio)o(n)p +FC(,)e(93)681 1007 y Fy(add-after)p FC(,)j(75)681 1107 +y Fy(add-before)p FC(,)f(75)681 1208 y Fy(alist->env)p +FC(,)g(73)681 1308 y Fy(alist-compress)p FC(,)e(74)681 +1408 y Fy(alist-delete)p FC(,)h(74)681 1508 y Fy(alist-update)p +FC(,)g(74)681 1608 y Fy(arg)p FC(,)k(62)681 1709 y Fy(arg*)p +FC(,)g(62)681 1809 y Fy(argv)p FC(,)g(62)681 1909 y Fy +(arithmetic-shift)o FC(,)c(125)681 2009 y Fy(ascii->char)p +FC(,)h(106)681 2109 y Fy(ascii-range->cha)o(r-)o(set)o +FC(,)f(107)681 2210 y Fy(autoreap-policy)p FC(,)f(56)681 +2310 y(awk,)20 b(1)-5 b(19)681 2502 y Fy(become-session-l)o(ea)o(der)o +FC(,)15 b(81)681 2602 y Fy(bind-listen-acce)o(pt)o(-lo)o(op)o +FC(,)g(90)681 2703 y Fy(bind-socket)p FC(,)h(93)681 2803 +y Fy(bitwise-and)p FC(,)g(125)681 2903 y Fy(bitwise-ior)p +FC(,)g(125)681 3003 y Fy(bitwise-not)p FC(,)g(125)681 +3103 y Fy(bitwise-xor)p FC(,)g(125)681 3296 y Fy(call-terminally)p +FC(,)e(52)681 3396 y Fy(call-with-string)o(-o)o(utp)o(ut)o(-p)o(ort)o +FC(,)1013 3496 y(26)681 3596 y Fy(call/fdes)p FC(,)j(30)681 +3696 y Fy(char->ascii)p FC(,)f(106)681 3796 y Fy(char-alphabetic?)o +FC(,)f(108)681 3896 y Fy(char-alphanumeri)o(c?)o FC(,)g(108)681 +3997 y Fy(char-filter)p FC(,)h(20)681 4097 y Fy(char-graphic?)p +FC(,)f(108)681 4197 y Fy(char-lower-case?)o FC(,)g(108)681 +4297 y Fy(char-numeric?)82 b FC(,)20 b(108)681 4397 y +Fy(char-set)p FC(,)d(107)681 4498 y Fy(char-set-contain)o(s?)o +FC(,)e(107)681 4598 y Fy(char-set-differe)o(nc)o(e)p +FC(,)f(108)681 4698 y Fy(char-set-interse)o(ct)o(ion)o +FC(,)h(108)681 4798 y Fy(char-set-invert)p FC(,)f(108)681 +4898 y Fy(char-set-members)o FC(,)h(107)2258 614 y Fy(char-set-union)p +FC(,)g(108)2258 714 y(char)o(-set:alphabetic,)j(108)2258 +814 y(char)o(-set:alphanumeric,)h(108)2258 914 y(char)o(-set:graphic,)g +(108)2258 1014 y(char)o(-set:lower)o(-case,)f(108)2258 +1114 y(char)o(-set:not-whitespace,)h(108)2258 1214 y(char)o +(-set:numeric,)g(108)2258 1314 y(char)o(-set:upper)o(-case,)e(108)2258 +1414 y(char)o(-set:whitespace,)i(108)2258 1514 y Fy(char-set?)p +FC(,)e(107)2258 1613 y Fy(char-upper-case?)p FC(,)d(108)2258 +1713 y Fy(char-whitespace?)p FC(,)g(108)2258 1813 y Fy(chars->char-set) +p FC(,)h(107)2258 1913 y Fy(chdir)p FC(,)k(59)2258 2013 +y Fy(close)p FC(,)g(25)2258 2113 y Fy(close-after)p FC(,)d(24)2258 +2213 y Fy(close-socket)p FC(,)g(90)2258 2313 y Fy(command-line)p +FC(,)g(61)2258 2413 y(command-line-ar)o(guments,)k(61)2258 +2513 y Fy(connect-socket)p FC(,)15 b(93)2258 2613 y Fy +(control-tty-file-)o(na)o(me)p FC(,)f(81)2258 2712 y +Fy(copy-tty-info)p FC(,)h(79)2258 2812 y Fy(cpu-ticks/sec)p +FC(,)g(60)2258 2912 y Fy(create-directory)p FC(,)f(40)2258 +3012 y Fy(create-fifo)p FC(,)i(40)2258 3112 y Fy(create-hard-link)p +FC(,)e(40)2258 3212 y Fy(create-socket)p FC(,)h(90)2258 +3312 y Fy(create-socket-pai)o(r)p FC(,)f(90)2258 3412 +y Fy(create-symlink)p FC(,)h(40)2258 3512 y Fy(create-temp-file)p +FC(,)f(48)2258 3612 y Fy(cwd)p FC(,)19 b(59)2258 3799 +y(date,)h(68,)f(70)2258 3899 y Fy(date->string)p FC(,)d(71)2258 +3999 y Fy(define-record)p FC(,)f(7)2258 4099 y Fy(delete-directory)p +FC(,)f(40)2258 4199 y Fy(delete-file)p FC(,)i(40)2258 +4299 y Fy(delete-filesys-ob)o(je)o(ct)p FC(,)e(40)2258 +4399 y Fy(directory-as-file)o(-n)o(ame)o FC(,)h(102)2258 +4499 y Fy(directory-files)p FC(,)g(44)2258 4599 y Fy(disable-tty-char)p +FC(,)f(78)2258 4698 y Fy(drain-tty)p FC(,)j(80)2258 4798 +y Fy(dump-scsh)p FC(,)g(142)2258 4898 y Fy(dump-scsh-program)o +FC(,)e(141)2051 5147 y(156)p eop +%%Page: 157 163 +157 162 bop 365 614 a Fy(dup)p FC(,)20 b(31)365 714 y +Fy(dup->fdes)p FC(,)d(31)365 815 y Fy(dup->inport)p FC(,)f(31)365 +915 y Fy(dup->outport)p FC(,)g(31)365 1105 y Fy(enabled-interrupt)o(s)p +FC(,)e(66)365 1205 y Fy(env->alist)p FC(,)j(73)365 1305 +y Fy(errno-error)p FC(,)f(21)365 1405 y Fy(error-output-port)o +FC(,)f(24)365 1505 y Fy(exec)p FC(,)k(51)365 1605 y(exec-epf,)g(13)365 +1706 y Fy(exec-path)p FC(,)e(51)365 1806 y(exec-path-list,)j(76)365 +1906 y Fy(exec-path-search)p FC(,)14 b(52)365 2006 y +Fy(exec-path/env)p FC(,)h(51)365 2106 y Fy(exec/env)p +FC(,)i(51)365 2206 y Fy(exit)p FC(,)i(52)365 2306 y Fy +(expand-file-name)p FC(,)14 b(106)365 2497 y Fy(fdes->inport)p +FC(,)i(30)365 2597 y Fy(fdes->outport)p FC(,)f(30)365 +2697 y Fy(fdes-flags)p FC(,)i(32)365 2797 y Fy(fdes-status)p +FC(,)f(33)365 2897 y Fy(field-reader)p FC(,)g(1)-5 b(16)365 +2997 y Fy(field-splitter)p FC(,)15 b(1)-5 b(13)365 3097 +y Fy(file-directory?)p FC(,)15 b(43)365 3197 y Fy(file-executable?)p +FC(,)f(44)365 3297 y Fy(file-exists?)p FC(,)i(44)365 +3397 y Fy(file-fifo?)p FC(,)h(43)365 3497 y Fy(file-group)p +FC(,)g(42)365 3597 y Fy(file-info)p FC(,)g(41)365 3697 +y(\002le-info:atime,)k(42)365 3797 y(\002le-info:ctime,)g(42)365 +3898 y(\002le-info:device,)f(42)365 3998 y(\002le-info:gid,)h(42)365 +4098 y(\002le-info:inode,)g(42)365 4198 y(\002le-info:mode,)g(42)365 +4298 y(\002le-info:mtime,)g(42)365 4398 y(\002le-info:nlinks,)h(42)365 +4498 y(\002le-info:size,)e(42)365 4598 y(\002le-info:type,)h(42)365 +4698 y(\002le-info:uid,)g(42)365 4798 y Fy(file-inode)p +FC(,)c(42)365 4898 y Fy(file-last-access)p FC(,)d(42)1943 +614 y Fy(file-last-mod)p FC(,)h(42)1943 714 y Fy(file-last-status)o(-c) +o(ha)o(nge)o FC(,)g(42)1943 814 y Fy(file-match)p FC(,)h(46)1943 +914 y Fy(file-mode)p FC(,)h(42)1943 1014 y Fy(file-name-absolu)o(te)o +(?)p FC(,)d(103)1943 1114 y Fy(file-name-as-dir)o(ec)o(to)o(ry)p +FC(,)g(102)1943 1214 y Fy(file-name-direct)o(or)o(y)p +FC(,)g(103)1943 1314 y Fy(file-name-direct)o(or)o(y?)o +FC(,)h(102)1943 1414 y Fy(file-name-extens)o(io)o(n)p +FC(,)f(104)1943 1514 y Fy(file-name-non-di)o(re)o(ct)o(ory)o(?)p +FC(,)g(102)1943 1613 y Fy(file-name-nondir)o(ec)o(to)o(ry)p +FC(,)g(103)1943 1713 y Fy(file-name-sans-e)o(xt)o(en)o(sio)o(n)p +FC(,)g(104)1943 1813 y Fy(file-nlinks)p FC(,)i(42)1943 +1913 y Fy(file-not-executa)o(bl)o(e?)o FC(,)f(43)1943 +2013 y Fy(file-not-exists?)o FC(,)g(44)1943 2113 y Fy(file-not-readabl) +o(e?)o FC(,)g(43)1943 2213 y Fy(file-not-writabl)o(e?)o +FC(,)g(43)1943 2313 y Fy(file-owner)p FC(,)h(42)1943 +2413 y Fy(file-readable?)p FC(,)e(44)1943 2513 y Fy(file-regular?)p +FC(,)h(43)1943 2613 y Fy(file-size)p FC(,)i(42)1943 2712 +y Fy(file-socket?)p FC(,)e(43)1943 2812 y Fy(file-special?)p +FC(,)g(43)1943 2912 y Fy(file-symlink?)p FC(,)g(43)1943 +3012 y Fy(file-type)p FC(,)i(42)1943 3112 y Fy(file-writable?)p +FC(,)d(44)1943 3212 y Fy(fill-in-date!)p FC(,)h(71)1943 +3312 y Fy(flush-all-ports)p FC(,)f(37)1943 3412 y Fy(flush-tty/both)p +FC(,)g(80)1943 3512 y Fy(flush-tty/input)p FC(,)g(80)1943 +3612 y Fy(flush-tty/output)o FC(,)h(80)1943 3712 y Fy(force-output)p +FC(,)g(37)1943 3811 y Fy(fork)p FC(,)k(53)1943 3911 y +Fy(fork-pty-session)o FC(,)c(82)1943 4011 y Fy(fork/pipe)p +FC(,)i(53)1943 4111 y Fy(fork/pipe+)p FC(,)f(54)1943 +4211 y Fy(format-date)p FC(,)g(71)1943 4399 y Fy(get-lock-region)p +FC(,)e(39)1943 4499 y Fy(getenv)p FC(,)k(73)1943 4599 +y Fy(glob)p FC(,)h(45)1943 4698 y Fy(glob-quote)p FC(,)d(46)1943 +4798 y Fy(group-info)p FC(,)g(61)1943 4898 y(gr)o(oup-info:gid,)k(61) +1735 5147 y(157)p eop +%%Page: 158 164 +158 163 bop 681 614 a FC(gr)o(oup-info:members,)20 b(61)681 +715 y(gr)o(oup-info:name,)g(61)681 910 y Fy(home-dir)p +FC(,)d(106)681 1011 y(home-dir)o(ectory)-9 b(,)20 b(76)681 +1111 y Fy(home-file)p FC(,)d(106)681 1211 y Fy(host-info)p +FC(,)g(96)681 1407 y Fy(index)p FC(,)h(100)681 1507 y +Fy(infix-splitter)p FC(,)c(1)-5 b(13)681 1608 y Fy(internet-address)o +(->)o(soc)o(ke)o(t-)o(add)o(re)o(ss)p FC(,)1013 1707 +y(92)681 1808 y Fy(interrupt-handle)o(r)p FC(,)14 b(67)681 +1908 y Fy(interrupt-set)p FC(,)h(66)681 2008 y Fy(itimer)p +FC(,)j(63)681 2204 y Fy(join-strings)p FC(,)d(1)-5 b(16)681 +2400 y Fy(listen-socket)p FC(,)15 b(93)681 2500 y Fy(lock-region)p +FC(,)h(39)681 2600 y Fy(lock-region/no-b)o(lo)o(ck)p +FC(,)e(39)681 2701 y(lock-r)o(egion:end,)20 b(38)681 +2801 y(lock-r)o(egion:exclusive?,)g(38)681 2901 y(lock-r)o(egion:len,)g +(38)681 3002 y(lock-r)o(egion:pr)o(oc,)g(38)681 3102 +y(lock-r)o(egion:start,)g(38)681 3202 y(lock-r)o(egion:whence,)h(38)681 +3303 y(lock-r)o(egion?,)f(38)681 3498 y Fy(make-date)p +FC(,)d(69)681 3599 y Fy(make-lock-region)o FC(,)e(39)681 +3699 y Fy(make-pty-generat)o(or)o FC(,)g(82)681 3799 +y Fy(make-regexp)p FC(,)h(99)681 3900 y Fy(make-string-inpu)o(t-)o(por) +o(t)p FC(,)e(26)681 4000 y Fy(make-string-outp)o(ut)o(-po)o(rt)o +FC(,)h(26)681 4101 y Fy(make-tty-info)p FC(,)g(79)681 +4201 y Fy(match:end)p FC(,)i(99)681 4301 y Fy(match:start)p +FC(,)f(99)681 4402 y Fy(match:substring)p FC(,)e(99)681 +4502 y Fy(move->fdes)p FC(,)i(30)681 4698 y Fy(network-info)p +FC(,)f(96)681 4798 y Fy(nice)p FC(,)k(60)681 4898 y Fy(nth)p +FC(,)g(125)2258 614 y Fy(open-control-tty)p FC(,)14 b(81)2258 +714 y Fy(open-fdes)p FC(,)j(32)2258 815 y Fy(open-file)p +FC(,)g(32)2258 915 y Fy(open-input-file)p FC(,)e(32)2258 +1015 y Fy(open-output-file)p FC(,)f(32)2258 1115 y Fy(open-pty)p +FC(,)j(82)2258 1305 y Fy(parent-pid)p FC(,)g(60)2258 +1405 y Fy(parse-file-name)p FC(,)e(105)2258 1505 y Fy +(path-list->file-n)o(am)o(e)p FC(,)f(104)2258 1605 y +Fy(pause-until-inter)o(ru)o(pt)p FC(,)g(63)2258 1706 +y Fy(pid)p FC(,)19 b(60)2258 1806 y Fy(pid->proc)p FC(,)e(55)2258 +1906 y Fy(pipe)p FC(,)i(33)2258 2006 y Fy(port->fdes)p +FC(,)e(30)2258 2106 y Fy(port->list)p FC(,)g(15)2258 +2206 y Fy(port->sexp-list)p FC(,)e(15)2258 2306 y Fy(port->string)p +FC(,)h(15)2258 2406 y Fy(port->string-list)o FC(,)f(15)2258 +2506 y Fy(port-revealed)p FC(,)g(30)2258 2606 y Fy(predicate->char-s)o +(et)o FC(,)g(107)2258 2706 y Fy(priority)p FC(,)i(60)2258 +2806 y(pr)o(oc,)j(55)2258 2906 y(pr)o(oc:pid,)g(55)2258 +3007 y(pr)o(oc?,)g(55)2258 3107 y Fy(process-group)p +FC(,)15 b(60)2258 3207 y Fy(process-times)p FC(,)g(60)2258 +3307 y Fy(protocol-info)p FC(,)g(96)2258 3407 y Fy(pty-name->tty-nam)o +(e)p FC(,)f(82)2258 3597 y Fy(read-delimited)p FC(,)h(1)-5 +b(10)2258 3697 y Fy(read-delimited!)p FC(,)15 b(1)-5 +b(10)2258 3797 y Fy(read-line)p FC(,)17 b(109)2258 3898 +y Fy(read-paragraph)p FC(,)e(1)-5 b(10)2258 3998 y Fy(read-string)p +FC(,)16 b(33)2258 4098 y Fy(read-string!)p FC(,)g(33)2258 +4198 y Fy(read-string!/part)o(ia)o(l)p FC(,)e(34)2258 +4298 y Fy(read-string/parti)o(al)o FC(,)h(34)2258 4398 +y Fy(read-symlink)p FC(,)h(40)2258 4498 y Fy(reap-zombies)p +FC(,)g(56)2258 4598 y Fy(receive-message)p FC(,)f(94)2258 +4698 y Fy(receive-message!)p FC(,)f(94)2258 4798 y Fy +(receive-message!/)o(pa)o(rti)o(al)o FC(,)h(94)2258 4898 +y Fy(receive-message/p)o(ar)o(tia)o(l)p FC(,)f(94)2051 +5147 y(158)p eop +%%Page: 159 165 +159 164 bop 365 614 a Fy(record-reader)p FC(,)15 b(1)-5 +b(13)365 714 y Fy(reduce-port)p FC(,)16 b(16)365 814 +y Fy(regexp-exec)p FC(,)g(99)365 914 y Fy(regexp-match?)p +FC(,)f(98)365 1014 y Fy(regexp-quote)p FC(,)h(99)365 +1114 y Fy(regexp?)p FC(,)i(99)365 1214 y Fy(release-port-hand)o(le)o +FC(,)d(30)365 1314 y Fy(rename-file)p FC(,)h(40)365 1414 +y Fy(repl)p FC(,)j(125)365 1514 y Fy(replace-extension)o +FC(,)c(105)365 1613 y Fy(resolve-file-name)o FC(,)g(106)365 +1713 y Fy(rindex)p FC(,)j(100)365 1813 y(r)o(un,)j(13)365 +1913 y Fy(run/collecting)p FC(,)15 b(17)365 2013 y Fy(run/collecting*)p +FC(,)g(17)365 2113 y Fy(run/file)p FC(,)i(14)365 2213 +y Fy(run/file*)p FC(,)g(15)365 2313 y Fy(run/port)p FC(,)g(14)365 +2413 y Fy(run/port*)p FC(,)g(15)365 2513 y Fy(run/port+proc)p +FC(,)e(17)365 2613 y Fy(run/port+proc*)p FC(,)g(17)365 +2712 y Fy(run/sexp)p FC(,)i(14)365 2812 y Fy(run/sexp*)p +FC(,)g(15)365 2912 y Fy(run/sexps)p FC(,)g(14)365 3012 +y Fy(run/sexps*)p FC(,)g(15)365 3112 y Fy(run/string)p +FC(,)g(14)365 3212 y Fy(run/string*)p FC(,)f(15)365 3312 +y Fy(run/strings)p FC(,)g(14)365 3412 y Fy(run/strings*)p +FC(,)g(15)365 3599 y Fy(seek)p FC(,)j(31)365 3699 y Fy(select)41 +b FC(,)21 b(34)365 3799 y Fy(send-message)p FC(,)16 b(94)365 +3899 y Fy(send-message/part)o(ia)o(l)p FC(,)f(94)365 +3999 y Fy(send-tty-break)p FC(,)g(80)365 4099 y Fy(service-info)p +FC(,)h(96)365 4199 y Fy(set-enabled-inter)o(ru)o(pts)o +FC(,)f(66)365 4299 y Fy(set-fdes-flags)p FC(,)g(32)365 +4399 y Fy(set-fdes-status)p FC(,)g(33)365 4499 y Fy(set-file-group)p +FC(,)g(41)365 4599 y Fy(set-file-mode)p FC(,)g(41)365 +4698 y Fy(set-file-owner)p FC(,)g(41)365 4798 y Fy(set-file-times)p +FC(,)g(41)365 4898 y Fy(set-gid)p FC(,)j(60)1943 614 +y Fy(set-interrupt-ha)o(nd)o(le)o(r)p FC(,)d(66)1943 +714 y Fy(set-port-bufferi)o(ng)o FC(,)g(37)1943 814 y +Fy(set-priority)p FC(,)g(60)1943 913 y Fy(set-process-grou)o(p)p +FC(,)f(60)1943 1013 y Fy(set-socket-optio)o(n)p FC(,)g(95)1943 +1112 y Fy(set-tty-info/dra)o(in)o FC(,)h(79)1943 1212 +y Fy(set-tty-info/flu)o(sh)o FC(,)g(79)1943 1312 y Fy(set-tty-info/now) +o FC(,)g(79)1943 1411 y Fy(set-tty-process-)o(gr)o(ou)o(p)p +FC(,)g(81)1943 1511 y Fy(set-uid)p FC(,)i(60)1943 1611 +y Fy(set-umask)p FC(,)g(59)1943 1710 y Fy(setenv)p FC(,)h(73)1943 +1810 y Fy(shutdown-socket)p FC(,)c(94)1943 1910 y Fy(signal->interrup)o +(t)p FC(,)g(66)1943 2009 y Fy(signal-process)p FC(,)g(63)1943 +2109 y Fy(signal-process-g)o(ro)o(up)o FC(,)h(63)1943 +2208 y Fy(simplify-file-na)o(me)o FC(,)g(105)1943 2308 +y Fy(skip-char-set)p FC(,)g(1)-5 b(1)g(1)1943 2408 y +Fy(sleep)p FC(,)18 b(63)1943 2507 y Fy(sleep-until)p +FC(,)e(63)1943 2607 y Fy(sloppy-suffix-sp)o(li)o(tt)o(er)p +FC(,)e(1)-5 b(13)1943 2707 y Fy(socket-address->)o(in)o(te)o(rne)o(t-)o +(add)o(re)o(ss)o FC(,)2275 2806 y(92)1943 2906 y Fy(socket-address->)o +(un)o(ix)o(-ad)o(dr)o(ess)o FC(,)2275 3005 y(92)1943 +3105 y Fy(socket-connect)p FC(,)14 b(89)1943 3205 y Fy +(socket-local-add)o(re)o(ss)o FC(,)h(93)1943 3304 y Fy(socket-option)p +FC(,)g(95)1943 3404 y Fy(socket-remote-ad)o(dr)o(es)o(s)p +FC(,)g(93)1943 3504 y Fy(split-file-name)p FC(,)f(103)1943 +3603 y Fy(start-tty-input)p FC(,)g(80)1943 3703 y Fy(start-tty-output)o +FC(,)h(80)1943 3802 y Fy(status:exit-val)p FC(,)f(58)1943 +3902 y Fy(status:stop-sig)p FC(,)g(59)1943 4002 y Fy(status:term-sig)p +FC(,)g(59)1943 4101 y Fy(stdio->stdports)p FC(,)g(25)1943 +4201 y Fy(stdports->stdio)p FC(,)g(25)1943 4301 y Fy(stop-tty-input)p +FC(,)g(80)1943 4400 y Fy(stop-tty-output)p FC(,)g(80)1943 +4500 y Fy(string->char-set)o FC(,)h(107)1943 4599 y Fy(string-filter)p +FC(,)g(20)1943 4699 y Fy(string-match)p FC(,)g(98)1943 +4799 y Fy(string-output-po)o(rt)o(-o)o(utp)o(ut)o FC(,)g(26)1943 +4898 y Fy(substitute-env-v)o(ar)o(s)p FC(,)f(100)1735 +5147 y(159)p eop +%%Page: 160 166 +160 165 bop 681 614 a Fy(suffix-splitter)p FC(,)14 b(1)-5 +b(13)681 714 y Fy(suspend)p FC(,)17 b(53)681 814 y Fy(sync-file)p +FC(,)g(41)681 914 y Fy(sync-file-system)o FC(,)e(41)681 +1014 y Fy(system-name)p FC(,)h(63)681 1202 y Fy(tell)p +FC(,)j(31)681 1302 y Fy(temp-file-channe)o(l)p FC(,)14 +b(50)681 1401 y Fy(temp-file-iterat)o(e)p FC(,)g(49)681 +1501 y Fy(ticks/sec)p FC(,)j(69)681 1601 y(time,)k(68,)e(70)681 +1701 y Fy(time+ticks)p FC(,)d(69)681 1801 y Fy(truncate-file)p +FC(,)f(41)681 1901 y Fy(tty-file-name)p FC(,)g(77)681 +2001 y Fy(tty-info)p FC(,)i(79)681 2101 y(tty-info)k(r)o(ecor)o(d)e +(type,)h(77)681 2201 y Fy(tty-info:control)o(-c)o(har)o(s)p +FC(,)14 b(77)681 2301 y Fy(tty-info:control)o(-f)o(lag)o(s)p +FC(,)g(77)681 2401 y Fy(tty-info:input-f)o(la)o(gs)p +FC(,)g(77)681 2500 y Fy(tty-info:input-s)o(pe)o(ed)p +FC(,)g(77)681 2600 y Fy(tty-info:local-f)o(la)o(gs)p +FC(,)g(77)681 2700 y Fy(tty-info:min)p FC(,)h(77)681 +2800 y Fy(tty-info:output-)o(fl)o(ags)o FC(,)g(77)681 +2900 y Fy(tty-info:output-)o(sp)o(eed)o FC(,)g(77)681 +3000 y Fy(tty-info:time)p FC(,)g(77)681 3100 y Fy(tty-info?)p +FC(,)i(77)681 3200 y Fy(tty-name->pty-na)o(me)o FC(,)e(82)681 +3300 y Fy(tty-process-grou)o(p)p FC(,)f(81)681 3400 y +Fy(tty?)p FC(,)19 b(77)681 3500 y Fy(ttyc/2-stop-bits)o +FC(,)c(87)681 3599 y Fy(ttyc/CTS-output-)o(fl)o(ow-)o(ct)o(l)p +FC(,)f(87)681 3699 y Fy(ttyc/RTS-input-f)o(lo)o(w-c)o(tl)o +FC(,)h(87)681 3799 y Fy(ttyc/carrier-flo)o(w-)o(ctl)o +FC(,)g(87)681 3899 y Fy(ttyc/char-size)p FC(,)f(87)681 +3999 y Fy(ttyc/char-size5)p FC(,)g(87)681 4099 y Fy(ttyc/char-size6)p +FC(,)g(87)681 4199 y Fy(ttyc/char-size7)p FC(,)g(87)681 +4299 y Fy(ttyc/char-size8)p FC(,)g(87)681 4399 y Fy(ttyc/enable-pari)o +(ty)o FC(,)h(87)681 4499 y Fy(ttyc/enable-read)o FC(,)g(87)681 +4599 y Fy(ttyc/hup-on-clos)o(e)p FC(,)f(87)681 4698 y +Fy(ttyc/ignore-flag)o(s)p FC(,)g(87)681 4798 y Fy(ttyc/no-modem-sy)o +(nc)o FC(,)h(87)681 4898 y Fy(ttyc/odd-parity)p FC(,)f(87)2258 +614 y Fy(ttychar/delayed-s)o(us)o(pen)o(d)p FC(,)g(84)2258 +714 y Fy(ttychar/delete-ch)o(ar)o FC(,)h(84)2258 814 +y Fy(ttychar/delete-li)o(ne)o FC(,)g(84)2258 913 y Fy +(ttychar/delete-wo)o(rd)o FC(,)g(84)2258 1013 y Fy(ttychar/discard)p +FC(,)g(84)2258 1112 y Fy(ttychar/eof)p FC(,)h(84)2258 +1212 y Fy(ttychar/eol)p FC(,)g(84)2258 1312 y Fy(ttychar/eol2)p +FC(,)g(84)2258 1411 y Fy(ttychar/interrupt)o FC(,)f(84)2258 +1511 y Fy(ttychar/literal-n)o(ex)o(t)p FC(,)f(84)2258 +1611 y Fy(ttychar/quit)p FC(,)i(84)2258 1710 y Fy(ttychar/reprint)p +FC(,)f(84)2258 1810 y Fy(ttychar/start)p FC(,)g(84)2258 +1910 y Fy(ttychar/status)p FC(,)g(84)2258 2009 y Fy(ttychar/stop)p +FC(,)h(84)2258 2109 y Fy(ttychar/suspend)p FC(,)f(84)2258 +2208 y Fy(ttyin/7bits)p FC(,)h(85)2258 2308 y Fy(ttyin/beep-on-ove)o +(rf)o(low)o FC(,)f(85)2258 2408 y Fy(ttyin/check-parit)o(y)p +FC(,)f(85)2258 2507 y Fy(ttyin/cr->nl)p FC(,)i(85)2258 +2607 y Fy(ttyin/ignore-bad-)o(pa)o(rit)o(y-)o(ch)o(ars)o +FC(,)2590 2707 y(85)2258 2806 y Fy(ttyin/ignore-brea)o(k)p +FC(,)e(85)2258 2906 y Fy(ttyin/ignore-cr)p FC(,)h(85)2258 +3005 y Fy(ttyin/input-flow-)o(ct)o(l)p FC(,)f(85)2258 +3105 y Fy(ttyin/interrupt-o)o(n-)o(bre)o(ak)o FC(,)h(85)2258 +3205 y Fy(ttyin/lowercase)p FC(,)g(85)2258 3304 y Fy(ttyin/mark-parity) +o(-e)o(rro)o(rs)o FC(,)g(85)2258 3404 y Fy(ttyin/nl->cr)p +FC(,)h(85)2258 3504 y Fy(ttyin/output-flow)o(-c)o(tl)p +FC(,)e(85)2258 3603 y Fy(ttyin/xon-any)p FC(,)h(85)2258 +3703 y Fy(ttyl/alt-delete-w)o(or)o(d)p FC(,)f(88)2258 +3802 y Fy(ttyl/canonical)p FC(,)h(88)2258 3902 y Fy(ttyl/case-map)p +FC(,)g(88)2258 4002 y Fy(ttyl/echo)p FC(,)i(88)2258 4101 +y Fy(ttyl/echo-ctl)p FC(,)e(88)2258 4201 y Fy(ttyl/echo-delete-)o(li)o +(ne)p FC(,)f(88)2258 4301 y Fy(ttyl/echo-nl)p FC(,)i(88)2258 +4400 y Fy(ttyl/enable-signa)o(ls)o FC(,)f(88)2258 4500 +y Fy(ttyl/extended)p FC(,)g(88)2258 4599 y Fy(ttyl/flush-output)o +FC(,)g(88)2258 4699 y Fy(ttyl/hardcopy-del)o(et)o(e)p +FC(,)f(88)2258 4799 y Fy(ttyl/no-flush-on-)o(in)o(ter)o(ru)o(pt)o +FC(,)h(88)2258 4898 y Fy(ttyl/no-kernel-st)o(at)o(us)p +FC(,)f(88)2051 5147 y(160)p eop +%%Page: 161 167 +161 166 bop 365 614 a Fy(ttyl/reprint-unre)o(ad)o(-ch)o(ar)o(s)p +FC(,)14 b(88)365 714 y Fy(ttyl/ttou-signal)p FC(,)g(88)365 +814 y Fy(ttyl/visual-delet)o(e)p FC(,)g(88)365 914 y +Fy(ttyl/visual-delet)o(e-)o(lin)o(e)p FC(,)g(88)365 1014 +y Fy(ttyout/all-delay)p FC(,)g(86)365 1114 y Fy(ttyout/bs-delay)p +FC(,)h(86)365 1214 y Fy(ttyout/bs-delay0)p FC(,)f(86)365 +1314 y Fy(ttyout/bs-delay1)p FC(,)g(86)365 1414 y Fy(ttyout/cr->nl)p +FC(,)h(85)365 1514 y Fy(ttyout/cr-delay)p FC(,)g(86)365 +1614 y Fy(ttyout/cr-delay0)p FC(,)f(86)365 1713 y Fy(ttyout/cr-delay1)p +FC(,)g(86)365 1813 y Fy(ttyout/cr-delay2)p FC(,)g(86)365 +1913 y Fy(ttyout/cr-delay3)p FC(,)g(86)365 2013 y Fy(ttyout/delay-w/fi) +o(ll)o(-ch)o(ar)o FC(,)h(85)365 2113 y Fy(ttyout/discard-eo)o(t)p +FC(,)f(85)365 2213 y Fy(ttyout/enable)p FC(,)h(85)365 +2313 y Fy(ttyout/expand-tab)o(s)p FC(,)f(85)365 2413 +y Fy(ttyout/ff-delay)p FC(,)h(86)365 2513 y Fy(ttyout/ff-delay0)p +FC(,)f(86)365 2613 y Fy(ttyout/ff-delay1)p FC(,)g(86)365 +2713 y Fy(ttyout/fill-w/del)o FC(,)h(85)365 2812 y Fy(ttyout/nl->crnl)p +FC(,)g(85)365 2912 y Fy(ttyout/nl-delay)p FC(,)g(86)365 +3012 y Fy(ttyout/nl-delay0)p FC(,)f(86)365 3112 y Fy(ttyout/nl-delay1)p +FC(,)g(86)365 3212 y Fy(ttyout/nl-does-cr)o FC(,)h(85)365 +3312 y Fy(ttyout/no-col0-cr)o FC(,)g(85)365 3412 y Fy(ttyout/tab-delay) +p FC(,)f(86)365 3512 y Fy(ttyout/tab-delay0)o FC(,)h(86)365 +3612 y Fy(ttyout/tab-delay1)o FC(,)g(86)365 3712 y Fy +(ttyout/tab-delay2)o FC(,)g(86)365 3812 y Fy(ttyout/tab-delayx)o +FC(,)g(86)365 3912 y Fy(ttyout/uppercase)p FC(,)f(85)365 +4011 y Fy(ttyout/vtab-delay)o FC(,)h(86)365 4111 y Fy +(ttyout/vtab-delay)o(0)p FC(,)f(86)365 4211 y Fy(ttyout/vtab-delay)o(1) +p FC(,)g(86)365 4399 y Fy(umask)p FC(,)19 b(59)365 4499 +y Fy(unix-address->soc)o(ke)o(t-a)o(dd)o(res)o(s)p FC(,)697 +4599 y(92)365 4698 y Fy(unlock-region)p FC(,)c(39)365 +4798 y Fy(user-effective-gi)o(d)p FC(,)f(60)365 4898 +y Fy(user-effective-ui)o(d)p FC(,)g(60)1943 614 y Fy(user-gid)p +FC(,)j(60)1943 714 y(user)o(-info,)j(61)1943 814 y(user)o(-info:gid,)f +(61)1943 913 y(user)o(-info:home-dir)-6 b(,)19 b(61)1943 +1013 y(user)o(-info:name,)g(61)1943 1112 y(user)o(-info:shell,)h(61) +1943 1212 y(user)o(-info:uid,)f(61)1943 1312 y Fy(user-login-name)p +FC(,)14 b(60)1943 1411 y Fy(user-supplementa)o(ry)o(-g)o(ids)o +FC(,)h(60)1943 1511 y Fy(user-uid)p FC(,)i(60)1943 1694 +y Fy(wait)p FC(,)i(57)1943 1793 y Fy(wait-any)p FC(,)e(57)1943 +1893 y Fy(wait-process-gro)o(up)o FC(,)e(58)1943 1993 +y Fy(with-current-inp)o(ut)o(-p)o(ort)o FC(,)g(24)1943 +2092 y Fy(with-current-inp)o(ut)o(-p)o(ort)o(*)p FC(,)f(24)1943 +2192 y Fy(with-current-out)o(pu)o(t-)o(por)o(t)p FC(,)g(24)1943 +2291 y Fy(with-current-out)o(pu)o(t-)o(por)o(t*)o FC(,)h(24)1943 +2391 y Fy(with-cwd)p FC(,)i(59)1943 2491 y Fy(with-cwd*)p +FC(,)g(59)1943 2590 y Fy(with-enabled-int)o(er)o(ru)o(pts)o +FC(,)e(66)1943 2690 y Fy(with-enabled-int)o(er)o(ru)o(pts)o(*)p +FC(,)f(66)1943 2790 y Fy(with-env)p FC(,)j(74)1943 2889 +y Fy(with-env*)p FC(,)g(74)1943 2989 y Fy(with-errno-handl)o(er)o +FC(,)e(22)1943 3088 y Fy(with-errno-handl)o(er)o(*)p +FC(,)f(22)1943 3188 y Fy(with-error-outpu)o(t-)o(po)o(rt)p +FC(,)g(24)1943 3288 y Fy(with-error-outpu)o(t-)o(po)o(rt*)o +FC(,)h(24)1943 3387 y Fy(with-region-lock)o FC(,)g(39)1943 +3487 y Fy(with-region-lock)o(*)p FC(,)f(39)1943 3587 +y Fy(with-stdio-ports)o FC(,)h(26)1943 3686 y Fy(with-stdio-ports)o(*)p +FC(,)f(26)1943 3786 y Fy(with-total-env)p FC(,)g(74)1943 +3885 y Fy(with-total-env*)p FC(,)g(74)1943 3985 y Fy(with-umask)p +FC(,)i(59)1943 4085 y Fy(with-umask*)p FC(,)g(59)1943 +4184 y Fy(write-string)p FC(,)f(35)1943 4284 y Fy(write-string/par)o +(ti)o(al)o FC(,)g(36)1735 5147 y(161)p eop +%%Trailer +end +userdict /end-hook known{end-hook}if +%%EOF