From nobody Thu Oct 2 08:20:53 2025 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 4ccl9f0kFxz69KRs; Thu, 02 Oct 2025 08:20:54 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ccl9d6qwQz4NRF; Thu, 02 Oct 2025 08:20:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759393254; 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=PxfffDDST+unS/AjjKaScxfY36BmsEKHSe4Rk0BW98M=; b=i76ng8gi6YlRWuz9I0V2ESJduMb458fAD0AjN9ARmIHfYM3Fy/1kmNJ2sBDPtrdAmhjgWO nQJUNT/umk5Pw626hzlKzUN7IpLmVURwYAPWfUhImSWW9Lyn0eWOppJcOrVC336EISA7T3 065H1YZ+Stq1FlfjPBuS76RUsPeSkBon+lYxWFIo7hEgtMXFORSteb/uqUTw7O31y91/r4 6Fe7iR4Cbj+ZafyD/d3M8CfG+1yiKvOoUKCNIREw5y/ezO0z2n0eKluS9inceuIDKuukpC eyBadLGMSJSNWbhzA9F+yeaN44ihUawEfTFqZfN2NPV7Kovh5DrDExckW8Z04w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759393254; 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=PxfffDDST+unS/AjjKaScxfY36BmsEKHSe4Rk0BW98M=; b=eeZ6jrgdlwChlXYgbfPLo1hF3FDtFi7AtL+JfZIDIDosLhTkFFS/JT2cixDvdItyKtVHuL qEFfzbKr1lnD8jcjzsWzHrJBmGKFwtu09boHFNBDSY49QY6cDpufXPh3Uhma9Cp3W047Tl SfqV5c/bpKIeLR2aTa39MGFOWgohnyjFxUgQw0bxWE8Xdj9vMTbNYvU/f59d84EA6xhAk3 45badAfWJNhx0j4mDjhxv31iFyPz0Zt1DZv2ULmIoxpEno3bd3vrIgs2SbOOjKaD/ZsTMs 9c6TS6gKAF5AqzhBatPymqFH/+pCYsMhMLE8T5LGjzlzD9yFS4uqf+LO1bIR0w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759393254; a=rsa-sha256; cv=none; b=RxAUfoMKA1Ots7uhjuZAydwn/AYa1OPeBvNMQwJujmDro6DVG8qolp/FI4Oe2wTh8vEKK0 MbXgMVH+ISc7nSjfwSaFluPrb1SlsEVEiL2I7I+FvxRmvqOCZ1X3hDnWsuTQM61E5gn5xY xB9Rroqitx/AE+ZUUr6CQ3TMxUycvl96rvGn9zlU/4fBEzOlzlTCy+AtX2IkhxgPzEr8L4 aW5G9CH2yRV19RJ8bginqEVYl+dk5ARD5pdQYRthJqing6rbrFmD5nvSEAJVKWfpH63PGs pxp7cFmwwNudC+g9A+XDjn0jVaIS+fGlbBufwMa5uo0N9l/bZOuilYd19h0NIQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4ccl9d6NZMz10lg; Thu, 02 Oct 2025 08:20:53 +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 5928Kr0p023587; Thu, 2 Oct 2025 08:20:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5928KrIJ023584; Thu, 2 Oct 2025 08:20:53 GMT (envelope-from git) Date: Thu, 2 Oct 2025 08:20:53 GMT Message-Id: <202510020820.5928KrIJ023584@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 65f3a787b6d7 - stable/14 - rc.subr: Fix wait_for_pids 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: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 65f3a787b6d7495f1638bc064277b320b4784019 Auto-Submitted: auto-generated The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=65f3a787b6d7495f1638bc064277b320b4784019 commit 65f3a787b6d7495f1638bc064277b320b4784019 Author: Dag-Erling Smørgrav AuthorDate: 2025-08-01 23:11:40 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-10-02 07:28:57 +0000 rc.subr: Fix wait_for_pids It looks like this function was intended to loop and print an update whenever at least one of the waited-for processes terminates. However, the default behavior of pwait is to block until none of the watched processes exist. Use pwait -o instead so it only blocks until at least one process terminates, and add a test. Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: siderop1_netapp.com, kevans Differential Revision: https://reviews.freebsd.org/D51691 (cherry picked from commit 7f04c09fe74535c1646a4af120f8f1342fe1c328) --- libexec/rc/rc.subr | 4 ++-- libexec/rc/tests/rc_subr_test.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr index 239ec4707b33..5423af476ad0 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -642,7 +642,7 @@ wait_for_pids() fi _prefix= while true; do - _nlist=""; + _nlist="" for _j in $_list; do if kill -0 $_j 2>/dev/null; then _nlist="${_nlist}${_nlist:+ }$_j" @@ -655,7 +655,7 @@ wait_for_pids() _list=$_nlist echo -n ${_prefix:-"Waiting for PIDS: "}$_list _prefix=", " - pwait $_list 2>/dev/null + pwait -o $_list 2>/dev/null done if [ -n "$_prefix" ]; then echo "." diff --git a/libexec/rc/tests/rc_subr_test.sh b/libexec/rc/tests/rc_subr_test.sh index 9931389e7a02..e8398c8d9b12 100644 --- a/libexec/rc/tests/rc_subr_test.sh +++ b/libexec/rc/tests/rc_subr_test.sh @@ -1,5 +1,8 @@ +#- +# SPDX-License-Identifier: BSD-2-Clause # # Copyright 2022 Mateusz Piotrowski <0mp@FreeBSD.org> +# Copyright (c) 2025 Klara, Inc. # # SPDX-License-Identifier: BSD-2-Clause # @@ -104,8 +107,32 @@ oomprotect_yes_body() /bin/sh "$__script" "$__name" "$__pidfile" onestop } +atf_test_case wait_for_pids_progress +wait_for_pids_progress_head() +{ + atf_set "descr" "Verify that wait_for_pids prints progress updates" +} +wait_for_pids_progress_body() +{ + cat >>script <<'EOF' +. /etc/rc.subr +sleep 15 & +a=$! +sleep 10 & +b=$! +sleep 5 & +c=$! +wait_for_pids $a $b $c +EOF + re="^Waiting for PIDS: [0-9]+ [0-9]+ [0-9]+" + re="${re}, [0-9]+ [0-9]+" + re="${re}, [0-9]+\.$" + atf_check -s exit:0 -o match:"${re}" /bin/sh script +} + atf_init_test_cases() { atf_add_test_case oomprotect_all atf_add_test_case oomprotect_yes + atf_add_test_case wait_for_pids_progress }