From e11708aba0fbafd4c83273ee1fa5147e54d1c80e Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Mon, 26 Mar 2018 14:49:18 +1100 Subject: [PATCH 2/3] Remove EINTR-safe, and all references to it. * modules/shepherd/support.scm (EINTR-safe): Remove procedure and its export. * modules/shepherd/service.scm (system*, system*): Remove now-unnecessary procedures. (waitpid*): Remove references to EINTR-safe. * modules/shepherd.scm (main): Remove references to EINTR-safe. --- modules/shepherd.scm | 7 +------ modules/shepherd/service.scm | 35 +++++++++++++---------------------- modules/shepherd/support.scm | 14 -------------- 3 files changed, 14 insertions(+), 42 deletions(-) diff --git a/modules/shepherd.scm b/modules/shepherd.scm index fede338..5d97598 100644 --- a/modules/shepherd.scm +++ b/modules/shepherd.scm @@ -241,12 +241,7 @@ ;; Get commands from the standard input port. (process-textual-commands (current-input-port)) ;; Process the data arriving at a socket. - (let ((sock (open-server-socket socket-file)) - - ;; With Guile <= 2.0.9, we can get a system-error exception for - ;; EINTR, which happens anytime we receive a signal, such as - ;; SIGCHLD. Thus, wrap the 'accept' call. - (accept (EINTR-safe accept))) + (let ((sock (open-server-socket socket-file))) ;; Possibly write out our PID, which means we're ready to accept ;; connections. XXX: What if we daemonized already? diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm index 7b062a1..93d3779 100644 --- a/modules/shepherd/service.scm +++ b/modules/shepherd/service.scm @@ -590,13 +590,6 @@ results." (apply action service the-action args)) which-services)))) -;; EINTR-safe versions of 'system' and 'system*'. - -(define system* - (EINTR-safe (@ (guile) system*))) - -(define system - (EINTR-safe (@ (guile) system))) @@ -981,21 +974,19 @@ returned in unspecified." (hashq-ref %services name '())) (define waitpid* - (let ((waitpid (EINTR-safe waitpid))) - (lambda (what flags) - "Like 'waitpid', but EINTR-safe, and return (0 . _) when there's no -child left." - (catch 'system-error - (lambda () - (waitpid what flags)) - (lambda args - ;; Did we get ECHILD or something? If we did, that's a problem, - ;; because this procedure is supposed to be called only upon - ;; SIGCHLD. - (let ((errno (system-error-errno args))) - (local-output "warning: 'waitpid' ~a failed unexpectedly: ~a" - what (strerror errno)) - '(0 . #f))))))) + (lambda (what flags) + "Like 'waitpid', and return (0 . _) when there's no child left." + (catch 'system-error + (lambda () + (waitpid what flags)) + (lambda args + ;; Did we get ECHILD or something? If we did, that's a problem, + ;; because this procedure is supposed to be called only upon + ;; SIGCHLD. + (let ((errno (system-error-errno args))) + (local-output "warning: 'waitpid' ~a failed unexpectedly: ~a" + what (strerror errno)) + '(0 . #f)))))) (define (handle-SIGCHLD signum) "Handle SIGCHLD, possibly by respawning the service that just died, or diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm index 380866e..9f02719 100644 --- a/modules/shepherd/support.scm +++ b/modules/shepherd/support.scm @@ -30,7 +30,6 @@ catch-system-error with-system-error-handling - EINTR-safe with-atomic-file-output mkdir-p with-directory-excursion @@ -127,19 +126,6 @@ turned into user error messages." (lambda () body ...))) -(define (EINTR-safe proc) - "Wrap PROC so that if a 'system-error' exception with EINTR is raised (that -was possible up to Guile 2.0.9 included) the call to PROC is restarted." - (lambda args - (let loop () - (catch 'system-error - (lambda () - (apply proc args)) - (lambda args - (if (= EINTR (system-error-errno args)) - (loop) - (apply throw args))))))) - (define (with-atomic-file-output file proc) ;copied from Guix "Call PROC with an output port for the file that is going to replace FILE. Upon success, FILE is atomically replaced by what has been written to the -- 2.16.2