} else {
int fd;
if (vm.count("arg1") == 0 || arg1 == "-") {
+ // Since read_fd() doesn't handle ^D from a tty stdin, don't allow it.
+ if (isatty(STDIN_FILENO)) {
+ cerr << "stdin is a tty and no file specified" << std::endl;
+ ret = 1;
+ goto out;
+ }
fd = STDIN_FILENO;
} else {
fd = open(arg1.c_str(), O_RDONLY|O_LARGEFILE, 0666);
int fd;
if (vm.count("arg2") == 0 || arg2 == "-") {
+ // Since read_fd() doesn't handle ^D from a tty stdin, don't allow it.
+ if (isatty(STDIN_FILENO)) {
+ cerr << "stdin is a tty and no file specified" << std::endl;
+ ret = 1;
+ goto out;
+ }
fd = STDIN_FILENO;
} else {
fd = open(arg2.c_str(), O_RDONLY|O_LARGEFILE, 0666);
int fd;
if (vm.count("arg2") == 0 || arg2 == "-") {
+ // Since read_fd() doesn't handle ^D from a tty stdin, don't allow it.
+ if (isatty(STDIN_FILENO)) {
+ cerr << "stdin is a tty and no file specified" << std::endl;
+ ret = 1;
+ goto out;
+ }
fd = STDIN_FILENO;
} else {
fd = open(arg2.c_str(), O_RDONLY|O_LARGEFILE, 0666);
usage(desc);
int fd;
if (vm.count("arg1") == 0 || arg1 == "-") {
+ // Since read_fd() doesn't handle ^D from a tty stdin, don't allow it.
+ if (isatty(STDIN_FILENO)) {
+ cerr << "stdin is a tty and no file specified" << std::endl;
+ ret = 1;
+ goto out;
+ }
fd = STDIN_FILENO;
} else {
fd = open(arg1.c_str(), O_RDONLY|O_LARGEFILE, 0666);