diff --git a/src/components/input.lisp b/src/components/input.lisp index 6e95a7d..ce237cc 100644 --- a/src/components/input.lisp +++ b/src/components/input.lisp @@ -74,9 +74,11 @@ (sb-sys:with-pinned-objects (buf) (let ((sap (sb-sys:vector-sap buf))) (if timeout-ms - (progn (sb-unix:unix-simple-poll fd :input timeout-ms) - (let ((n (sb-unix:unix-read fd sap 1))) - (if (= n 1) (aref buf 0) (values nil :eof)))) + ;; Poll first: only read if data is ready + (if (sb-unix:unix-simple-poll fd :input timeout-ms) + (let ((n (sb-unix:unix-read fd sap 1))) + (if (= n 1) (aref buf 0) (values nil :eof))) + nil) (let ((n (sb-unix:unix-read fd sap 1))) (if (= n 1) (aref buf 0) (values nil :eof))))))))