Make it not read stdin from a terminal or write stdout to a terminal unless forced with -f.

This commit is contained in:
Con Kolivas 2011-02-21 13:26:51 +11:00
parent 29dfb16c7a
commit b06287cce5

11
main.c
View file

@ -909,6 +909,17 @@ int main(int argc, char *argv[])
sigaction(SIGTERM, &handler, 0); sigaction(SIGTERM, &handler, 0);
sigaction(SIGINT, &handler, 0); sigaction(SIGINT, &handler, 0);
if (!FORCE_REPLACE) {
if (STDIN && isatty(fileno((FILE *)stdin))) {
print_err("Will not read stdin from a terminal. Use -f to override.\n");
exit (1);
}
if (STDIN && isatty(fileno((FILE *)stdout))) {
print_err("Will not write stdout to a terminal. Use -f to override.\n");
exit (1);
}
}
gettimeofday(&start_time, NULL); gettimeofday(&start_time, NULL);
if (control.flags & (FLAG_DECOMPRESS | FLAG_TEST_ONLY)) if (control.flags & (FLAG_DECOMPRESS | FLAG_TEST_ONLY))