]> gitweb.factorcode.org Git - factor.git/commitdiff
unix: Ignore failures if errno is EINTR on close(2). Fixes #908.
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 7 Jul 2014 21:55:13 +0000 (14:55 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 7 Jul 2014 21:55:13 +0000 (14:55 -0700)
basis/unix/unix.factor

index 9f69d8e68361979657e44904e897add042882c4d..6108cd457e3d0bb18a2359b0a059f577a688b92d 100644 (file)
@@ -40,9 +40,29 @@ MACRO:: unix-system-call ( quot -- )
         ] if
     ] ;
 
+MACRO:: unix-system-call-allow-eintr ( quot -- )
+    quot inputs :> n
+    quot first :> word
+    0 :> ret!
+    [
+        n ndup quot call ret!
+        ret unix-call-failed? [
+            ! Bug #908
+            ! Allow EINTR for close(2)
+            errno EINTR = [
+                n narray
+                errno dup strerror
+                word unix-system-call-error
+            ] unless
+        ] [
+            n ndrop
+            ret
+        ] if
+    ] ;
+
 HOOK: open-file os ( path flags mode -- fd )
 
-: close-file ( fd -- ) [ close ] unix-system-call drop ;
+: close-file ( fd -- ) [ close ] unix-system-call-allow-eintr drop ;
 
 FUNCTION: int _exit ( int status ) ;