mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-13 23:20:32 +02:00
* tests/ports.test (non-blocking-I/O): a couple more details:
a) combine the O_NONBLOCK flag with the default flags instead of replacing them. b) check EWOULDBLOCK as well as EAGAIN.
This commit is contained in:
parent
cffcab3013
commit
8cc58ec1cc
1 changed files with 6 additions and 4 deletions
|
@ -195,18 +195,20 @@
|
||||||
(string=? (read-line) "moon")))))
|
(string=? (read-line) "moon")))))
|
||||||
|
|
||||||
;;; non-blocking mode on a port. create a pipe and set O_NONBLOCK on
|
;;; non-blocking mode on a port. create a pipe and set O_NONBLOCK on
|
||||||
;;; the reading end. try to read a byte: should get EAGAIN error.
|
;;; the reading end. try to read a byte: should get EAGAIN or
|
||||||
|
;;; EWOULDBLOCK error.
|
||||||
(catch-test-errors
|
(catch-test-errors
|
||||||
(let* ((p (pipe))
|
(let* ((p (pipe))
|
||||||
(r (car p)))
|
(r (car p)))
|
||||||
(fcntl r F_SETFL O_NONBLOCK)
|
(fcntl r F_SETFL (logior (fcntl r F_GETFL) O_NONBLOCK))
|
||||||
(pass-if "non-blocking-I/O"
|
(pass-if "non-blocking-I/O"
|
||||||
(catch 'system-error
|
(catch 'system-error
|
||||||
(lambda () (read-char r) #f)
|
(lambda () (read-char r) #f)
|
||||||
(lambda (key . args)
|
(lambda (key . args)
|
||||||
(and (eq? key 'system-error)
|
(and (eq? key 'system-error)
|
||||||
(= (car (list-ref args 3)) EAGAIN)))))))
|
(let ((errno (car (list-ref args 3))))
|
||||||
|
(or (= errno EAGAIN)
|
||||||
|
(= errno EWOULDBLOCK)))))))))
|
||||||
|
|
||||||
;;;; Pipe (popen) ports.
|
;;;; Pipe (popen) ports.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue