version 1.11, 2016/10/28 07:22:59 |
version 1.12, 2017/07/11 13:14:59 |
|
|
|
|
#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> |
|
|
#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) |
|
|
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 |
|
|
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) { |
|
|
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 { |
|
|
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; |