From nobody Mon Jun 9 23:53:20 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 4bGTJd0sGFz5yhDS; Mon, 09 Jun 2025 23:53:21 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bGTJc4WgBz3KW5; Mon, 09 Jun 2025 23:53:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1749513200; 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=omqn7VBhtvaBdfVFXuADBOomu2tGRCIAIYQJaQXQGJs=; b=lU22YV7+ZytTBLPxSnfBbQr58OEa+sDtxPzSyxyVhAtyVpn5qZHVY1rEmurLSwODGOQHbe tv4HgwvtWu2in/CA6l58frSeAnezIdorByxl00lrtq9sXPtW2/DwWaCzEhQAA9Rg/r2WtM sKTMvUjG4e3Li6tTbfTQ4ZTuqhHCyK/FiBKnpxUGhUdruJQUuidWCHt0V9R4NilEkFAmmm brjM9lExLmKN6Nf3UJlqSlSF4tqgDCpfGeituT8tr6w8pLNPK5T3PbKbjE6cSxTG+Wl8Q9 H3AJi/J0LXDNCGoOe5OjZ1z5PMUFz08XkXWjU9HeSBCzTJH1w/NWt2+ru/VwBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1749513200; 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=omqn7VBhtvaBdfVFXuADBOomu2tGRCIAIYQJaQXQGJs=; b=GUhSJVK8x1AapqwrP85Vm0I7Q50Bo9jLpTduEFneuLtpph1ly1pqjmWuYqFnhkCeCiOj6G PQ3PFIda4IlPEwoq0mUVis22TRdV0rDFMGhP0KgX/um6btPCwvFoiZvdKXA+FUApNqCiJx 709BiMX+ObNHSURYR5Nww9YcPjWH3CagkLbfSwAP6Ue2kToaJSfucik78GN6wKhvgeZL5n RDUpj2uxGyVYx6dwiYsMUeIxUBVS2Id/4afpEtHVrfZ4r7mzdRRtNnNooHyb+Ke+XtQ/sf 0/bKQSxxsrM/OHL6gXVRvdgiJH2dDz59JZdMkU1JWIfxgsmknT3c0PJxzHnN/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1749513200; a=rsa-sha256; cv=none; b=GmizEACstd3b/qozAjpxn4pMks0h/ewLWL4cxXib+XYAdfpiPw1xNyTtuCphHvZAeDTJPO mSPXP9Lofy8TIduWXrBI7qy74FnUrJbWZQ5vyt48PKSu07U+DrSNEvV3RaF3t6mnXoah/E 9MBmtaAOef7XHjkkHoif7rL3M3P43siXkJZOMyoiHhYkKEa+6CXJFLLu5yfW6q2kJib2Gu aJI6g5njua0t+fdfbGU9mps1PyeX+5fT+fdsKtS/I5Dh4z+KETn6NXY6OQi0lkqe0XnsVo /lM+qQJL78SGXL7qxRfxy6igfQZmRJyNN3uWvToBfFThnYT7e/PGbunq2D/yRw== 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 4bGTJc3tM7z1kg; Mon, 09 Jun 2025 23:53:20 +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 559NrKVI006825; Mon, 9 Jun 2025 23:53:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 559NrK5H006822; Mon, 9 Jun 2025 23:53:20 GMT (envelope-from git) Date: Mon, 9 Jun 2025 23:53:20 GMT Message-Id: <202506092353.559NrK5H006822@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: aa8cdb7cae7b - main - timeout(1): only start the child command after the parent is fully set up 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aa8cdb7cae7b7550d5cb81d85ee294c4f182f694 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=aa8cdb7cae7b7550d5cb81d85ee294c4f182f694 commit aa8cdb7cae7b7550d5cb81d85ee294c4f182f694 Author: Konstantin Belousov AuthorDate: 2025-06-08 15:47:49 +0000 Commit: Konstantin Belousov CommitDate: 2025-06-09 23:51:19 +0000 timeout(1): only start the child command after the parent is fully set up Since the default disposition for SIGCHLD is ignore, the prematurely exited child would cause SIGCHLD dropped. This makes timeout(1) hang, because REAP_STATUS reports a zombie not waited for, but SIGCHLD for it was already lost, so the main loop cannot exit, instead calling into sigsuspend(). Reported and tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50752 --- bin/timeout/timeout.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bin/timeout/timeout.c b/bin/timeout/timeout.c index 05904522c5b5..f47976aa27df 100644 --- a/bin/timeout/timeout.c +++ b/bin/timeout/timeout.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include #include @@ -283,6 +283,8 @@ main(int argc, char **argv) int ch, status, sig; int pstat = 0; pid_t pid, cpid; + int pp[2], error; + char c; double first_kill; double second_kill = 0; bool foreground = false; @@ -351,6 +353,9 @@ main(int argc, char **argv) if (sigprocmask(SIG_BLOCK, &allmask, &oldmask) == -1) err(EXIT_FAILURE, "sigprocmask()"); + if (pipe2(pp, O_CLOEXEC) == -1) + err(EXIT_FAILURE, "pipe2"); + pid = fork(); if (pid == -1) { err(EXIT_FAILURE, "fork()"); @@ -366,6 +371,11 @@ main(int argc, char **argv) if (sigprocmask(SIG_SETMASK, &oldmask, NULL) == -1) err(EXIT_FAILURE, "sigprocmask(oldmask)"); + error = read(pp[0], &c, 1); + if (error == -1) + err(EXIT_FAILURE, "read from control pipe"); + if (error == 0) + errx(EXIT_FAILURE, "eof from control pipe"); execvp(argv[0], argv); warn("exec(%s)", argv[0]); _exit(errno == ENOENT ? EXIT_CMD_NOENT : EXIT_CMD_ERROR); @@ -391,6 +401,11 @@ main(int argc, char **argv) signal(SIGTTOU, SIG_IGN); set_interval(first_kill); + error = write(pp[1], "a", 1); + if (error == -1) + err(EXIT_FAILURE, "write to control pipe"); + if (error == 0) + errx(EXIT_FAILURE, "short write to control pipe"); sigemptyset(&zeromask); for (;;) {