From d222c8aefb16abce388969f76bf1d2379497b148 Mon Sep 17 00:00:00 2001 From: mainzelm Date: Wed, 5 Apr 2006 07:18:39 +0000 Subject: [PATCH] Deal with tty's that return EIO on EOF (e.g. on Linux) --- scheme/console.scm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scheme/console.scm b/scheme/console.scm index c80dc19..fa64974 100644 --- a/scheme/console.scm +++ b/scheme/console.scm @@ -20,16 +20,29 @@ pty-in pty-out pause-channel resume-channel window terminal-buffer))) +(define (eio? condition) + (and (eq? (car condition) 'exception) + (eq? (list-ref condition 2) 'os-error) + (= (list-ref condition 3) errno/io))) + +(define (read-char-pty pty) + (with-fatal-error-handler + (lambda (condition more) + (if (eio? condition) + (eof-object) + (more))) + (read-char pty))) + (define (make-channel-for-pty-out pty) (let ((channel (make-channel))) (spawn (lambda () (debug-message "make-channel-for-pty-out " pty) - (let lp ((c (read-char pty))) + (let lp ((c (read-char-pty pty))) (if (not (eof-object? c)) (begin (send channel c) - (lp (read-char pty))))))) + (lp (read-char-pty pty))))))) channel)) (define (spawn-console-loop