guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 29/32: shepherd: Gracefully handle failure to open the socket


From: Ludovic Courtès
Subject: [shepherd] 29/32: shepherd: Gracefully handle failure to open the socket.
Date: Wed, 30 Mar 2022 11:01:33 -0400 (EDT)

civodul pushed a commit to branch master
in repository shepherd.

commit e9616abaad176ffa32e6104a1ab90805528af534
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Mar 28 23:10:03 2022 +0200

    shepherd: Gracefully handle failure to open the socket.
    
    Previously 'shepherd' would just show a backtrace and hang because other
    fibers would still be running.
    
    * modules/shepherd.scm (call-with-server-socket): Catch 'system-error'
    around 'open-server-socket' call.
---
 modules/shepherd.scm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index 63a0a2c..80ce642 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -72,7 +72,18 @@ delimited continuations and fibers."
 (define (call-with-server-socket file-name proc)
   "Call PROC, passing it a listening socket at FILE-NAME and deleting the
 socket file at FILE-NAME upon exit of PROC.  Return the values of PROC."
-  (let ((sock (open-server-socket file-name)))
+  (let ((sock (catch 'system-error
+                (lambda ()
+                  (open-server-socket file-name))
+                (lambda args
+                  (match args
+                    ((key proc . _)
+                     (report-error (l10n "while opening socket '~a': ~a: ~a~%")
+                                   file-name proc
+                                   (strerror (system-error-errno args)))
+                     ;; Stop services that were started from the config file
+                     ;; and quit.
+                     (stop 'root)))))))
     (unwind-protect (proc sock)
                     (begin
                       (close sock)



reply via email to

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