version 1.13, 2021/11/21 16:15:43 |
version 1.14, 2021/12/13 18:33:23 |
|
|
#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; |
|
|
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"); |
|
|
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); |
|
|
} |
} |
} |
} |
} |
} |
|
free(buf); |
if (rval == -1) { |
if (rval == -1) { |
warn("read"); |
warn("read"); |
exitval = 1; |
exitval = 1; |