[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 01/01: shepherd: Ignore reboot(2) errors in containers.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 01/01: shepherd: Ignore reboot(2) errors in containers. |
Date: |
Wed, 26 Sep 2018 16:50:38 -0400 (EDT) |
civodul pushed a commit to branch master
in repository shepherd.
commit 92e806bac1abaeeaf5d60f0ab50d1ae85ba6a62f
Author: Ludovic Courtès <address@hidden>
Date: Wed Sep 26 22:27:40 2018 +0200
shepherd: Ignore reboot(2) errors in containers.
* modules/shepherd.scm (main): Ignore EINVAL and EPERM raised by
'disable-reboot-on-ctrl-alt-del'.
---
modules/shepherd.scm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index 628267b..e241e7a 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -219,7 +219,16 @@
;; When running as PID 1, disable hard reboots upon ctrl-alt-del.
;; Instead, the kernel will send us SIGINT so that we can gracefully
;; shut down. See ctrlaltdel(8) and kernel/reboot.c.
- (disable-reboot-on-ctrl-alt-del))
+ (catch 'system-error
+ (lambda ()
+ (disable-reboot-on-ctrl-alt-del))
+ (lambda args
+ (let ((err (system-error-errno args)))
+ ;; When in a separate PID namespace, we get EINVAL (see
+ ;; 'reboot_pid_ns' in kernel/pid_namespace.c.) We get EPERM in
+ ;; a user namespace that lacks CAP_SYS_BOOT.
+ (unless (member err (list EINVAL EPERM))
+ (apply throw args))))))
;; Stop everything when we get SIGINT.
(sigaction SIGINT