io.backend.unix: make timeouts work on stdin once Doug fixes alarms

db4
Slava Pestov 2010-05-21 19:09:15 -04:00
parent 0e496c8693
commit 949712243f
1 changed files with 7 additions and 2 deletions
basis/io/backend/unix

View 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 ;