|
|
@ -5,31 +5,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]);
|
|
|
|
int main(int argc, char *argv[]);
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
|
|
|
initfd(int fd2, const char *path, uint32_t open_flags) {
|
|
|
|
|
|
|
|
int fd1;
|
|
|
|
|
|
|
|
if ((fd1 = open(path, open_flags)) < 0) {
|
|
|
|
|
|
|
|
return fd1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int ret = fd1;
|
|
|
|
|
|
|
|
if (fd1 != fd2) {
|
|
|
|
|
|
|
|
close(fd2);
|
|
|
|
|
|
|
|
ret = dup2(fd1, fd2);
|
|
|
|
|
|
|
|
close(fd1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
umain(int argc, char *argv[]) {
|
|
|
|
umain(int argc, char *argv[]) {
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
if ((fd = initfd(0, "stdin:", O_RDONLY)) < 0) {
|
|
|
|
|
|
|
|
warn("open <stdin> failed: %e.\n", fd);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((fd = initfd(1, "stdout:", O_WRONLY)) < 0) {
|
|
|
|
|
|
|
|
warn("open <stdout> failed: %e.\n", fd);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int ret = main(argc, argv);
|
|
|
|
int ret = main(argc, argv);
|
|
|
|
exit(ret);
|
|
|
|
exit(ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|