[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.11 and 1.12

version 1.11, 2016/10/28 07:22:59 version 1.12, 2017/07/11 13:14:59
Line 32 
Line 32 
   
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/stat.h>  #include <sys/stat.h>
   #include <sys/queue.h>
   
 #include <err.h>  #include <err.h>
 #include <errno.h>  #include <errno.h>
Line 43 
Line 44 
 #include <unistd.h>  #include <unistd.h>
   
 struct list {  struct list {
         struct list *next;          SLIST_ENTRY(list) next;
         int fd;          int fd;
         char *name;          char *name;
 };  };
 struct list *head;  SLIST_HEAD(, list) head;
   
 static void  static void
 add(int fd, char *name)  add(int fd, char *name)
Line 58 
Line 59 
                 err(1, NULL);                  err(1, NULL);
         p->fd = fd;          p->fd = fd;
         p->name = name;          p->name = name;
         p->next = head;          SLIST_INSERT_HEAD(&head, p, next);
         head = p;  
 }  }
   
 int  int
Line 75 
Line 75 
         if (pledge("stdio wpath cpath", NULL) == -1)          if (pledge("stdio wpath cpath", NULL) == -1)
                 err(1, "pledge");                  err(1, "pledge");
   
           SLIST_INIT(&head);
   
         append = 0;          append = 0;
         while ((ch = getopt(argc, argv, "ai")) != -1) {          while ((ch = getopt(argc, argv, "ai")) != -1) {
                 switch(ch) {                  switch(ch) {
Line 109 
Line 111 
                 err(1, "pledge");                  err(1, "pledge");
   
         while ((rval = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {          while ((rval = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
                 for (p = head; p; p = p->next) {                  SLIST_FOREACH(p, &head, next) {
                         n = rval;                          n = rval;
                         bp = buf;                          bp = buf;
                         do {                          do {
Line 127 
Line 129 
                 exitval = 1;                  exitval = 1;
         }          }
   
         for (p = head; p; p = p->next) {          SLIST_FOREACH(p, &head, next) {
                 if (close(p->fd) == -1) {                  if (close(p->fd) == -1) {
                         warn("%s", p->name);                          warn("%s", p->name);
                         exitval = 1;                          exitval = 1;

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12