Hi Graham,

Your intuition about closing the input side before reading output is
correct, and the following program should, in theory, work:

USING: namespaces destructors io io.encodings.ascii
io.streams.duplex io.launcher ;

"sort" ascii <process-stream> [
    "a\nc\nb\n" write output-stream get dispose
    input-stream get contents
] with-stream

However, after testing it I discovered that <process-stream> is in
fact broken, along with <process-writer>! Oops...

Seems that <process-reader> is the only one that worked, because its
the only one that any of our 'real' code actually uses. I added some
tests for <process-stream> and fixed the problems; the latest git
should work properly with the above snippet now.

Thanks for raising this issue,

Slava

On Thu, Jul 24, 2008 at 9:01 PM, Graham Fawcett
<[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> I would like to use an external program to process some text, and the
> <process-stream> word seems to be the right choice, but I can't get it
> working. I wrote this, for example:
>
> "sort" ascii <process-stream> [ "a\nc\nb\n" write flush 1000 read ] 
> with-stream
>
> ...hoping that it would leave a string of sorted lines on the top of
> the stack. But it fails with a broken-pipe error.
>
> In other languages, I'd flush and close the input descriptor before
> trying to read from the output descriptor, and I suspect that's what's
> wrong here, but don't know how to do that on a duplex stream. Any
> suggestions?
>
> Thanks,
> Graham
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to