add "make help"
[oweals/busybox.git] / coreutils / tee.c
index 25c108725c885f41c6bbfd64808bd987b011a8da..ba2e10f90d166965f2a869b2750d6b024ae36eae 100644 (file)
@@ -38,7 +38,7 @@ int tee_main(int argc, char **argv)
        int flags;
        int retval = EXIT_SUCCESS;
 #ifdef CONFIG_FEATURE_TEE_USE_BLOCK_IO
-       size_t c;
+       ssize_t c;
        RESERVE_CONFIG_BUFFER(buf, BUFSIZ);
 #else
        int c;
@@ -78,12 +78,16 @@ int tee_main(int argc, char **argv)
        *p = NULL;                              /* Store the sentinal value. */
 
 #ifdef CONFIG_FEATURE_TEE_USE_BLOCK_IO
-       while ((c = read(0, buf, BUFSIZ)) != 0) {
+       while ((c = safe_read(STDIN_FILENO, buf, BUFSIZ)) > 0) {
                for (p=files ; *p ; p++) {
                        fwrite(buf, 1, c, *p);
                }
        }
 
+       if (c < 0) {                    /* Make sure read errors are signaled. */
+               retval = EXIT_FAILURE;
+       }
+
 #ifdef CONFIG_FEATURE_CLEAN_UP
        RELEASE_CONFIG_BUFFER(buf);
 #endif