version 1.44, 2019/08/17 14:25:06 |
version 1.45, 2019/12/02 22:17:32 |
|
|
fromfd = open(from, O_RDONLY); |
fromfd = open(from, O_RDONLY); |
if (fromfd == -1) |
if (fromfd == -1) |
pfatal("internal error, can't reopen %s", from); |
pfatal("internal error, can't reopen %s", from); |
while ((i = read(fromfd, buf, sizeof buf)) > 0) |
while ((i = read(fromfd, buf, bufsz)) > 0) |
if (write(STDOUT_FILENO, buf, i) != i) |
if (write(STDOUT_FILENO, buf, i) != i) |
pfatal("write failed"); |
pfatal("write failed"); |
close(fromfd); |
close(fromfd); |
|
|
fromfd = open(from, O_RDONLY, 0); |
fromfd = open(from, O_RDONLY, 0); |
if (fromfd == -1) |
if (fromfd == -1) |
pfatal("internal error, can't reopen %s", from); |
pfatal("internal error, can't reopen %s", from); |
while ((i = read(fromfd, buf, sizeof buf)) > 0) |
while ((i = read(fromfd, buf, bufsz)) > 0) |
if (write(tofd, buf, i) != i) |
if (write(tofd, buf, i) != i) |
pfatal("write to %s failed", to); |
pfatal("write to %s failed", to); |
close(fromfd); |
close(fromfd); |
|
|
if (ttyfd < 0) |
if (ttyfd < 0) |
ttyfd = open(_PATH_TTY, O_RDONLY); |
ttyfd = open(_PATH_TTY, O_RDONLY); |
if (ttyfd >= 0) { |
if (ttyfd >= 0) { |
if ((nr = read(ttyfd, buf, sizeof(buf))) > 0 && |
if ((nr = read(ttyfd, buf, bufsz)) > 0 && |
buf[nr - 1] == '\n') |
buf[nr - 1] == '\n') |
buf[nr - 1] = '\0'; |
buf[nr - 1] = '\0'; |
} |
} |