guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/06: syscalls: Add 'restart-on-EINTR'.


From: Ludovic Courtès
Subject: 01/06: syscalls: Add 'restart-on-EINTR'.
Date: Fri, 22 May 2015 09:51:21 +0000

civodul pushed a commit to branch master
in repository guix.

commit ea982704430b061f263580041d4f94174d8ba5cd
Author: Ludovic Courtès <address@hidden>
Date:   Thu May 21 23:23:47 2015 +0200

    syscalls: Add 'restart-on-EINTR'.
    
    * guix/build/syscalls.scm (call-with-restart-on-EINTR): New procedure.
      (restart-on-EINTR): New macro.
---
 guix/build/syscalls.scm |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 5bc4595..9ec7e8b 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -29,6 +29,7 @@
             MS_REMOUNT
             MS_BIND
             MS_MOVE
+            restart-on-EINTR
             mount
             umount
             mount-points
@@ -89,6 +90,19 @@
             (ref bv))))
       (lambda () 0)))
 
+(define (call-with-restart-on-EINTR thunk)
+  (let loop ()
+    (catch 'system-error
+      thunk
+      (lambda args
+        (if (= (system-error-errno args) EINTR)
+            (loop)
+            (apply throw args))))))
+
+(define-syntax-rule (restart-on-EINTR expr)
+  "Evaluate EXPR and restart upon EINTR.  Return the value of EXPR."
+  (call-with-restart-on-EINTR (lambda () expr)))
+
 (define (augment-mtab source target type options)
   "Augment /etc/mtab with information about the given mount point."
   (let ((port (open-file "/etc/mtab" "a")))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]