<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div><blockquote type="cite"><span class="Apple-style-span" style="font-family: monospace; ">You have a synchronization problem.  The copy-port within foo starts<br>reading the input file stream and hits EOF before the copy-port within<br>the separate thread starts writing to the file.</span></blockquote></div><div><br></div><div>David Pierson, you're absolutely right. This is exactly the problem with my hacky solution, which your (sleep 1) addition sort of solves.</div><div><br></div><div><blockquote type="cite"><div>Vlad, are you looking for pipes? </div></blockquote><br></div><div>Matthias, I'm trying re-create unix shell pipe behavior, but where you can splice Racket code wrapped in (begin ..) as part of the pipeline: every element in the pipe reads from (current-input-port). (subprocess ..) that I was using to run external binaries strictly expects file-stream-ports. In Racket however my 'pipe' form can be parametrized over any kind of input/output port: string, result of</div><div>(make-pipe), etc. Hence the need to somehow wrap the input ports.</div><div><br></div><div>More insight came courtesy of #racket irc particularly Jens Axel Søgaard. As was pointed out to me process*/ports could be just what I was looking for and I should be using it in place of (subprocess ..). Cursory glance at the <a href="https://github.com/plt/racket/blob/master/racket/collects/racket/system.rkt">source code for process*/ports</a> reveals that it calls the subprocess and does exactly the port manipulation magic I was looking for. I don't pretend to understand the code since I'm yet to learn concurrent programming in Racket, but <a href="https://groups.google.com/forum/#!topic/racket-users/6GvjIbndNt8">this answer by Matthew Flatt</a> seems to support my understanding.</div><div><br></div><div><blockquote type="cite"><span class="Apple-style-span" style="font-family: monospace; ">#lang racket<br>(define (make-file-stream-input-port in-port)<br> (if (file-stream-port? in-port)<br>     in-port<br>     (match (process*/ports #f in-port 'stdout "/bin/cat")<br>       ((list stdout-in-port #f pid #f proc)<br>        stdout-in-port))))</span></blockquote></div><div><br></div><div>David Pierson, calling external "cat" to fake what essentially is copying one port onto another won't cut it (pun intended) :) I hope the guts of process*/ports will provide the solution. But the behavior of your code is exactly what I need. </div><div><br></div><div apple-content-edited="true">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><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></div>
</div>
<br><div><div>On Nov 13, 2013, at 8:58 AM, Matthias Felleisen wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On Nov 12, 2013, at 11:55 PM, David T. Pierson <<a href="mailto:dtp@mindstory.com">dtp@mindstory.com</a>> wrote:<br><br><blockquote type="cite">Do you really need a file stream port and not just an input port?  <br></blockquote><br>Vlad, are you looking for pipes? <br><br></div></blockquote></div><br></body></html>