]> gitweb.factorcode.org Git - factor.git/commitdiff
io.backend.unix: make timeouts work on stdin once Doug fixes alarms
authorSlava Pestov <slava@CPE001ec21b1c01-CM0012c90d0486.cpe.net.cable.rogers.com>
Fri, 21 May 2010 23:09:15 +0000 (19:09 -0400)
committerSlava Pestov <slava@CPE001ec21b1c01-CM0012c90d0486.cpe.net.cable.rogers.com>
Fri, 21 May 2010 23:09:15 +0000 (19:09 -0400)
basis/io/backend/unix/unix.factor

index 0e84f1b65e522ff478cb779d93ff288bc60d6bb7..972b2a5b0743c953ebaab2ebea66a2b5806296e7 100644 (file)
@@ -144,7 +144,7 @@ M: stdin dispose*
         tri
     ] with-destructors ;
 
-: wait-for-stdin ( stdin -- n )
+: wait-for-stdin ( stdin -- size )
     [ control>> CHAR: X over io:stream-write1 io:stream-flush ]
     [ size>> ssize_t heap-size swap io:stream-read *int ]
     bi ;
@@ -160,7 +160,12 @@ M: stdin dispose*
     ] if ;
 
 M: stdin refill
-    [ buffer>> ] [ dup wait-for-stdin ] bi* refill-stdin f ;
+    '[
+        buffer>> _ dup wait-for-stdin refill-stdin f
+    ] with-timeout ;
+
+M: stdin cancel-operation
+    [ size>> ] [ control>> ] bi [ cancel-operation ] bi@ ;
 
 : control-write-fd ( -- fd ) &: control_write *uint ;