1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

env: Check the status of stdout.

MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D47009
This commit is contained in:
Dag-Erling Smørgrav 2024-10-08 19:01:46 +02:00
parent 6f6166e49c
commit c2d93a803a
2 changed files with 19 additions and 0 deletions

2
usr.bin/env/env.c vendored
View File

@ -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);
}

View File

@ -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
}