diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/yes.c | 22 |
2 files changed, 19 insertions, 6 deletions
@@ -21,6 +21,9 @@ GNU coreutils NEWS -*- outline -*- seq now immediately exits upon write errors. [This bug was present in "the beginning".] + yes now handles short writes, rather than assuming all writes complete. + [bug introduced in coreutils-8.24] + ** Changes in behavior seq no longer accepts 0 value as increment, and now also rejects NaN @@ -101,12 +101,22 @@ main (int argc, char **argv) memcpy (pbuf, pbuf - line_len, line_len); pbuf += line_len; } - - while (0 <= write (STDOUT_FILENO, buf, pbuf - buf)) - continue; - - error (0, errno, _("standard output")); - return EXIT_FAILURE; + } + while (operandp == operand_lim) + { + char const* pwrite = buf; + size_t to_write = pbuf - buf; + while (to_write) + { + ssize_t written = write (STDOUT_FILENO, pwrite, to_write); + if (written < 0) + { + error (0, errno, _("standard output")); + return EXIT_FAILURE; + } + to_write -= written; + pwrite += written; + } } /* If the data doesn't fit in BUFSIZ then output |