diff --git a/extra/io/launcher/launcher.factor b/extra/io/launcher/launcher.factor index 21d3757c4e..d63b2cd9c0 100755 --- a/extra/io/launcher/launcher.factor +++ b/extra/io/launcher/launcher.factor @@ -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 encoding -- process stream ) +: ( 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>> encoding ] - } cleave + [ in>> ] + } cleave r> ] with-destructors ; : ( desc encoding -- stream ) nip ; inline -:: ( process encoding -- process stream ) +: ( 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>> encoding ] - } cleave + [ out>> ] + } cleave r> ] with-destructors ; : ( desc encoding -- stream ) nip ; inline -:: ( process encoding -- 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>> ] [ out>> ] bi* - encoding - ] - } 2cleave + [ [ in>> ] [ out>> ] bi* ] + } 2cleave r> ] with-destructors ; : ( desc encoding -- stream ) diff --git a/extra/io/pipes/pipes.factor b/extra/io/pipes/pipes.factor index 241cf3e971..274d933f0d 100644 --- a/extra/io/pipes/pipes.factor +++ b/extra/io/pipes/pipes.factor @@ -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 ) :: ( encoding -- input-stream output-stream ) [ (pipe) - [ [ close-later ] each ] - [ - [ in>> encoding ] - [ out>> encoding ] bi - ] bi + [ add-error-destructor ] + [ in>> encoding ] + [ out>> encoding ] + tri ] with-destructors ; :: with-fds ( input-fd output-fd quot encoding -- ) input-fd [ encoding dup add-always-destructor ] [ input-stream get ] if* [ output-fd [ encoding dup add-always-destructor ] [ output-stream get ] if* - quot with-output-stream - ] with-input-stream ; inline + quot with-output-stream* + ] with-input-stream* ; inline : ( 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 ; : with-pipe-fds ( seq -- results ) diff --git a/extra/io/unix/unix-tests.factor b/extra/io/unix/unix-tests.factor index 3dc1f1d5fc..61a667b70f 100755 --- a/extra/io/unix/unix-tests.factor +++ b/extra/io/unix/unix-tests.factor @@ -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