|
|
@ -939,8 +939,8 @@ main(int argc, char **argv) |
|
|
|
|
|
|
|
|
case 'o': /* Output file */ |
|
|
case 'o': /* Output file */ |
|
|
if (optarg) { |
|
|
if (optarg) { |
|
|
/* turn off buffering for stdout */ |
|
|
|
|
|
setbuf(stdout, NULL); |
|
|
|
|
|
|
|
|
/* switch to line buffering for stdout */ |
|
|
|
|
|
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); |
|
|
sprintf (log_file, "%s", optarg); |
|
|
sprintf (log_file, "%s", optarg); |
|
|
orflag = TRUE; |
|
|
orflag = TRUE; |
|
|
} |
|
|
} |
|
|
@ -950,6 +950,8 @@ main(int argc, char **argv) |
|
|
iflag = TRUE; |
|
|
iflag = TRUE; |
|
|
istty = TRUE; |
|
|
istty = TRUE; |
|
|
ft_pipemode = TRUE; |
|
|
ft_pipemode = TRUE; |
|
|
|
|
|
/* switch to line buffering for stdout */ |
|
|
|
|
|
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case 'q': /* Command completion */ |
|
|
case 'q': /* Command completion */ |
|
|
@ -1013,11 +1015,13 @@ main(int argc, char **argv) |
|
|
} |
|
|
} |
|
|
// oflag = TRUE; /* All further output to -o log file */ |
|
|
// oflag = TRUE; /* All further output to -o log file */ |
|
|
#else |
|
|
#else |
|
|
/* Connect stdout to file log_file and log stdout */ |
|
|
|
|
|
|
|
|
/* Connect stdout and stderr to file log_file and log stdout */ |
|
|
if (!freopen (log_file, "w", stdout)) { |
|
|
if (!freopen (log_file, "w", stdout)) { |
|
|
perror (log_file); |
|
|
perror (log_file); |
|
|
sp_shutdown (EXIT_BAD); |
|
|
sp_shutdown (EXIT_BAD); |
|
|
} |
|
|
} |
|
|
|
|
|
dup2(fileno(stdout), fileno(stderr)); |
|
|
|
|
|
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* enable line buffering */ |
|
|
#endif |
|
|
#endif |
|
|
} /* orflag */ |
|
|
} /* orflag */ |
|
|
|
|
|
|
|
|
|