diff --git a/basis/io/launcher/launcher.factor b/basis/io/launcher/launcher.factor old mode 100644 new mode 100755 index cb20f78a33..3999a026c0 --- a/basis/io/launcher/launcher.factor +++ b/basis/io/launcher/launcher.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: system kernel namespaces strings hashtables sequences assocs combinators vocabs.loader init threads continuations math accessors @@ -127,16 +127,17 @@ M: process-was-killed error. "Launch descriptor:" print nl process>> . ; -: wait-for-process ( process -- status ) +: (wait-for-process) ( process -- status ) + dup handle>> [ - dup handle>> - [ - dup [ processes get at push ] curry - "process" suspend drop - ] when - dup killed>> - [ process-was-killed ] [ status>> ] if - ] with-timeout ; + dup [ processes get at push ] curry + "process" suspend drop + ] when + dup killed>> + [ process-was-killed ] [ status>> ] if ; + +: wait-for-process ( process -- status ) + [ (wait-for-process) ] with-timeout ; : run-detached ( desc -- process ) >process @@ -264,7 +265,7 @@ M: output-process-error error. +stdout+ >>stderr [ +closed+ or ] change-stdin utf8 - [ stream-contents ] [ dup wait-for-process ] bi* + [ [ stream-contents ] [ dup (wait-for-process) ] bi* ] with-timeout 0 = [ 2drop ] [ output-process-error ] if ; : notify-exit ( process status -- ) diff --git a/basis/io/launcher/windows/nt/nt-tests.factor b/basis/io/launcher/windows/nt/nt-tests.factor old mode 100644 new mode 100755 index 85999a89f7..c97c411d2c --- a/basis/io/launcher/windows/nt/nt-tests.factor +++ b/basis/io/launcher/windows/nt/nt-tests.factor @@ -23,6 +23,20 @@ IN: io.launcher.windows.nt.tests [ f ] [ "notepad" get process-running? ] unit-test +[ + + "notepad" >>command + 1/2 seconds >>timeout + try-process +] must-fail + +[ + + "notepad" >>command + 1/2 seconds >>timeout + try-output-process +] must-fail + : console-vm ( -- path ) vm ".exe" ?tail [ ".com" append ] when ;