aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2017-09-01 22:37:49 +0000
committerConrad Meyer <cem@FreeBSD.org>2017-09-01 22:37:49 +0000
commitb2b1603e173e599ad7e487d5640c87fbb027be00 (patch)
tree001b2e864928bd38dfa900f1cb49ed81dc1be172 /usr.bin
parentfe8b4983b4f200c479846839b2632024136c0ff4 (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tail/extern.h12
-rwxr-xr-xusr.bin/tail/tests/tail_test.sh14
2 files changed, 23 insertions, 3 deletions
diff --git a/usr.bin/tail/extern.h b/usr.bin/tail/extern.h
index 94cc057789bf..e42fda7f6962 100644
--- a/usr.bin/tail/extern.h
+++ b/usr.bin/tail/extern.h
@@ -32,9 +32,15 @@
*/
#define WR(p, size) do { \
- if (write(STDOUT_FILENO, p, size) != (ssize_t)size) \
- oerr(); \
- } while(0)
+ ssize_t res; \
+ res = write(STDOUT_FILENO, p, size); \
+ if (res != (ssize_t)size) { \
+ if (res == -1) \
+ oerr(); \
+ else \
+ errx(1, "stdout"); \
+ } \
+} while (0)
#define TAILMAPLEN (4<<20)
diff --git a/usr.bin/tail/tests/tail_test.sh b/usr.bin/tail/tests/tail_test.sh
index 3e407ea3ff00..dcfd0b2ca781 100755
--- a/usr.bin/tail/tests/tail_test.sh
+++ b/usr.bin/tail/tests/tail_test.sh
@@ -215,6 +215,19 @@ longfile_rn2500_body()
atf_check cmp expectfile outpipe
}
+atf_test_case broken_pipe
+broken_pipe_head()
+{
+ atf_set "descr" "Do not print bogus errno based output on short writes"
+}
+broken_pipe_body()
+{
+ atf_expect_fail "Can't seem to get testcase to work in test environment. Reproduces easily in interactive shell."
+
+ seq -f '%128g' 1 1000 > ints
+ atf_check -s exit:1 -o ignore -e "inline:tail: stdout" tail -n 856 ints | awk '{ exit }'
+}
+
atf_init_test_cases()
{
@@ -230,4 +243,5 @@ atf_init_test_cases()
atf_add_test_case longfile_rc135782
atf_add_test_case longfile_rc145782_longlines
atf_add_test_case longfile_rn2500
+ #atf_add_test_case broken_pipe
}