Fixing bugs
parent
75fb15ee4c
commit
8397b45110
|
@ -4,7 +4,7 @@ USING: io io.backend io.timeouts io.pipes system kernel
|
|||
namespaces strings hashtables sequences assocs combinators
|
||||
vocabs.loader init threads continuations math io.encodings
|
||||
io.streams.duplex io.nonblocking io.streams.duplex accessors
|
||||
concurrency.flags locals destructors ;
|
||||
concurrency.flags destructors ;
|
||||
IN: io.launcher
|
||||
|
||||
TUPLE: process < identity-tuple
|
||||
|
@ -146,56 +146,53 @@ M: process set-timeout set-process-timeout ;
|
|||
|
||||
M: process timed-out kill-process ;
|
||||
|
||||
:: <process-reader*> ( process encoding -- process stream )
|
||||
: <process-reader*> ( process encoding -- process stream )
|
||||
[
|
||||
(pipe) {
|
||||
>r (pipe) {
|
||||
[ add-error-destructor ]
|
||||
[
|
||||
process >process
|
||||
swap >process
|
||||
[ swap out>> or ] change-stdout
|
||||
run-detached
|
||||
]
|
||||
[ out>> close-handle ]
|
||||
[ in>> <reader> encoding <decoder> ]
|
||||
} cleave
|
||||
[ in>> <reader> ]
|
||||
} cleave r> <decoder>
|
||||
] with-destructors ;
|
||||
|
||||
: <process-reader> ( desc encoding -- stream )
|
||||
<process-reader*> nip ; inline
|
||||
|
||||
:: <process-writer*> ( process encoding -- process stream )
|
||||
: <process-writer*> ( process encoding -- process stream )
|
||||
[
|
||||
(pipe) {
|
||||
>r (pipe) {
|
||||
[ add-error-destructor ]
|
||||
[
|
||||
process >process
|
||||
swap >process
|
||||
[ swap in>> or ] change-stdout
|
||||
run-detached
|
||||
]
|
||||
[ in>> close-handle ]
|
||||
[ out>> <writer> encoding <encoder> ]
|
||||
} cleave
|
||||
[ out>> <writer> ]
|
||||
} cleave r> <encoder>
|
||||
] with-destructors ;
|
||||
|
||||
: <process-writer> ( desc encoding -- stream )
|
||||
<process-writer*> nip ; inline
|
||||
|
||||
:: <process-stream*> ( process encoding -- process stream )
|
||||
: <process-stream*> ( process encoding -- process stream )
|
||||
[
|
||||
(pipe) (pipe) {
|
||||
>r (pipe) (pipe) {
|
||||
[ [ add-error-destructor ] bi@ ]
|
||||
[
|
||||
process >process
|
||||
rot >process
|
||||
[ swap out>> or ] change-stdout
|
||||
[ swap in>> or ] change-stdin
|
||||
run-detached
|
||||
]
|
||||
[ [ in>> close-handle ] [ out>> close-handle ] bi* ]
|
||||
[
|
||||
[ in>> <reader> ] [ out>> <writer> ] bi*
|
||||
encoding <encoder-duplex>
|
||||
]
|
||||
} 2cleave
|
||||
[ [ in>> <reader> ] [ out>> <writer> ] bi* ]
|
||||
} 2cleave r> <encoder-duplex>
|
||||
] with-destructors ;
|
||||
|
||||
: <process-stream> ( desc encoding -- stream )
|
||||
|
|
|
@ -8,30 +8,29 @@ IN: io.pipes
|
|||
|
||||
TUPLE: pipe in out ;
|
||||
|
||||
: close-pipe ( pipe -- )
|
||||
[ in>> ] [ out>> ] bi 2array dispose-each ;
|
||||
M: pipe dispose ( pipe -- )
|
||||
[ in>> close-handle ] [ out>> close-handle ] bi ;
|
||||
|
||||
HOOK: (pipe) io-backend ( -- pipe )
|
||||
|
||||
:: <pipe> ( encoding -- input-stream output-stream )
|
||||
[
|
||||
(pipe)
|
||||
[ [ close-later ] each ]
|
||||
[
|
||||
[ in>> <reader> encoding <decoder> ]
|
||||
[ out>> <writer> encoding <encoder> ] bi
|
||||
] bi
|
||||
[ add-error-destructor ]
|
||||
[ in>> <reader> encoding <decoder> ]
|
||||
[ out>> <writer> encoding <encoder> ]
|
||||
tri
|
||||
] with-destructors ;
|
||||
|
||||
:: with-fds ( input-fd output-fd quot encoding -- )
|
||||
input-fd [ <reader> encoding <decoder> dup add-always-destructor ] [ input-stream get ] if* [
|
||||
output-fd [ <writer> encoding <encoder> dup add-always-destructor ] [ output-stream get ] if*
|
||||
quot with-output-stream
|
||||
] with-input-stream ; inline
|
||||
quot with-output-stream*
|
||||
] with-input-stream* ; inline
|
||||
|
||||
: <pipes> ( n -- pipes )
|
||||
[ (pipe) dup [ close-later ] each ] replicate
|
||||
{ f f } [ prefix ] [ suffix ] bi
|
||||
[ (pipe) dup add-error-destructor ] replicate
|
||||
f f pipe boa [ prefix ] [ suffix ] bi
|
||||
2 <sliding-groups> ;
|
||||
|
||||
: with-pipe-fds ( seq -- results )
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
USING: io.files io.sockets io kernel threads
|
||||
namespaces tools.test continuations strings byte-arrays
|
||||
sequences prettyprint system io.encodings.binary io.encodings.ascii ;
|
||||
sequences prettyprint system io.encodings.binary io.encodings.ascii
|
||||
io.streams.duplex ;
|
||||
IN: io.unix.tests
|
||||
|
||||
! Unix domain stream sockets
|
||||
|
|
Loading…
Reference in New Issue