Add BROKEN-PIPE condition.

This commit is contained in:
Stas Boukarev 2019-01-03 16:28:42 +03:00
parent 04a38c3d1e
commit 0c9c598d38
4 changed files with 15 additions and 4 deletions

View file

@ -1141,6 +1141,8 @@ possibly temporarily, because it might be used internally."
"STREAM-ERROR-POSITION-INFO"
"TRY-RESTART"
"BROKEN-PIPE"
;; error-signalling facilities
"STANDARD-READTABLE-MODIFIED-ERROR"
"STANDARD-PPRINT-DISPATCH-TABLE-MODIFIED-ERROR"
@ -3030,7 +3032,8 @@ no guarantees of interface stability."
"ENOTCONN" "ENOTEMPTY" "ENOTSOCK" "ENOTTY" "ENXIO"
"EOPNOTSUPP" "EPERM" "EPFNOSUPPORT" "EPIPE" "EPROCLIM"
"EPROTONOSUPPORT" "EPROTOTYPE" "ERANGE" "EREMOTE"
"ERESTART" "EROFS" "ESHUTDOWN" "ESOCKTNOSUPPORT" "ESPIPE"
"ERESTART" "EROFS" "ESHUTDOWN" "ESOCKTNOSUPPORT"
"EPIPE" "ESPIPE"
"ESRCH" "ESUCCESS" "ETIMEDOUT" "ETOOMANYREFS" "ETXTBSY"
"EUSERS" "EVICEERR" "EVICEOP" "EWOULDBLOCK" "EXDEV"

View file

@ -1829,8 +1829,10 @@ the restart does not exist."))
(define-condition file-does-not-exist (simple-file-error) ())
(define-condition delete-file-error (simple-file-error) ())
(define-condition simple-stream-error (simple-condition stream-error) ())
(define-condition simple-parse-error (simple-condition parse-error) ())
(define-condition simple-stream-error (simple-condition stream-error) ())
(define-condition simple-parse-error (simple-condition parse-error) ())
(define-condition broken-pipe (simple-stream-error) ())
(define-condition character-coding-error (error)
((external-format :initarg :external-format :reader character-coding-error-external-format)))

View file

@ -443,10 +443,15 @@
element-type output, the kind of buffering, the function name, and the number
of bytes per element.")
(defun stream-errno-to-condition (errno)
(case errno
(#.sb-unix:epipe 'broken-pipe)
(t 'simple-stream-error)))
;;; common idioms for reporting low-level stream and file problems
(defun simple-stream-perror (format-control stream &optional errno &rest format-arguments)
(declare (optimize allow-non-returning-tail-call))
(error 'simple-stream-error
(error (stream-errno-to-condition errno)
:stream stream
:format-control "~@<~?~@[: ~2I~_~A~]~:>"
:format-arguments (list format-control

View file

@ -218,6 +218,7 @@ main(int argc, char __attribute__((unused)) *argv[])
deferrno("eio", EIO);
deferrno("eexist", EEXIST);
deferrno("eloop", ELOOP);
deferrno("epipe", EPIPE);
deferrno("espipe", ESPIPE);
deferrno("ewouldblock", EWOULDBLOCK);
printf("\n");