[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 01/01: shepherd: Disable reboot on ctrl-alt-del before loadin
From: |
Ludovic Courtès |
Subject: |
[shepherd] 01/01: shepherd: Disable reboot on ctrl-alt-del before loading the config file. |
Date: |
Thu, 6 Jun 2019 04:04:03 -0400 (EDT) |
civodul pushed a commit to branch master
in repository shepherd.
commit c6f250d1fd1afa9ee49c8bb2414eee087b672789
Author: Ludovic Courtès <address@hidden>
Date: Thu Jun 6 10:01:15 2019 +0200
shepherd: Disable reboot on ctrl-alt-del before loading the config file.
Reported by Florian Pelz <address@hidden>
in <https://bugs.gnu.org/35996>.
* modules/shepherd.scm (main): Move 'sigaction' and
'disable-reboot-on-ctrl-alt-del' calls before 'load-in-user-module'.
This ensures a clean reboot if the user presses ctrl-alt-del before the
config file has been fully loaded (on Guix System, the config file is
fully loaded once all the services have been started).
---
modules/shepherd.scm | 56 ++++++++++++++++++++++++++--------------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index 8b2cc1d..769085a 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -198,34 +198,6 @@ socket file at FILE-NAME upon exit of PROC. Return the
values of PROC."
;; Start the 'root' service.
(start root-service)
- ;; This _must_ succeed. (We could also put the `catch' around
- ;; `main', but it is often useful to get the backtrace, and
- ;; `caught-error' does not do this yet.)
- (catch #t
- (lambda ()
- (load-in-user-module (or config-file (default-config-file))))
- (lambda (key . args)
- (caught-error key args)
- (quit 1)))
- ;; Start what was started last time.
- (and persistency
- (catch 'system-error
- (lambda ()
- (start-in-order (read (open-input-file
- persistency-state-file))))
- (lambda (key . args)
- (apply format #f (gettext (cadr args)) (caddr args))
- (quit 1))))
-
- (when (provided? 'threads)
- ;; XXX: This terrible hack allows us to make sure that signal handlers
- ;; get a chance to run in a timely fashion. Without it, after an
EINTR,
- ;; we could restart the accept(2) call below before the corresponding
- ;; async has been queued. See the thread at
- ;;
<https://lists.gnu.org/archive/html/guile-devel/2013-07/msg00004.html>.
- (sigaction SIGALRM (lambda _ (alarm 1)))
- (alarm 1))
-
(when (= 1 (getpid))
;; When running as PID 1, disable hard reboots upon ctrl-alt-del.
;; Instead, the kernel will send us SIGINT so that we can gracefully
@@ -259,6 +231,34 @@ socket file at FILE-NAME upon exit of PROC. Return the
values of PROC."
(lambda _
(stop root-service)))
+ ;; This _must_ succeed. (We could also put the `catch' around
+ ;; `main', but it is often useful to get the backtrace, and
+ ;; `caught-error' does not do this yet.)
+ (catch #t
+ (lambda ()
+ (load-in-user-module (or config-file (default-config-file))))
+ (lambda (key . args)
+ (caught-error key args)
+ (quit 1)))
+ ;; Start what was started last time.
+ (and persistency
+ (catch 'system-error
+ (lambda ()
+ (start-in-order (read (open-input-file
+ persistency-state-file))))
+ (lambda (key . args)
+ (apply format #f (gettext (cadr args)) (caddr args))
+ (quit 1))))
+
+ (when (provided? 'threads)
+ ;; XXX: This terrible hack allows us to make sure that signal handlers
+ ;; get a chance to run in a timely fashion. Without it, after an
EINTR,
+ ;; we could restart the accept(2) call below before the corresponding
+ ;; async has been queued. See the thread at
+ ;;
<https://lists.gnu.org/archive/html/guile-devel/2013-07/msg00004.html>.
+ (sigaction SIGALRM (lambda _ (alarm 1)))
+ (alarm 1))
+
;; Ignore SIGPIPE so that we don't die if a client closes the connection
;; prematurely.
(sigaction SIGPIPE SIG_IGN)