From: Piotr Wajda <address@hidden>
Date: Fri, 30 Sep 2016 09:51:37 +0200
Hi, Reworked recent patch to behave correctly on fg and bg. Now user can switch
from fg to bg and vice versa and wget will select fd accordingly.
Thanks.
+ /* Initialize this values so we don't have to ask every time we print line */
+ shell_is_interactive = isatty (STDIN_FILENO);
The MS-Windows version of isatty returns non-zero when its argument
file descriptor is open on any character device. Notably, this
includes the null device, which is definitely not what we want in this
case, I think.
So I think using this logic will need to import isatty from Gnulib, or
provide an alternative implementation in mswindows.c.
static void
check_redirect_output (void)
{
- if (redirect_request == RR_REQUESTED)
+ /* If it was redirected already to log file by SIGHUP or SIGUSR1, it was
permanent */
+ if(!redirect_request_signal_name && shell_is_interactive)
{
- redirect_request = RR_DONE;
- redirect_output ();
+ if(tcgetpgrp(STDIN_FILENO) != getpgrp())
Neither tcgetpgrp nor getpgrp exist on MS-Windows.
AFAIU, this test is intended to check whether wget was backgrounded.
Since AFAIK that's not possible on MS-Windows, this test should always
return zero on Windows, so I suggest a separate predicate function
with 2 implementations: one on Windows, the other on Posix platforms.