Files
coreutils/tests/tee/write-eagain.sh
T
Collin Funk 0d6fcb99d6 tee: fix infinite loop when write returns EAGAIN and short write errors
* NEWS: Mention the bug fixes.
* THANKS.in: Add Bernhard M. Wiedemann for reporting the bugs.
* src/iopoll.c (close_wait): Remove function.
(write_wait): Don't call wait_for_nonblocking_write if write is
successful. Handle errors more robustly.
* src/iopoll.h (close_wait): Remove declaration.
* src/tee.c (tee_files): Use close instead of close_wait.
* tests/tee/short-write.sh: New test for the bug.
* tests/tee/write-eagain.sh: Likewise.
* tests/local.mk (all_tests): Add the new tests.
Fixes https://bugs.gnu.org/81060
2026-05-18 20:50:48 -07:00

32 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Test 'tee' when a write fails with errno set to EAGAIN.
# Copyright (C) 2026 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tee
require_strace_ write
# In coreutils-9.11 the following test would infinite loop.
echo a >exp || framework_failure_
timeout 10 strace -qqq -o /dev/null -e trace-fds=3 \
-e inject=write:error=EAGAIN:when=1 tee file1 <exp >out 2>err || fail=1
compare exp file1 || fail=1
compare exp out || fail=1
compare /dev/null err || fail=1
Exit $fail