version 1.1, 2018/11/30 07:08:24 |
version 1.2, 2019/06/28 13:35:02 |
|
|
ifd = STDIN_FILENO; |
ifd = STDIN_FILENO; |
else { |
else { |
ifd = open(ifile, O_RDONLY, 0); |
ifd = open(ifile, O_RDONLY, 0); |
if (ifd < 0) { |
if (ifd == -1) { |
perror(ifile); |
perror(ifile); |
return 1; |
return 1; |
} |
} |
|
|
ofd = STDOUT_FILENO; |
ofd = STDOUT_FILENO; |
else { |
else { |
ofd = open(ofile, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
ofd = open(ofile, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
if (ofd < 0) { |
if (ofd == -1) { |
perror(ofile); |
perror(ofile); |
return 1; |
return 1; |
} |
} |
|
|
} |
} |
} |
} |
|
|
if (pledge("stdio", NULL) < 0) |
if (pledge("stdio", NULL) == -1) |
err(1, "pledge"); |
err(1, "pledge"); |
|
|
/* transfer until end-of-file or error */ |
/* transfer until end-of-file or error */ |
|
|
len = read(ifd, buf, sizeof(buf)); |
len = read(ifd, buf, sizeof(buf)); |
if (len == 0) |
if (len == 0) |
break; |
break; |
if (len < 0) { |
if (len == -1) { |
perror("stdin"); |
perror("stdin"); |
break; |
break; |
} |
} |