=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tee/tee.c,v retrieving revision 1.11 retrieving revision 1.12 diff -c -r1.11 -r1.12 *** src/usr.bin/tee/tee.c 2016/10/28 07:22:59 1.11 --- src/usr.bin/tee/tee.c 2017/07/11 13:14:59 1.12 *************** *** 1,4 **** ! /* $OpenBSD: tee.c,v 1.11 2016/10/28 07:22:59 schwarze Exp $ */ /* $NetBSD: tee.c,v 1.5 1994/12/09 01:43:39 jtc Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: tee.c,v 1.12 2017/07/11 13:14:59 bluhm Exp $ */ /* $NetBSD: tee.c,v 1.5 1994/12/09 01:43:39 jtc Exp $ */ /* *************** *** 32,37 **** --- 32,38 ---- #include #include + #include #include #include *************** *** 43,53 **** #include struct list { ! struct list *next; int fd; char *name; }; ! struct list *head; static void add(int fd, char *name) --- 44,54 ---- #include struct list { ! SLIST_ENTRY(list) next; int fd; char *name; }; ! SLIST_HEAD(, list) head; static void add(int fd, char *name) *************** *** 58,65 **** err(1, NULL); p->fd = fd; p->name = name; ! p->next = head; ! head = p; } int --- 59,65 ---- err(1, NULL); p->fd = fd; p->name = name; ! SLIST_INSERT_HEAD(&head, p, next); } int *************** *** 75,80 **** --- 75,82 ---- if (pledge("stdio wpath cpath", NULL) == -1) err(1, "pledge"); + SLIST_INIT(&head); + append = 0; while ((ch = getopt(argc, argv, "ai")) != -1) { switch(ch) { *************** *** 109,115 **** err(1, "pledge"); while ((rval = read(STDIN_FILENO, buf, sizeof(buf))) > 0) { ! for (p = head; p; p = p->next) { n = rval; bp = buf; do { --- 111,117 ---- err(1, "pledge"); while ((rval = read(STDIN_FILENO, buf, sizeof(buf))) > 0) { ! SLIST_FOREACH(p, &head, next) { n = rval; bp = buf; do { *************** *** 127,133 **** exitval = 1; } ! for (p = head; p; p = p->next) { if (close(p->fd) == -1) { warn("%s", p->name); exitval = 1; --- 129,135 ---- exitval = 1; } ! SLIST_FOREACH(p, &head, next) { if (close(p->fd) == -1) { warn("%s", p->name); exitval = 1;