Subject: shepherd: dangling file descriptor to /dev/console
From: [email-masked]
To: [email-masked]
Date: Tue, 10 Jun 2025 20:31:51 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

All shepherd children have an open file descriptor to /dev/console,
probably because of the use of dup2 (and not dup3) in system.scm.

The pb. disapears if I force that flag with that code before I define
my services (context: shepherd used as init system on Debian):
(port-for-each (lambda (x)
                 (catch #t
		   (lambda ()
		     (when (= (fcntl x F_GETFD) 0)
		       (fcntl x F_SETFD FD_CLOEXEC)
		       (format #t "FD_CLOEXEC flag set on port ~a (fd: ~a)\n" x (port->fdes x))))
		   (lambda (keys . args) (format #t "fcntl error for port ~a\n" x)))
		 ))

Sincerely.

-- 

Bernard