mirror of
https://github.com/coreutils/coreutils.git
synced 2026-10-28 09:44:34 +08:00
truncate: don't hang with --reference=FIFO
* NEWS: Mention the fix. * src/truncate.c (main): Open the reference with O_NONBLOCK. * tests/truncate/truncate-fifo.sh: Also cover --reference=FIFO.
This commit is contained in:
1 parent
162ddbe972
commit
95de5f1372
3 files changed
+11
-1
No files matched your search
@@ -58,6 +58,9 @@ GNU coreutils NEWS -*- outline -*-
|
||||
with an error.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
'truncate --reference=R' no longer hangs when R is a FIFO with no readers.
|
||||
[bug introduced in coreutils-8.17]
|
||||
|
||||
'unexpand -t' no longer overflows a heap buffer, for tab values > SIZE_MAX/16,
|
||||
or with multi-byte blank characters longer than the tab value.
|
||||
[bugs introduced in coreutils-9.11]
|
||||
|
||||
+2
-1
@@ -326,7 +326,8 @@ main (int argc, char **argv)
|
||||
file_size = sb.st_size;
|
||||
else
|
||||
{
|
||||
int ref_fd = open (ref_file, O_RDONLY);
|
||||
/* O_NONBLOCK so we do not hang forever on a FIFO with no writer. */
|
||||
int ref_fd = open (ref_file, O_RDONLY | O_NONBLOCK);
|
||||
if (0 <= ref_fd)
|
||||
{
|
||||
off_t file_end = lseek (ref_fd, 0, SEEK_END);
|
||||
|
||||
@@ -21,7 +21,13 @@ print_ver_ truncate
|
||||
|
||||
mkfifo_or_skip_ fifo
|
||||
|
||||
# Output FIFO must not hang.
|
||||
timeout 10 truncate -s0 fifo
|
||||
test "$?" = 124 && fail=1
|
||||
|
||||
# Reference FIFO must not hang either.
|
||||
touch file || framework_failure_
|
||||
timeout 10 truncate --reference=fifo file 2>/dev/null
|
||||
test "$?" = 124 && fail=1
|
||||
|
||||
Exit $fail
|
||||
Reference in new issue
Block a user