io.launcher: since process timeouts only kick in when wait-for-process is called, try-output-process would hang indefinitely. Fix this by splitting up wait-for-process and wrapping stream-contents in a with-timeout
parent
098ef42202
commit
790c7afeaf
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008, 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: system kernel namespaces strings hashtables sequences assocs
|
USING: system kernel namespaces strings hashtables sequences assocs
|
||||||
combinators vocabs.loader init threads continuations math accessors
|
combinators vocabs.loader init threads continuations math accessors
|
||||||
|
@ -127,16 +127,17 @@ M: process-was-killed error.
|
||||||
"Launch descriptor:" print nl
|
"Launch descriptor:" print nl
|
||||||
process>> . ;
|
process>> . ;
|
||||||
|
|
||||||
: wait-for-process ( process -- status )
|
: (wait-for-process) ( process -- status )
|
||||||
|
dup handle>>
|
||||||
[
|
[
|
||||||
dup handle>>
|
dup [ processes get at push ] curry
|
||||||
[
|
"process" suspend drop
|
||||||
dup [ processes get at push ] curry
|
] when
|
||||||
"process" suspend drop
|
dup killed>>
|
||||||
] when
|
[ process-was-killed ] [ status>> ] if ;
|
||||||
dup killed>>
|
|
||||||
[ process-was-killed ] [ status>> ] if
|
: wait-for-process ( process -- status )
|
||||||
] with-timeout ;
|
[ (wait-for-process) ] with-timeout ;
|
||||||
|
|
||||||
: run-detached ( desc -- process )
|
: run-detached ( desc -- process )
|
||||||
>process
|
>process
|
||||||
|
@ -264,7 +265,7 @@ M: output-process-error error.
|
||||||
+stdout+ >>stderr
|
+stdout+ >>stderr
|
||||||
[ +closed+ or ] change-stdin
|
[ +closed+ or ] change-stdin
|
||||||
utf8 <process-reader*>
|
utf8 <process-reader*>
|
||||||
[ stream-contents ] [ dup wait-for-process ] bi*
|
[ [ stream-contents ] [ dup (wait-for-process) ] bi* ] with-timeout
|
||||||
0 = [ 2drop ] [ output-process-error ] if ;
|
0 = [ 2drop ] [ output-process-error ] if ;
|
||||||
|
|
||||||
: notify-exit ( process status -- )
|
: notify-exit ( process status -- )
|
||||||
|
|
|
@ -23,6 +23,20 @@ IN: io.launcher.windows.nt.tests
|
||||||
|
|
||||||
[ f ] [ "notepad" get process-running? ] unit-test
|
[ f ] [ "notepad" get process-running? ] unit-test
|
||||||
|
|
||||||
|
[
|
||||||
|
<process>
|
||||||
|
"notepad" >>command
|
||||||
|
1/2 seconds >>timeout
|
||||||
|
try-process
|
||||||
|
] must-fail
|
||||||
|
|
||||||
|
[
|
||||||
|
<process>
|
||||||
|
"notepad" >>command
|
||||||
|
1/2 seconds >>timeout
|
||||||
|
try-output-process
|
||||||
|
] must-fail
|
||||||
|
|
||||||
: console-vm ( -- path )
|
: console-vm ( -- path )
|
||||||
vm ".exe" ?tail [ ".com" append ] when ;
|
vm ".exe" ?tail [ ".com" append ] when ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue