~ chicken-core (master) 9e0330f75fc83dd2d4ea269f0ff2323e6a9508ad


commit 9e0330f75fc83dd2d4ea269f0ff2323e6a9508ad
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Sun Nov 1 19:53:27 2026 +0100
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Sun Nov 1 19:53:27 2026 +0100

    flush + close for file ports handle EINTR and retry

diff --git a/library.scm b/library.scm
index a2f3af8c..498a3548 100644
--- a/library.scm
+++ b/library.scm
@@ -4348,17 +4348,24 @@ EOF
              (lambda (bv start len)
                (##core#inline "C_display_string" p bv start len))))
           (lambda (p d)                ; close
-            (unless (##core#inline "C_close_file" p)
-              (##sys#signal-hook/errno
-                #:file-error (##sys#update-errno) 'close-output-port
-                (##sys#string-append "error while closing port - " strerror)
-                p)))
+            (let loop ()
+              (unless (##core#inline "C_close_file" p)
+                (if (eq? err (foreign-value "EINTR" int))
+                    (##sys#dispatch-interrupt loop)
+                    (##sys#signal-hook/errno
+                      #:file-error (##sys#update-errno) 'close-output-port
+                      (##sys#string-append "error while closing port - " strerror)
+                      p)))))
           (lambda (p)      ; flush-output
-            (unless (##core#inline "C_flush_output" p)
-              (##sys#signal-hook/errno
-                #:file-error (##sys#update-errno) 'flush-output-port
-                (##sys#string-append "error while flushing output port - " strerror)
-                p)))
+            (let loop ()
+              (unless (##core#inline "C_flush_output" p)
+                (let ((err (##sys#update-errno)))
+                  (if (eq? err (foreign-value "EINTR" int))
+                      (##sys#dispatch-interrupt loop)
+                      (##sys#signal-hook/errno
+                        #:file-error err 'flush-output-port
+                        (##sys#string-append "error while flushing output port - " strerror)
+                        p))))))
           (lambda (p)      ; u8-ready?
             (or (##sys#slot p 10)
                 (##core#inline "C_char_ready_p" p) ))
Trap