From 6076ca90a8101888483b769edd2f9aeef0da8638 Mon Sep 17 00:00:00 2001 From: Marcos Mello Date: Wed, 23 Jan 2019 15:18:43 +0000 Subject: [PATCH] Bug 4914: Do not call setsid() in --foreground mode (#354) Squid executed in --foreground is always a process group leader. Thus, setsid(2) is unnecessary and always fails (with EPERM) for such Squids. --- src/main.cc | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main.cc b/src/main.cc index 7f5ec8015f..1e8e035f4c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1871,6 +1871,7 @@ GoIntoBackground() exit(EXIT_SUCCESS); } // child, running as a background daemon + Must(setsid() > 0); // ought to succeed after fork() } static void @@ -1916,14 +1917,6 @@ watch_child(const CommandLine &masterCommand) if (!opt_foreground) GoIntoBackground(); - // TODO: Fails with --foreground if the calling process is process group - // leader, which is always (?) the case. Should probably moved to - // GoIntoBackground and executed only after successfully forking - if (setsid() < 0) { - int xerrno = errno; - syslog(LOG_ALERT, "setsid failed: %s", xstrerr(xerrno)); - } - closelog(); #ifdef TIOCNOTTY -- 2.47.2