<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Yep, closing the port did the trick. Thanks David and Matthew. <div><br></div><div>I wonder though if this is practical in a general case. Say, I expect more data and want to grab it as it appears. Something like calling "tail -10" on a file that's being updated. I thought flushing the port would do, but it doesn't.</div><div><br></div><div>Here's an example of IO from the Guide:</div><div>---------------------------------------</div><div><table cellspacing="0" class="RktBlk" style="font-family: monospace; white-space: normal; text-align: left; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); position: static; z-index: auto; "><tbody><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><div style="display: block; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Examples:</div></td></tr><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><blockquote class="SCodeFlow" style="margin: 0em 1em; display: block; white-space: nowrap;"><table cellspacing="0" class="RktBlk" style="font-family: monospace; white-space: inherit; text-align: left; position: static; z-index: auto; "><tbody><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><span class="stt" style="font-family: monospace;">> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28quote._~23~25kernel%29._define-values%29%29" class="RktStxLink" data-pltdoc="x" style="text-decoration: none; color: black;">define-values</a></span><span class="hspace" style="font-family: monospace;"> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);">in</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);">out</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/pipeports.html#%28def._%28%28quote._~23~25kernel%29._make-pipe%29%29" class="RktValLink" data-pltdoc="x" style="text-decoration: none; color: blue;">make-pipe</a></span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span></td></tr><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><table cellspacing="0"><tbody><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"></td></tr></tbody></table></td></tr><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><span class="stt" style="font-family: monospace;">> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._write%29%29" class="RktValLink" data-pltdoc="x" style="text-decoration: none; color: blue;">write</a></span><span class="hspace" style="font-family: monospace;"> </span><span class="RktVal" style="font-family: monospace; white-space: inherit; color: rgb(34, 139, 34);">"hello"</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);">out</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span></td></tr><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><table cellspacing="0"><tbody><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"></td></tr></tbody></table></td></tr><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><span class="stt" style="font-family: monospace;">> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/Reading.html#%28def._%28%28quote._~23~25kernel%29._read%29%29" class="RktValLink" data-pltdoc="x" style="text-decoration: none; color: blue;">read</a></span><span class="hspace" style="font-family: monospace;"> </span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);">in</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span></td></tr><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><div style="display: block; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="RktRes" style="font-family: monospace; white-space: inherit; color: rgb(0, 0, 175);">"hello"</span></div></td></tr><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><span class="stt" style="font-family: monospace;">> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._write%29%29" class="RktValLink" data-pltdoc="x" style="text-decoration: none; color: blue;">write</a></span><span class="hspace" style="font-family: monospace;"> </span><span class="RktVal" style="font-family: monospace; white-space: inherit; color: rgb(34, 139, 34);">'</span><span class="RktVal" style="font-family: monospace; white-space: inherit; color: rgb(34, 139, 34);">(</span><span class="RktVal" style="font-family: monospace; white-space: inherit; color: rgb(34, 139, 34);">"alphabet"</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktVal" style="font-family: monospace; white-space: inherit; color: rgb(34, 139, 34);">soup</span><span class="RktVal" style="font-family: monospace; white-space: inherit; color: rgb(34, 139, 34);">)</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);">out</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span></td></tr><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><table cellspacing="0"><tbody><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"></td></tr></tbody></table></td></tr><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><span class="stt" style="font-family: monospace;">> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/Reading.html#%28def._%28%28quote._~23~25kernel%29._read%29%29" class="RktValLink" data-pltdoc="x" style="text-decoration: none; color: blue;">read</a></span><span class="hspace" style="font-family: monospace;"> </span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);">in</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span></td></tr><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><div style="display: block; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="RktRes" style="font-family: monospace; white-space: inherit; color: rgb(0, 0, 175);">'("alphabet" soup)</span></div></td></tr></tbody></table></blockquote></td></tr></tbody></table><div><br></div></div><div>Why does this work?</div><div><br></div><div><div apple-content-edited="true">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Andale Mono'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">---</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Vlad Kozin <<a href="mailto:vladilen.kozin@gmail.com">vladilen.kozin@gmail.com</a>><br><br><br></div></span></div>
</div>
<br><div><div>On Oct 16, 2013, at 1:36 PM, David Vanderson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On 10/16/2013 12:35 PM, Vlad Kozin wrote:<br><blockquote type="cite">assuming I have a number of .c files I expect "find" to write corresponding lines to (current-output-port). I want to collect them in a list. Here's a solution I thought would work:<br></blockquote><blockquote type="cite">------------------------------------<br></blockquote><blockquote type="cite">(define-values (in out) (make-pipe))<br></blockquote><blockquote type="cite">(parameterize ((current-output-port out))<br></blockquote><blockquote type="cite">   (system (format "find . ~a ~a" "-name \"*.c\"" "-print"))<br></blockquote><blockquote type="cite">   (for/list ((line (in-lines in)))<br></blockquote><blockquote type="cite">     line))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">It doesn't. It blocks expecting input.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Blocks again. Am I not getting EOF here?<br></blockquote><blockquote type="cite"><br></blockquote>I think you are on the right track here.  You need to close the output port on the pipe so "in-lines" stops reading:<br><br>(define-values (in out) (make-pipe))<br>(parameterize ((current-output-port out))<br>  (system (format "find . ~a ~a" "-name \"*.c\"" "-print"))<br>  (close-output-port (current-output-port))<br>  (for/list ((line (in-lines in)))<br>    line))<br><br>Does that make sense?<br><br>Alternatively you can rearrange your last example:<br><br>(define str (with-output-to-string<br>               (lambda ()<br>                 (system (format "find . ~a ~a" "-name \"*.c\"" "-print")))))<br>(for/list ((line (in-lines (open-input-string str))))<br>  line)<br><br>Thanks,<br>Dave<br></div></blockquote></div><br></div></body></html>