summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-12-03 22:36:17 +0100
committerLudovic Courtès <ludo@gnu.org>2017-12-03 23:18:53 +0100
commit4bd70904c7f555a953808a9a4f892f462ffd352f (patch)
treeb835498a88201eb248782802a22499aff29c8b9f
parentcbb76780ef5e4aed113a1065d96fd6e035f60eaf (diff)
gnu: shepherd: Avoid "Bad file descriptor" warnings.
* gnu/packages/patches/shepherd-close-fds.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/admin.scm (shepherd)[source]: Use it.
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/admin.scm3
-rw-r--r--gnu/packages/patches/shepherd-close-fds.patch36
3 files changed, 39 insertions, 1 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 9dd0ce4f8a2..434bbb016a9 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1061,6 +1061,7 @@ dist_patch_DATA = \
1061 %D%/packages/patches/scotch-test-threading.patch \ 1061 %D%/packages/patches/scotch-test-threading.patch \
1062 %D%/packages/patches/sdl-libx11-1.6.patch \ 1062 %D%/packages/patches/sdl-libx11-1.6.patch \
1063 %D%/packages/patches/seq24-rename-mutex.patch \ 1063 %D%/packages/patches/seq24-rename-mutex.patch \
1064 %D%/packages/patches/shepherd-close-fds.patch \
1064 %D%/packages/patches/shishi-fix-libgcrypt-detection.patch \ 1065 %D%/packages/patches/shishi-fix-libgcrypt-detection.patch \
1065 %D%/packages/patches/slim-session.patch \ 1066 %D%/packages/patches/slim-session.patch \
1066 %D%/packages/patches/slim-config.patch \ 1067 %D%/packages/patches/slim-config.patch \
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index d4215ead18d..221d583bb43 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -162,7 +162,8 @@ and provides a \"top-like\" mode (monitoring).")
162 version ".tar.gz")) 162 version ".tar.gz"))
163 (sha256 163 (sha256
164 (base32 164 (base32
165 "174q1qg7yg6w1hfvlfv720hr6hid4h5xzw15y3ycfpspllzldhcb")))) 165 "174q1qg7yg6w1hfvlfv720hr6hid4h5xzw15y3ycfpspllzldhcb"))
166 (patches (search-patches "shepherd-close-fds.patch"))))
166 (build-system gnu-build-system) 167 (build-system gnu-build-system)
167 (arguments 168 (arguments
168 '(#:configure-flags '("--localstatedir=/var"))) 169 '(#:configure-flags '("--localstatedir=/var")))
diff --git a/gnu/packages/patches/shepherd-close-fds.patch b/gnu/packages/patches/shepherd-close-fds.patch
new file mode 100644
index 00000000000..2078b15265d
--- /dev/null
+++ b/gnu/packages/patches/shepherd-close-fds.patch
@@ -0,0 +1,36 @@
1commit 3e346a2a84b099766ea8a3a4a4549f6172483062
2Author: Ludovic Courtès <ludo@gnu.org>
3Date: Sun Dec 3 22:30:03 2017 +0100
4
5 service: In 'exec-command', close open ports before 'execl'.
6
7 This gets rid of annoying "Bad file descriptor" warnings from shepherd.
8
9 * modules/shepherd/service.scm (exec-command): In 'loop', invoke
10 'close-port' and the ports returned by (fdes->ports i).
11
12diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
13index b2d8bc5..0ad28a0 100644
14--- a/modules/shepherd/service.scm
15+++ b/modules/shepherd/service.scm
16@@ -1,5 +1,5 @@
17 ;; service.scm -- Representation of services.
18-;; Copyright (C) 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
19+;; Copyright (C) 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
20 ;; Copyright (C) 2002, 2003 Wolfgang Järling <wolfgang@pro-linux.de>
21 ;; Copyright (C) 2014 Alex Sassmannshausen <alex.sassmannshausen@gmail.com>
22 ;; Copyright (C) 2016 Alex Kost <alezost@gmail.com>
23@@ -744,6 +744,14 @@ false."
24
25 (let loop ((i 3))
26 (when (< i max-fd)
27+ ;; First try to close any ports associated with file descriptor I.
28+ ;; Otherwise the finalization thread might get around to closing
29+ ;; those ports eventually, which will raise an EBADF exception (on
30+ ;; 2.2), leading to messages like "error in the finalization
31+ ;; thread: Bad file descriptor".
32+ (for-each (lambda (port)
33+ (catch-system-error (close-port port)))
34+ (fdes->ports i))
35 (catch-system-error (close-fdes i))
36 (loop (+ i 1)))))