Page MenuHomeFreeBSD

D47020.id144505.diff
No OneTemporary

D47020.id144505.diff

diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c
--- a/usr.bin/cmp/cmp.c
+++ b/usr.bin/cmp/cmp.c
@@ -92,6 +92,13 @@
return (true);
}
+static void
+check_stdout(void)
+{
+ if (fflush(stdout) != 0)
+ err(ERR_EXIT, "stdout");
+}
+
int
main(int argc, char *argv[])
{
@@ -197,6 +204,8 @@
if (sflag && skip1 == 0 && skip2 == 0)
zflag = true;
+ atexit(check_stdout);
+
if (fd1 == -1) {
if (fd2 == -1) {
c_link(file1, skip1, file2, skip2, limit);
diff --git a/usr.bin/cmp/tests/cmp_test2.sh b/usr.bin/cmp/tests/cmp_test2.sh
--- a/usr.bin/cmp/tests/cmp_test2.sh
+++ b/usr.bin/cmp/tests/cmp_test2.sh
@@ -133,6 +133,24 @@
cmp -bl a b
}
+atf_test_case stdout
+stdout_head()
+{
+ atf_set descr "Failure to write to stdout"
+}
+stdout_body()
+{
+ echo a >a
+ echo b >b
+ (
+ trap "" PIPE
+ cmp a b 2>stderr
+ echo $? >result
+ ) | true
+ atf_check -o inline:"2\n" cat result
+ atf_check -o match:"stdout" cat stderr
+}
+
atf_init_test_cases()
{
atf_add_test_case special
@@ -141,4 +159,5 @@
atf_add_test_case skipsuff
atf_add_test_case limit
atf_add_test_case bflag
+ atf_add_test_case stdout
}

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 28, 9:44 AM (10 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32266640
Default Alt Text
D47020.id144505.diff (1 KB)

Event Timeline