44USING: accessors assocs calendar combinators concurrency.flags
55debugger destructors environment fry init io io.backend
66io.encodings io.encodings.utf8 io.pipes io.pipes.private
7- io.ports io.streams.duplex io.timeouts kernel namespaces
8- prettyprint sequences strings system threads vocabs ;
7+ io.ports io.streams.duplex io.timeouts kernel math math.order
8+ namespaces prettyprint sequences strings system threads vocabs ;
99
1010IN: io.launcher
1111
@@ -74,14 +74,23 @@ HOOK: (wait-for-processes) io-backend ( -- ? )
7474<PRIVATE
7575
7676SYMBOL: wait-flag
77+ SYMBOL: wait-delay
7778
7879: wait-loop ( -- )
79- processes get assoc-empty?
80- [ wait-flag get-global lower-flag ]
81- [ (wait-for-processes) [ 100 milliseconds sleep ] when ] if ;
80+ processes get assoc-empty? [
81+ 5 wait-delay set-global
82+ wait-flag get-global lower-flag
83+ ] [
84+ (wait-for-processes) [
85+ wait-delay [
86+ [ milliseconds sleep ] [ 5 + 100 max ] bi
87+ ] change-global
88+ ] when
89+ ] if ;
8290
8391: start-wait-thread ( -- )
8492 <flag> wait-flag set-global
93+ 5 wait-delay set-global
8594 [ wait-loop t ] "Process wait" spawn-server drop ;
8695
8796[
@@ -94,6 +103,11 @@ SYMBOL: wait-flag
94103 V{ } clone swap processes get set-at
95104 wait-flag get-global raise-flag ;
96105
106+ : notify-exit ( process status -- )
107+ >>status
108+ [ processes get delete-at* drop [ resume ] each ] keep
109+ f >>handle drop ;
110+
97111: pass-environment? ( process -- ? )
98112 dup environment>> assoc-empty? not
99113 swap environment-mode>> +replace-environment+ eq? or ;
@@ -296,16 +310,6 @@ M: output-process-error error.
296310 [ [ stream-contents ] [ dup (wait-for-process) ] bi* ] with-timeout
297311 0 = [ 2drop ] [ output-process-error ] if ;
298312
299- <PRIVATE
300-
301- : notify-exit ( process status -- )
302- >>status
303- [ processes get delete-at* drop [ resume ] each ] keep
304- f >>handle
305- drop ;
306-
307- PRIVATE>
308-
309313{
310314 { [ os unix? ] [ "io.launcher.unix" require ] }
311315 { [ os windows? ] [ "io.launcher.windows" require ] }
0 commit comments