From nobody Wed Apr 16 19:46:33 2025 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 4ZdBNq0tB1z5t8Sm; Wed, 16 Apr 2025 19:46:35 +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 4ZdBNn6z0zz3krV; Wed, 16 Apr 2025 19:46:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744832794; 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=n6ctyrJ4fKeqvw87UedxLu180/A/Wzu9AsK5EoJCaM8=; b=CAVh+kbF2z7ypqjXSvhmoR80GYZQ4N37i8Ga/hCUOJRn2otqTFCa27vd3STrp5+krsfkcn 2ct3eZ4rLSaNrrRrPE91PA7VFHSgZXJgpUnmYtClwnan9ah0FYkZXs7eakYVkQCXk0FA9V NeEzWqT1SqiuNE7dcZy5PAfdaloqao4ba8YvQR23iFHoiGjOqxfuVuhU46yajDt0f3ziAx MtVwZtC124UBohRKW9k1KUrvqoybjJVYs057pz20qMuzZ7mE8DqIklRhSyksuWmXruqyZl yHSL3JUnk9n304SlvYoGMA5l4ODZy/UutYC+awvPifuP5E3nWkQv0wqWmvkIQQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744832794; a=rsa-sha256; cv=none; b=s37F2r350aPL/9xjVjikF6FntWy+RAX9MpRTX9QE2gwQuHnscyVSKyLV782HpvyhA9zTDy EemN+EzaY3uxuTWFw6f4XeVny3aJIZM2B1Eg1PaFGZTP3qbxeE/mEHcDy/bJp4j4CJiFYL XfrqV7hMOxiyhgz8QT8tIHyHCxUld3P8hePHP3hnleBRuUcHUWV5vuMx2+qQFnP5M7DfCp g87A/KBMHfCaVEVS38QbNS5Kq4EnrxYc6z9Ng54St/9ScRvCCGrg+a9FpHcadxrO4YyamZ 69siSQYXzPbkrLdMoix5qNoDH+jS7TAcCLO03Dld2sFzMT19nuGBK0+uNYyAoQ== 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=1744832794; 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=n6ctyrJ4fKeqvw87UedxLu180/A/Wzu9AsK5EoJCaM8=; b=kSTqHhTxMWGKanhXN5oZsqZx6vzs2Uw0AbvR1N6eMrms6qG9DwLzvr0rzsEZKC8MUxgX8p +4zYN0SBFGA+skMTgcLaBMs1cM2FI6BO+/Yvy276uuEe6dwdcUimo9BWjCudql9HD/B3FI byEMSJAr3gb+LzO+5qrp810QFFxxJeHlZrd5ABEWwjIyZSG1I+yPb4GzPIP9ATX3cd4Ed2 nAlkZb+miiuWKHQGe/WQy0MygrdFyIX2jWzyJAVxwuBx/EcQfAgbhKixYOL3J0xQY0K4gG OYpMImP/uLeQsKL6F2PWhoHryJhz95IT4Bcr0CBBL9+Uj2jmnRpvubXe77ViTg== 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 4ZdBNn6Wvzz2Fw; Wed, 16 Apr 2025 19:46:33 +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 53GJkXcg063814; Wed, 16 Apr 2025 19:46:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53GJkXRi063811; Wed, 16 Apr 2025 19:46:33 GMT (envelope-from git) Date: Wed, 16 Apr 2025 19:46:33 GMT Message-Id: <202504161946.53GJkXRi063811@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: aae3eb24dfdb - main - timeout(1): Fix the handling of repeated terminating signals 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aae3eb24dfdbbe0a9e62fe7239d6038060cd07f6 Auto-Submitted: auto-generated The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=aae3eb24dfdbbe0a9e62fe7239d6038060cd07f6 commit aae3eb24dfdbbe0a9e62fe7239d6038060cd07f6 Author: Aaron LI AuthorDate: 2025-04-02 16:14:40 +0000 Commit: Baptiste Daroussin CommitDate: 2025-04-16 19:45:38 +0000 timeout(1): Fix the handling of repeated terminating signals This actually fixes the following two issues: * If a terminating signal (e.g., HUP/INT/TERM) was received, timeout would propagate it to the command and then ignore it. So it was unable to resend the same terminating signal to the command. This was different from the GNU's timeout(1), and also contradicted the POSIX.1-2024 standard. * Sending two different terminating signals would break timeout(1)'s --kill-after mechanism. That was because the second signal would break the for() loop, so the second SIGALRM set by '--kill-after' would never be caught. For example, in one shell run: $ time timeout -f -v -s INT -k 1 2 sh -T -c \ 'trap date INT HUP; sleep 5; echo ok; date' and in another shell run: $ pkill -INT timeout; pkill -HUP timeout in the end, the time(1) would report it cost 5 seconds instead of the expected 3 seconds. Obtained-from: DragonFly BSD --- bin/timeout/timeout.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/bin/timeout/timeout.c b/bin/timeout/timeout.c index e702803a25c2..c3c7532a9d08 100644 --- a/bin/timeout/timeout.c +++ b/bin/timeout/timeout.c @@ -49,7 +49,6 @@ static volatile sig_atomic_t sig_chld = 0; static volatile sig_atomic_t sig_term = 0; static volatile sig_atomic_t sig_alrm = 0; -static volatile sig_atomic_t sig_ign = 0; static const char *command = NULL; static bool verbose = false; @@ -138,11 +137,6 @@ parse_signal(const char *str) static void sig_handler(int signo) { - if (sig_ign != 0 && signo == sig_ign) { - sig_ign = 0; - return; - } - switch (signo) { case SIGINT: case SIGHUP: @@ -377,19 +371,11 @@ main(int argc, char **argv) if (do_second_kill) { set_interval(second_kill); do_second_kill = false; - sig_ign = killsig; killsig = SIGKILL; - } else { - break; } } } - while (!child_done && wait(&pstat) == -1) { - if (errno != EINTR) - err(EXIT_FAILURE, "wait()"); - } - if (!foreground) procctl(P_PID, getpid(), PROC_REAP_RELEASE, NULL);