[PATCH s6] s6-setsid: Only open /dev/tty if it's actually needed

From: Josiah Frentsos <jfrent_at_tilde.team>
Date: Fri, 27 Mar 2026 20:40:59 -0400

Without this, s6-setsid -b will fail if it doesn't have a
controlling terminal:

        s6-setsid: fatal: unable to open /dev/tty: Device not configured

Signed-off-by: Josiah Frentsos <jfrent_at_tilde.team>
---
 src/daemontools-extras/s6-setsid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/daemontools-extras/s6-setsid.c b/src/daemontools-extras/s6-setsid.c
index 21662d0..3d11895 100644
--- a/src/daemontools-extras/s6-setsid.c
+++ b/src/daemontools-extras/s6-setsid.c
_at__at_ -60,7 +60,7 _at__at_ int main (int argc, char const *const *argv)
   {
     if (!uint0_scan(wgola[GOLA_CTTY], &ctty)) dieusage() ;
   }
-  else if (wgolb & (GOLB_PGRP | GOLB_FG))
+  else if ((wgolb & GOLB_PGRP) && (wgolb & GOLB_FG))
   {
     int fd = openc_read("/dev/tty") ;
     if (fd == -1) strerr_diefu2sys(111, "open ", "/dev/tty") ;
-- 
2.53.0
Received on Sat Mar 28 2026 - 01:40:59 CET

This archive was generated by hypermail 2.4.0 : Sat Mar 28 2026 - 01:44:30 CET