 <PRIVATE
 
 SYMBOL: wait-flag
+SYMBOL: wait-delay
 
 : wait-loop ( -- )
-    processes get assoc-empty?
-    [ wait-flag get-global lower-flag ]
-    [ (wait-for-processes) [ 100 milliseconds sleep ] when ] if ;
+    processes get assoc-empty? [
+        5 wait-delay set-global
+        wait-flag get-global lower-flag
+    ] [
+        (wait-for-processes) [
+            wait-delay [
+                [ milliseconds sleep ] [ 5 + 100 max ] bi
+            ] change-global
+        ] when
+    ] if ;
 
 : start-wait-thread ( -- )
     <flag> wait-flag set-global
+    5 wait-delay set-global
     [ wait-loop t ] "Process wait" spawn-server drop ;
 
 [

USING: accessors assocs calendar combinators concurrency.flags
debugger destructors environment fry init io io.backend
io.encodings io.encodings.utf8 io.pipes io.pipes.private
io.ports io.streams.duplex io.timeouts kernel namespaces
prettyprint sequences strings system threads vocabs ;

IN: io.launcher


    [ [ stream-contents ] [ dup (wait-for-process) ] bi* ] with-timeout
    0 = [ 2drop ] [ output-process-error ] if ;

{
    { [ os unix? ] [ "io.launcher.unix" require ] }
    { [ os windows? ] [ "io.launcher.windows" require ] }
