tail(1): Do not print bogus errno string
In the case where write(2) does not return -1, it does not initialize errno. This can happen when a broken pipe causes a short write. I attempted to adapt the submitted test case to ATF but could not figure out how to make the test run in the ATF environment. So the aborted test is left disabled, in case someone would like to run it manually or fix it. PR: 221976 Submitted by: <martin AT lispworks.com> (earlier version) Sponsored by: Dell EMC Isilon
This commit is contained in:
parent
fe8b4983b4
commit
b2b1603e17
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323123
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user