From 949712243ffd6162ee71d5237ec6125ee67f71e8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 21 May 2010 19:09:15 -0400 Subject: [PATCH] io.backend.unix: make timeouts work on stdin once Doug fixes alarms --- basis/io/backend/unix/unix.factor | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/basis/io/backend/unix/unix.factor b/basis/io/backend/unix/unix.factor index 0e84f1b65e..972b2a5b07 100644 --- a/basis/io/backend/unix/unix.factor +++ b/basis/io/backend/unix/unix.factor @@ -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 ;