From nobody Tue Nov 19 19:51:43 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 4XtFW357XVz5fNY5; Tue, 19 Nov 2024 19:51:43 +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 4XtFW33WJSz4clR; Tue, 19 Nov 2024 19:51:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732045903; 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=yf3C6XPMiXjbj/jzG2LCKfjbBxeLoMM4HbcXxpDoBow=; b=Ks6Usjb8VqDoLtGr6cUHzzDGIgY5X5NZkHZ4lnYDX+0jmdIoPCmQKU8AFvrbYTVZS6yjCF kxpci3AuZYN1cyrHpVOpikDahOEXFcH8iv+Q1vcoFChhkAZvsawx0A9Tx3vKC51RNcNqJ2 W66MI+xONN3o/fncip6CWvUmC/+Cz/rv3OGaY3MPdS8q/6oJxYX9tNFNF18oNiX+HbUlpL nyxweIVJ/pOolLJNk1aoBEON2abIS1tda4dyEUDBYOlACsIDN/SAYHq8211APtxMFbRWr2 xgVPRy5VZxdICTeNWU2NPwF0EYrJdvQRxlKSlnbDoJoMjbsEGeHBujmRwf2OFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732045903; 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=yf3C6XPMiXjbj/jzG2LCKfjbBxeLoMM4HbcXxpDoBow=; b=frx7pLjROTSQe9i5w7Jl4jZrirV9ONqX6PQduM78M7MRc/vZRH+FZZGLwcygYoJ0ZOhZ9w nAvLXfwaNz5oqQcsd3NHlJpAHC0fjNXl6FXIwEKYTyGXrUxveJQDgGYEoTTtO6vMHqdklm 3L+ltwW4Y/MUBZOCb+TUAly6gtrye4mZFNbALOjJ93D2bGvut+HK+ncTI2iWfG5iaOhsNi BJ1xyJuFma3QeEIFS1mLl+aBziKUafGUjlMSfMPnV4ijHDKzx/6KqzVgVKh0S293N5qMAc Cx7wdTDfBJVC65/usdRnePmSq1s8zYhEvvWmZapt/eJXN9JrZ0WuOLK883cWfg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732045903; a=rsa-sha256; cv=none; b=PQHqtpRo/qHanY7Mg6eEwhT5jLRa9p4U0f5crQ5c2XoDZ7A3gV344MPC3wpJyrP/PREdti 95Fza2zSCewqHdUJj2YmwCyk6127/SgnXCSAMNI4vmoIfCrchRA4zfjyJit6av1PhmAERV /62jjHsffEODp6kuB55XdaDzt+t9JOULUJENt5zvlOiK7TLnWd3ku0OIoA30VNAFfng0La RiMaf6Oz7zwAyQ06xhKjY2hjtC0mu62F+k5N4rkbq3ZqbU1MI2EhWcVaogUIUWHUZ4PBYE EneibEBvgRVvx1lAZwbiVPqd/Ggth45ycS8DTZmAFl3xvUoD76bgSnmPm9bwQQ== 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 4XtFW337P1zNLr; Tue, 19 Nov 2024 19:51:43 +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 4AJJphXF035665; Tue, 19 Nov 2024 19:51:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AJJphm4035662; Tue, 19 Nov 2024 19:51:43 GMT (envelope-from git) Date: Tue, 19 Nov 2024 19:51:43 GMT Message-Id: <202411191951.4AJJphm4035662@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 9ab59e900c1d - main - 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/main X-Git-Reftype: branch X-Git-Commit: 9ab59e900c1dd693b4d14285389a035e81341789 Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=9ab59e900c1dd693b4d14285389a035e81341789 commit 9ab59e900c1dd693b4d14285389a035e81341789 Author: Kyle Evans AuthorDate: 2024-11-19 19:51:27 +0000 Commit: Kyle Evans CommitDate: 2024-11-19 19:51:27 +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 Differential Revision: https://reviews.freebsd.org/D47005 --- 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