guix-commits
[Top][All Lists]
Advanced

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

03/04: gnu: shepherd: Avoid "Bad file descriptor" warnings.


From: Ludovic Courtès
Subject: 03/04: gnu: shepherd: Avoid "Bad file descriptor" warnings.
Date: Sun, 3 Dec 2017 17:27:10 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 4bd70904c7f555a953808a9a4f892f462ffd352f
Author: Ludovic Courtès <address@hidden>
Date:   Sun Dec 3 22:36:17 2017 +0100

    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.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/admin.scm                        |  3 ++-
 gnu/packages/patches/shepherd-close-fds.patch | 36 +++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 9dd0ce4..434bbb0 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1061,6 +1061,7 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/scotch-test-threading.patch             \
   %D%/packages/patches/sdl-libx11-1.6.patch                    \
   %D%/packages/patches/seq24-rename-mutex.patch                        \
+  %D%/packages/patches/shepherd-close-fds.patch                        \
   %D%/packages/patches/shishi-fix-libgcrypt-detection.patch    \
   %D%/packages/patches/slim-session.patch                      \
   %D%/packages/patches/slim-config.patch                       \
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index d4215ea..221d583 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -162,7 +162,8 @@ and provides a \"top-like\" mode (monitoring).")
                                   version ".tar.gz"))
               (sha256
                (base32
-                "174q1qg7yg6w1hfvlfv720hr6hid4h5xzw15y3ycfpspllzldhcb"))))
+                "174q1qg7yg6w1hfvlfv720hr6hid4h5xzw15y3ycfpspllzldhcb"))
+              (patches (search-patches "shepherd-close-fds.patch"))))
     (build-system gnu-build-system)
     (arguments
      '(#: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 0000000..2078b15
--- /dev/null
+++ b/gnu/packages/patches/shepherd-close-fds.patch
@@ -0,0 +1,36 @@
+commit 3e346a2a84b099766ea8a3a4a4549f6172483062
+Author: Ludovic Courtès <address@hidden>
+Date:   Sun Dec 3 22:30:03 2017 +0100
+
+    service: In 'exec-command', close open ports before 'execl'.
+    
+    This gets rid of annoying "Bad file descriptor" warnings from shepherd.
+    
+    * modules/shepherd/service.scm (exec-command): In 'loop', invoke
+    'close-port' and the ports returned by (fdes->ports i).
+
+diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
+index b2d8bc5..0ad28a0 100644
+--- a/modules/shepherd/service.scm
++++ b/modules/shepherd/service.scm
+@@ -1,5 +1,5 @@
+ ;; service.scm -- Representation of services.
+-;; Copyright (C) 2013, 2014, 2015, 2016 Ludovic Courtès <address@hidden>
++;; Copyright (C) 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <address@hidden>
+ ;; Copyright (C) 2002, 2003 Wolfgang Järling <address@hidden>
+ ;; Copyright (C) 2014 Alex Sassmannshausen <address@hidden>
+ ;; Copyright (C) 2016 Alex Kost <address@hidden>
+@@ -744,6 +744,14 @@ false."
+ 
+        (let loop ((i 3))
+          (when (< i max-fd)
++           ;; First try to close any ports associated with file descriptor I.
++           ;; Otherwise the finalization thread might get around to closing
++           ;; those ports eventually, which will raise an EBADF exception (on
++           ;; 2.2), leading to messages like "error in the finalization
++           ;; thread: Bad file descriptor".
++           (for-each (lambda (port)
++                       (catch-system-error (close-port port)))
++                     (fdes->ports i))
+            (catch-system-error (close-fdes i))
+            (loop (+ i 1)))))



reply via email to

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