From nobody Tue Dec 10 23:37:59 2024 X-Original-To: dev-commits-src-all@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 4Y7FXS4HWqz5g2W0; Tue, 10 Dec 2024 23:38:00 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y7FXS1qnDz4l7K; Tue, 10 Dec 2024 23:38:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733873880; 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=xtTUh3U4MO0KJ/LFR3GTIcSEvpqX0V3PHFwNUrhJonQ=; b=nfLny+VqO3/0NPkrGCitRzHMN+iEWZuQDwtDFyP33VXS7JNHs+69v1Kg0ycwH3zKQyMplY 4fLHkebpB2tyP+H9LlmfpN8Wq9q5T/2WT/HmqNJE8Ir+fLKgHjZF2iIvw7Ay42iv+nqrkf hmI4XGittBB1P1PwBijzFJyFd2idSJfBexNOlmVqUiw/VeIqiL7rXiGejCELG+ikABVwMr 9UUmvHLQfi458f7irvQyCx1BV/z1H2HEexIX6e5bkvaej53Z9IhcjxQQQMf+jWW/8b5KAJ uCMBwmGddaV7zL1zCAaRBVtvEW4XYHR4IIh01Nj2ZtdgMWSpmapFVi3Ij0ORfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733873880; 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=xtTUh3U4MO0KJ/LFR3GTIcSEvpqX0V3PHFwNUrhJonQ=; b=Eba8EQnyT05VUHBfm0kRgYpubfTIFQbmK3Gcjr5WsgDNdb/GOTRyCdyIv9FjZ9aKA+t9cU kd9dup1dm4Hiqd/dBizDvRZju7RpENSfq547RJCvwoMu0j6TVvwGqZb7iz/q/+i97E9TTP u7usj3GIvUC7WdRb78SmNHz6c1c0JLmwsn4+p01XSyZW0DUxzVyoAFeThyJcBDMkLwQqxU 5baq9yGNxzr+fIPTbgul89NSJ1gMAB+nHVmsc1pDagLY/GWHuBNZV85YBHSpkLsBvtYolp iEvVW8SCBBNTbqFPrkQXthLT8WZ38HZ7pCulNPIEw0GK/P+vEhqfDOlW5U2NqQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733873880; a=rsa-sha256; cv=none; b=dmN2SUKSGUuHUn87EehrHGQB0HD0WAMbsykqzk3ZBQJrh0CZ3YJgY0KXim6ZywuIV8KwIw HT3GNA5Q6tVofhzUPD+dy8AhF3D/yLvljCVcx12A/M1GSvPGjdKV2niXXz/UALq+BL5HSx z+Tx5cSrLBPPz5IDgr/AxZe15jKcCj+x6OS3uC7Ltl0aLlg1So/FfGVDuimLyd07mOQyN2 m5vyLw4qGts5+TCo62kJuytoQHNr8Zo4uTYRvRkvWRWG4Ncc9jWI/1MtzoWiWajlRoi0oe /FbI3He5gpcFjcQYELFCq/aAp3PN4qza2BHK2xHwmx21xwYJwjxCySGIJJLylw== 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 4Y7FXS12L2zkWX; Tue, 10 Dec 2024 23:38:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BANbxK5019763; Tue, 10 Dec 2024 23:37:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BANbxeX019760; Tue, 10 Dec 2024 23:37:59 GMT (envelope-from git) Date: Tue, 10 Dec 2024 23:37:59 GMT Message-Id: <202412102337.4BANbxeX019760@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: e310a825c933 - stable/14 - daemon: tests: add a test for missed SIGTERM List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: e310a825c933182a5b29261b741467f649951ff1 Auto-Submitted: auto-generated The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=e310a825c933182a5b29261b741467f649951ff1 commit e310a825c933182a5b29261b741467f649951ff1 Author: Kyle Evans AuthorDate: 2024-11-19 19:51:27 +0000 Commit: Kyle Evans CommitDate: 2024-12-10 23:00:03 +0000 daemon: tests: add a test for missed SIGTERM This is somewhaht hard to test reliably, but we'll give it a shot. Startup a sleep(1) daemon with a hefty restart delay. In refactoring of daemon(8), we inadvertently started dropping SIGTERMs that came in while we were waiting to restart the child, so we employ the strategy: - Pop the child sleep(1) first - Wait for sleep(1) to exit (pid file truncated) - Pop the daemon(8) with a SIGTERM - Wait for daemon(8) to exit The pidfile is specifically truncated outside of the event loop so that we don't have a kqueue to catch it in the current model. PR: 277959 Reviewed by: des, markj (cherry picked from commit 9ab59e900c1dd693b4d14285389a035e81341789) --- usr.sbin/daemon/tests/daemon_test.sh | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/usr.sbin/daemon/tests/daemon_test.sh b/usr.sbin/daemon/tests/daemon_test.sh index 2ad0803842b7..ec94d30bc1c3 100644 --- a/usr.sbin/daemon/tests/daemon_test.sh +++ b/usr.sbin/daemon/tests/daemon_test.sh @@ -154,6 +154,43 @@ restart_child_cleanup() { [ -f daemon.pid ] && kill `cat daemon.pid` } +atf_test_case restart_hang cleanup +restart_hang_head() { + atf_set "descr" "daemon should terminate with SIGTERM even pending child restart" +} +restart_hang_body() { + daemon -rP daemon.pid -R 10 -p sleep.pid sleep 300 + atf_check -s exit:0 test -f daemon.pid + atf_check -s exit:0 test -f sleep.pid + read sleep_pid < sleep.pid + 1>&2 echo "$sleep_pid" + kill "$sleep_pid" + + # Wait up to 5s for the child to exit + for t in `seq 0 0.1 5`; do + [ ! -s "sleep.pid" ] && break + sleep 0.1 + done + + atf_check test ! -s "sleep.pid" + + read daemon_pid < daemon.pid + kill -TERM "$daemon_pid" + + # Wait up to 10s for the daemon to terminate + for t in `seq 0 0.1 10`; do + [ ! -f "daemon.pid" ] && break + sleep 0.1 + done + + atf_check test ! -f "daemon.pid" + atf_check test ! -f "sleep.pid" +} +restart_hang_cleanup() { + [ -s daemon.pid ] && kill -9 `cat daemon.pid` + true +} + atf_test_case supervisor_pidfile cleanup supervisor_pidfile_head() { atf_set "descr" "daemon should write its own pid to a pidfile" @@ -218,6 +255,7 @@ atf_init_test_cases() { atf_add_test_case newsyslog atf_add_test_case output_file atf_add_test_case restart_child + atf_add_test_case restart_hang atf_add_test_case supervisor_pidfile atf_add_test_case supervisor_pidfile_lock atf_add_test_case title