diff --git a/basis/io/backend/unix/unix.factor b/basis/io/backend/unix/unix.factor index f210180517..1a52ce6f34 100644 --- a/basis/io/backend/unix/unix.factor +++ b/basis/io/backend/unix/unix.factor @@ -173,10 +173,11 @@ M: stdin refill size-read-fd init-fd >>size data-read-fd >>data ; -M: unix (init-stdio) +M: unix init-stdio 1 - 2 t ; + 2 + set-stdio ; ! mx io-task for embedding an fd-based mx inside another mx TUPLE: mx-port < port mx ; diff --git a/basis/io/backend/windows/nt/nt.factor b/basis/io/backend/windows/nt/nt.factor index 4dfe02d651..c102cae8c2 100755 --- a/basis/io/backend/windows/nt/nt.factor +++ b/basis/io/backend/windows/nt/nt.factor @@ -1,9 +1,9 @@ -USING: alien alien.c-types arrays assocs combinators -continuations destructors io io.backend io.ports io.timeouts -io.backend.windows io.files.windows io.files.windows.nt io.files -io.pathnames io.buffers io.streams.c libc kernel math namespaces -sequences threads windows windows.errors windows.kernel32 -strings splitting ascii system accessors locals ; +USING: alien alien.c-types arrays assocs combinators continuations +destructors io io.backend io.ports io.timeouts io.backend.windows +io.files.windows io.files.windows.nt io.files io.pathnames io.buffers +io.streams.c io.streams.null libc kernel math namespaces sequences +threads windows windows.errors windows.kernel32 strings splitting +ascii system accessors locals ; QUALIFIED: windows.winsock IN: io.backend.windows.nt @@ -140,7 +140,9 @@ M: winnt (wait-to-read) ( port -- ) : console-app? ( -- ? ) GetConsoleWindow >boolean ; -M: winnt (init-stdio) - console-app? [ init-c-stdio t ] [ f f f f ] if ; +M: winnt init-stdio + console-app? + [ init-c-stdio ] + [ null-reader null-writer null-writer init-stdio ] if ; winnt set-io-backend diff --git a/core/io/streams/null/authors.txt b/basis/io/streams/null/authors.txt similarity index 100% rename from core/io/streams/null/authors.txt rename to basis/io/streams/null/authors.txt diff --git a/core/io/streams/null/null-docs.factor b/basis/io/streams/null/null-docs.factor similarity index 100% rename from core/io/streams/null/null-docs.factor rename to basis/io/streams/null/null-docs.factor diff --git a/core/io/streams/null/null.factor b/basis/io/streams/null/null.factor similarity index 100% rename from core/io/streams/null/null.factor rename to basis/io/streams/null/null.factor diff --git a/core/io/streams/null/summary.txt b/basis/io/streams/null/summary.txt similarity index 100% rename from core/io/streams/null/summary.txt rename to basis/io/streams/null/summary.txt diff --git a/core/io/backend/backend.factor b/core/io/backend/backend.factor index 4c91a519c6..ac3fbef8d0 100644 --- a/core/io/backend/backend.factor +++ b/core/io/backend/backend.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: init kernel system namespaces io io.encodings -io.encodings.utf8 init assocs splitting alien io.streams.null ; +io.encodings.utf8 init assocs splitting alien ; IN: io.backend SYMBOL: io-backend @@ -12,22 +12,12 @@ io-backend [ c-io-backend ] initialize HOOK: init-io io-backend ( -- ) -HOOK: (init-stdio) io-backend ( -- stdin stdout stderr ? ) +HOOK: init-stdio io-backend ( -- ) -: set-stdio ( input-handle output-handle error-handle -- ) - [ input-stream set-global ] - [ output-stream set-global ] - [ error-stream set-global ] tri* ; - -: init-stdio ( -- ) - (init-stdio) [ - [ utf8 ] - [ utf8 ] - [ utf8 ] tri* - ] [ - 3drop - null-reader null-writer null-writer - ] if set-stdio ; +: set-stdio ( input output error -- ) + [ utf8 input-stream set-global ] + [ utf8 output-stream set-global ] + [ utf8 error-stream set-global ] tri* ; HOOK: io-multiplex io-backend ( us -- ) diff --git a/core/io/streams/c/c.factor b/core/io/streams/c/c.factor index d3fd593a7b..7a7ac5a97c 100755 --- a/core/io/streams/c/c.factor +++ b/core/io/streams/c/c.factor @@ -60,12 +60,13 @@ M: c-io-backend init-io ; : stdout-handle ( -- alien ) 12 getenv ; : stderr-handle ( -- alien ) 61 getenv ; -: init-c-stdio ( -- stdin stdout stderr ) +: init-c-stdio ( -- ) stdin-handle stdout-handle - stderr-handle ; + stderr-handle + set-stdio ; -M: c-io-backend (init-stdio) init-c-stdio t ; +M: c-io-backend init-stdio init-c-stdio ; M: c-io-backend io-multiplex 60 60 * 1000 * 1000 * or (sleep) ;