[PATCH 3/3] tee.2: always fail after perror(), use for(;;) instead of do{}while(1)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 man2/tee.2 | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/man2/tee.2 b/man2/tee.2
index 17b93882d..4b410ecad 100644
--- a/man2/tee.2
+++ b/man2/tee.2
@@ -171,10 +171,10 @@ main(int argc, char *argv[])
     int fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);
     if (fd == \-1) {
         perror("open");
-        exit(EXIT_FAILURE);
+        return EXIT_FAILURE;
     }
 
-    do {
+    for (;;) {
         /*
          * tee stdin to stdout.
          */
@@ -184,7 +184,7 @@ main(int argc, char *argv[])
             if (errno == EAGAIN)
                 continue;
             perror("tee");
-            exit(EXIT_FAILURE);
+            return EXIT_FAILURE;
         } else
             if (len == 0)
                 break;
@@ -197,14 +197,13 @@ main(int argc, char *argv[])
                                   len, SPLICE_F_MOVE);
             if (slen < 0) {
                 perror("splice");
-                break;
+                return EXIT_FAILURE;
             }
             len \-= slen;
         }
-    } while (1);
+    }
 
     close(fd);
-    exit(EXIT_SUCCESS);
 }
 .EE
 .SH SEE ALSO
-- 
2.30.2

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux