From nobody Tue Oct 08 17:02:20 2024 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 4XNMl11QC9z5XfJY; Tue, 08 Oct 2024 17:02: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 4XNMl10Zk4z46L4; Tue, 8 Oct 2024 17:02:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728406941; 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=kbVmSdKvIGVobmqnx+agIrYFarhtkwI2YPxhgw0RCiQ=; b=hyN3n8u3bQYSIZ1zDXMV5joJZ9OVhp/RgvH3R/ZMV5Cdsu0ZTmt+Tox3cNXxZ4Xk9hEP/p YY/oAMyUd2QvOAUekUrBPfrbxYyyyz7j+hEw64Bzii+iLTnFdaRgxSA2vrfgbhGtYEoAE3 Stew+e/ugzl5SKMiYxrrWxgCCwleDMYsItx19+/JbRBh9nawq9QiwOFTH3vJN7EVFdqD4+ QHdUD86TNjX/btrH9/c9DMgR3OuHD3Qy5L5/7vPvjgSPGZnXEFbaKETKTFwTIEuESg6e7p joGQpZdSg2yCQhIsRATfw9MOoxrIUBIXwZkpE/kxaOklX/5J1QApN3tGmhpmog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728406941; 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=kbVmSdKvIGVobmqnx+agIrYFarhtkwI2YPxhgw0RCiQ=; b=Ak2DiJZXLscdTfp3r7JIZdyVQ4PVp8I7PsR/jwrJsv2DOX8HWsR7MfaHHqdO9o01jat+Bb gRW+XaRwsZAdNmQHLQL4UT5WPTdWqHV2tcQDf4O8asQT+7QY9HoJrIzOClgvxiqafKE5Vz bQz5jLn9FVIMRWVNCdKXtSfntSCBO886IRedqPCe0xgVutCdPv7aqqusCO0StMR3aZDTM3 CYUc1D4feJeE+tUKYI3pstgoFoBei/4IBieWX6e9yj7WXae/DxSwPiuEI6G6iktIYHH6eA yn0AdDfP+abF11a9Y2vwT8yNi3n1/pgh9xubF5nJz1g71JnQtKi4x2uHVbiKMg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728406941; a=rsa-sha256; cv=none; b=scr3IrvnghwAu6VfksDS2lpaw08qzHOsNoH8l22QcyUijLxSXiavkV+YwIvWS3nS+UNW3I mQPdvZou2NrgvOsMGQUl+0pj42EDzhfT+JtB7liSmvWaCDOklu2sO+qmm53MKfxy53SuoY 7GqWhBTH+J790I201UHgscoJx+UF8tdosmweGaUUcb940a7Jbkma0eo59QRTBhT24XnoSv afjbK6ljn0QnTKfQK6+GVS0FaFSZiOrGlptk6Ry7P/ryA2jJjomoBmutq1mn1XjvUsG1Lj O+uk2axbkwKTWg5MMlj/GAY02OQmnBg1Hwo0F8yFIJtDDQAplP17YD9hWzstAw== 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 4XNMl109ZBzfFM; Tue, 8 Oct 2024 17:02:21 +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 498H2Km8072015; Tue, 8 Oct 2024 17:02:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 498H2KIP072012; Tue, 8 Oct 2024 17:02:20 GMT (envelope-from git) Date: Tue, 8 Oct 2024 17:02:20 GMT Message-Id: <202410081702.498H2KIP072012@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: c2d93a803ace - main - env: Check the status of stdout. 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: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c2d93a803acef634bd0eede6673aeea59e90c277 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=c2d93a803acef634bd0eede6673aeea59e90c277 commit c2d93a803acef634bd0eede6673aeea59e90c277 Author: Dag-Erling Smørgrav AuthorDate: 2024-10-08 17:01:46 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-10-08 17:01:46 +0000 env: Check the status of stdout. MFC after: 3 days Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D47009 --- usr.bin/env/env.c | 2 ++ usr.bin/env/tests/env_test.sh | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/usr.bin/env/env.c b/usr.bin/env/env.c index bb83baee114f..10e333602ee8 100644 --- a/usr.bin/env/env.c +++ b/usr.bin/env/env.c @@ -214,6 +214,8 @@ main(int argc, char **argv) } for (ep = environ; *ep; ep++) (void)printf("%s%c", *ep, term); + if (fflush(stdout) != 0) + err(1, "stdout"); exit(0); } diff --git a/usr.bin/env/tests/env_test.sh b/usr.bin/env/tests/env_test.sh index d49765a04f9a..2dc8f1a4c911 100644 --- a/usr.bin/env/tests/env_test.sh +++ b/usr.bin/env/tests/env_test.sh @@ -130,6 +130,22 @@ chdir_body() env -C "${subdir}" pwd } +atf_test_case stdout +stdout_head() +{ + atf_set descr "Failure to write to stdout" +} +stdout_body() +{ + ( + trap "" PIPE + env 2>stderr + echo $? >result + ) | true + atf_check -o inline:"1\n" cat result + atf_check -o match:"stdout" cat stderr +} + atf_init_test_cases() { atf_add_test_case basic @@ -140,4 +156,5 @@ atf_init_test_cases() atf_add_test_case altpath atf_add_test_case equal atf_add_test_case chdir + atf_add_test_case stdout }