From nobody Thu Sep 28 15:52:47 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RxJ0H4xJ5z4tyF9; Thu, 28 Sep 2023 15:52:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RxJ0H3xRdz4LPf; Thu, 28 Sep 2023 15:52:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695916367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EQWmUsoss9uS1ZxShm7ADGNm8hNDLoAUz+WGoGQM3WM=; b=Vch+GwE9IiALTCkz+6OJH31cNuw97Q8KmSwTmjY26jhwgAkP9e7EkHANJAPDpk6oV/GRgX 2rBm73O81RDz4zg/I/fmlKRhlKICSAvnMcy1jpwHwakurvPKTXC+F5knxwoHImWWyVN878 sL1ylzFW+sOVCj8TUjVCPu+tkf29i8Fvxbb0ptE2LSofRoDJ/lwC2z00btCi8YMRmrkuCA Mjk6RcD8TStaPLqt4sLJiuk67DzSvqTx4fIDnHquXYbAFHmtvwJpbf9yDX69bb8+0+x2dQ DWK9pExC6wMG/bxFwoCaaknZG7h0uRW79Zptkp6X0Lkyg/d581LEwvep9k0Q/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695916367; a=rsa-sha256; cv=none; b=uMXmuj30AZB1LCtyO+e/xcIz5uNZWKMIonY1Tp29jsNFwAGwwtd5dYhJJeJlhPAwFL6c1o BZupRV3EsfQpkXCLjgnt/1rlRpQRhJAp+slpJFlXtWMA1iEmC68MK5I5rszJyEblTGsY5F xqphOldO4gp6MCNUfMgnJfXsO8vD1tyPUWE/xXKEQOsDQ/V/JLPbLAdTStAoJtbo1uz6k3 24PMIps7YegNz39pCC/4WfJgOdYwlISO/fasOeEC2aeRXyBmEkBj5orPrD0tA/T3zgUO4s KFK0Q4MwAWd8PuP6XD//OvRyCJ/lFQaIB+Hp9yvoJc6vWQyN0a+1VvCvm5Gfig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695916367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EQWmUsoss9uS1ZxShm7ADGNm8hNDLoAUz+WGoGQM3WM=; b=rOSP3toenT0ZTC9mP3G2Pts6uASEfegAm/kV1Hj5xFWEt4qpYOEY42yvjyDLUS0kIaCjw0 A7imfZgYSCBYlwcer/FOfzkTrDcXHvTeiNO49VYmff40NaI8npDCgn4+TyyKdGrDwYYETv rluhnag+rVpj5eL2H/GDoH7Y7utzslxIFsQVSc1setCH81opD4is+CyV7TaP92S+/rkrun +RdmojEezTZB8Xm0VVornX9wYHoQPoOTiXvnVlPQ2sSi4eiSnxai7HbA0bPg4RNfgZiR9D uqHvquK5BJhsoG9YpcoSI1I0m8yCjDAWcjBz3CIv9nCdsvcKdgi4k9FZ5EcGSA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RxJ0H32F3zDLC; Thu, 28 Sep 2023 15:52:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38SFqlQR022537; Thu, 28 Sep 2023 15:52:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38SFqlOW022534; Thu, 28 Sep 2023 15:52:47 GMT (envelope-from git) Date: Thu, 28 Sep 2023 15:52:47 GMT Message-Id: <202309281552.38SFqlOW022534@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4ac6582472a2 - main - syslogd: Ignore signals in sigcatch[] List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4ac6582472a2f4be06217cfbfd7a9d049f2cd6d6 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4ac6582472a2f4be06217cfbfd7a9d049f2cd6d6 commit 4ac6582472a2f4be06217cfbfd7a9d049f2cd6d6 Author: Jake Freeland AuthorDate: 2023-09-01 02:51:22 +0000 Commit: Mark Johnston CommitDate: 2023-09-28 15:51:54 +0000 syslogd: Ignore signals in sigcatch[] Instead of blocking signals in sigcatch[], just ignore them. This frees up some space on the proc's sigqueue. Reviewed by: markj MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41433 --- usr.sbin/syslogd/syslogd.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 2ff39d8c3676..3f9633ca8c35 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -597,7 +597,6 @@ int main(int argc, char *argv[]) { struct sigaction act = { }; - sigset_t sigset = { }; struct kevent ev; struct socklist *sl; pid_t ppid = -1, spid; @@ -838,6 +837,14 @@ main(int argc, char *argv[]) exit(1); } } + + /* + * Syslogd will not reap its children via wait(). + * When SIGCHLD is ignored, zombie processes are + * not created. A child's PID will be recycled + * upon its exit. + */ + act.sa_handler = SIG_IGN; for (size_t i = 0; i < nitems(sigcatch); ++i) { EV_SET(&ev, sigcatch[i], EVFILT_SIGNAL, EV_ADD, 0, 0, NULL); if (kevent(kq, &ev, 1, NULL, 0, NULL) == -1) { @@ -845,23 +852,14 @@ main(int argc, char *argv[]) pidfile_remove(pfh); exit(1); } - (void)sigaddset(&sigset, sigcatch[i]); - } - if (sigprocmask(SIG_BLOCK, &sigset, NULL) != 0) { - warn("failed to apply signal mask"); - pidfile_remove(pfh); - exit(1); + if (sigaction(sigcatch[i], &act, NULL) == -1) { + warn("failed to apply signal handler"); + pidfile_remove(pfh); + exit(1); + } } (void)alarm(TIMERINTVL); - /* Do not create zombie processes. */ - act.sa_flags = SA_NOCLDWAIT; - if (sigaction(SIGCHLD, &act, NULL) == -1) { - warn("failed to apply signal handler"); - pidfile_remove(pfh); - exit(1); - } - /* tuck my process id away */ pidfile_write(pfh); @@ -3598,7 +3596,7 @@ validate(struct sockaddr *sa, const char *hname) static int p_open(const char *prog, int *rpd) { - sigset_t sigset = { }; + struct sigaction act = { }; int pfd[2], pd; pid_t pid; char *argv[4]; /* sh -c cmd NULL */ @@ -3623,12 +3621,12 @@ p_open(const char *prog, int *rpd) } alarm(0); - - for (size_t i = 0; i < nitems(sigcatch); ++i) - (void)sigaddset(&sigset, sigcatch[i]); - if (sigprocmask(SIG_UNBLOCK, &sigset, NULL) != 0) { - logerror("sigprocmask"); - exit(1); + act.sa_handler = SIG_DFL; + for (size_t i = 0; i < nitems(sigcatch); ++i) { + if (sigaction(sigcatch[i], &act, NULL) == -1) { + logerror("sigaction"); + exit(1); + } } dup2(pfd[0], STDIN_FILENO);