From: Marcos Mello Date: Wed, 23 Jan 2019 15:18:43 +0000 (+0000) Subject: Bug 4914: Do not call setsid() in --foreground mode (#354) X-Git-Tag: M-staged-PR356~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e6dbb95a188639ae01b32e49325dec79e25f6821;p=thirdparty%2Fsquid.git 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. --- diff --git a/src/main.cc b/src/main.cc index d9f423ed67..97e1315ecf 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1866,6 +1866,7 @@ GoIntoBackground() exit(EXIT_SUCCESS); } // child, running as a background daemon + Must(setsid() > 0); // ought to succeed after fork() } static void @@ -1911,14 +1912,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