[BACK]Return to tee.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tee

Diff for /src/usr.bin/tee/tee.c between version 1.13 and 1.14

version 1.13, 2021/11/21 16:15:43 version 1.14, 2021/12/13 18:33:23
Line 43 
Line 43 
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   
   #define BSIZE (64 * 1024)
   
 struct list {  struct list {
         SLIST_ENTRY(list) next;          SLIST_ENTRY(list) next;
         int fd;          int fd;
Line 69 
Line 71 
         int fd;          int fd;
         ssize_t n, rval, wval;          ssize_t n, rval, wval;
         int append, ch, exitval;          int append, ch, exitval;
         char buf[8192];          char *buf;
   
         if (pledge("stdio wpath cpath", NULL) == -1)          if (pledge("stdio wpath cpath", NULL) == -1)
                 err(1, "pledge");                  err(1, "pledge");
Line 109 
Line 111 
         if (pledge("stdio", NULL) == -1)          if (pledge("stdio", NULL) == -1)
                 err(1, "pledge");                  err(1, "pledge");
   
         while ((rval = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {          buf = malloc(BSIZE);
           if (buf == NULL)
                   err(1, NULL);
           while ((rval = read(STDIN_FILENO, buf, BSIZE)) > 0) {
                 SLIST_FOREACH(p, &head, next) {                  SLIST_FOREACH(p, &head, next) {
                         for (n = 0; n < rval; n += wval) {                          for (n = 0; n < rval; n += wval) {
                                 wval = write(p->fd, buf + n, rval - n);                                  wval = write(p->fd, buf + n, rval - n);
Line 121 
Line 126 
                         }                          }
                 }                  }
         }          }
           free(buf);
         if (rval == -1) {          if (rval == -1) {
                 warn("read");                  warn("read");
                 exitval = 1;                  exitval = 1;

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14