You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
checking for interactive input e.g. from TTY or pipe is best done right after opening a file, this checks the file type to set the input to non-blocking for TTY, pipes, and sockets, then registering the non-blocking input-following handler later; this change also prevents unnecessary repeated checks when reading zip/tar archived files
if (!flag_decompress && !flag_quiet && !flag_files_with_matches && !flag_count)
3519
+
{
3520
+
int fd = fileno(file_in);
3521
+
struct stat buf;
3522
+
3523
+
// if input is a character device (e.g. TTY) or a pipe, then make it non-blocking and register a stdin handler to continue reading and flush results to output, don't check for invalid Unicode input
// for Windows we don't check for invalid Unicode input, no stdin handler
3529
+
if (input == stdin && !flag_quiet && !flag_files_with_matches && !flag_count)
3530
+
interactive = true;
3531
+
#endif
3532
+
3513
3533
return true;
3514
3534
}
3515
3535
@@ -3903,9 +3923,6 @@ struct Grep {
3903
3923
matches = 0;
3904
3924
stop = false;
3905
3925
3906
-
// "interactive" and possibly slow input from a standard input device or pipe
3907
-
bool interactive = false;
3908
-
3909
3926
const char *base;
3910
3927
size_t size;
3911
3928
@@ -3930,23 +3947,9 @@ struct Grep {
3930
3947
#endif
3931
3948
3932
3949
#ifndef OS_WIN
3933
-
if (!flag_decompress && !flag_quiet && !flag_files_with_matches && !flag_count)
3934
-
{
3935
-
int fd = fileno(file_in);
3936
-
struct stat buf;
3937
-
3938
-
// if input is a character device (e.g. TTY) or a pipe, then make it non-blocking and register a stdin handler to continue reading and flush results to output, don't check for invalid Unicode input
0 commit comments