[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 03/03: service: Remove file descriptor closing loop from 'exe
From: |
Ludovic Courtès |
Subject: |
[shepherd] 03/03: service: Remove file descriptor closing loop from 'exec-command'. |
Date: |
Fri, 9 Sep 2022 11:48:02 -0400 (EDT) |
civodul pushed a commit to branch master
in repository shepherd.
commit 2c0354258047133db8b885bcc11afdf0def5d885
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Sep 9 17:28:48 2022 +0200
service: Remove file descriptor closing loop from 'exec-command'.
It is no longer necessary now that file descriptors are marked as
close-on-exec.
* modules/shepherd/service.scm (exec-command): Remove
'without-automatic-finalization' and 'close-fdes' loop.
---
modules/shepherd/service.scm | 31 ++++++++++---------------------
1 file changed, 10 insertions(+), 21 deletions(-)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index dc5539d..08547de 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -1048,27 +1048,16 @@ false."
(when file-creation-mask
(umask file-creation-mask))
- ;; Last, close all file descriptors. Do that after shutting down the
- ;; finalization thread since we will close its pipe, leading to
- ;; "error in the finalization thread: Bad file descriptor".
- (without-automatic-finalization
- ;; TODO: Remove this loop. Now that all internal file descriptors are
- ;; close-on-exec, we can safely remove this loop, unless users cause
- ;; shepherd to evaluate code that opens non-close-on-exec file
- ;; descriptors.
- (let loop ((i (+ 3 (length extra-ports))))
- (when (< i max-fd)
- (catch-system-error (close-fdes i))
- (loop (+ i 1))))
-
- (catch 'system-error
- (lambda ()
- (apply execlp program program args))
- (lambda args
- (format (current-error-port)
- "exec of ~s failed: ~a~%"
- program (strerror (system-error-errno args)))
- (primitive-exit 1))))))))
+ (catch 'system-error
+ (lambda ()
+ ;; File descriptors used internally are all marked as close-on-exec,
+ ;; so we can fearlessly go ahead.
+ (apply execlp program program args))
+ (lambda args
+ (format (current-error-port)
+ "exec of ~s failed: ~a~%"
+ program (strerror (system-error-errno args)))
+ (primitive-exit 1)))))))
(define %precious-signals
;; Signals that the shepherd process handles.