Re: [Bug-wget] [PATCH v3] bug #45790: wget prints it's progress even when background

2016-10-06 Thread Wajda, Piotr
Sorry for incorrect Date email header in that email, I've send it from 
previously suspended virtual machine that I forgot to ntpupdate.


Piotr

On 06/10/16 09:47, losgrandes wrote:

I've updated patch to not run tcgetpgrp, getpgrp and isatty (for 
shell_is_interactive test) on windows.
I have compiled and tested on linux and (mostly*) on windows. Should be ok.

* - I was able to create working mingw env on linux, but cross-compilation 
worked for me only few times (I know, silly, I broke it somehow).
Fortunately I tested wget.exe in normal mode and background mode (-b). Was ok.
Unfortunately I haven't tested wget.exe with CTRL+Break/CTRL+C (is it really 
works on windows?).
I'm struggling with mingw, but no luck so far.

So here're my asks for you:
1. Could you be so kind and test my wget.exe with CTRL+Break?
and/or
2. Advise me with error I get while compiling:
  main.o:main.c:(.text+0x579): undefined reference to `pipe'
  url.o:url.c:(.text+0x1e78): undefined reference to `libiconv_open'
  url.o:url.c:(.text+0x1f25): undefined reference to `libiconv'
  url.o:url.c:(.text+0x1f57): undefined reference to `libiconv'
  url.o:url.c:(.text+0x1f7e): undefined reference to `libiconv_close'
  url.o:url.c:(.text+0x20ee): undefined reference to `libiconv_close'
  collect2: error: ld returned 1 exit status

This was generated by:
./configure --host=i686-w64-mingw32 --without-ssl --without-libidn 
--without-metalink --with-gpgme-prefix=/dev/null CFLAGS=-I$BUILDDIR/tmp/include 
LDFLAGS=-L$BUILDDIR/tmp/lib --with-libiconv-prefix=$BUILDDIR/tmp CFLAGS=-liconv
make

Thanks
Piotr

---
 src/log.c   | 125 +---
 src/log.h   |   1 +
 src/main.c  |   2 +-
 src/mswindows.c |   5 +--
 4 files changed, 85 insertions(+), 48 deletions(-)

diff --git a/src/log.c b/src/log.c
index a1338ca..9a84c85 100644
--- a/src/log.c
+++ b/src/log.c
@@ -80,6 +80,18 @@ as that of the covered work.  */
logging is inhibited, logfp is set back to NULL. */
 static FILE *logfp;

+/* Descriptor of the stdout|stderr */
+static FILE *stdlogfp;
+
+/* Descriptor of the wget.log* file (if created) */
+static FILE *filelogfp;
+
+/* Name of log file */
+static char *logfile;
+
+/* Is interactive shell ? */
+static int shell_is_interactive;
+
 /* A second file descriptor pointing to the temporary log file for the
WARC writer.  If WARC writing is disabled, this is NULL.  */
 static FILE *warclogfp;
@@ -611,16 +623,18 @@ log_init (const char *file, bool appendp)
 {
   if (HYPHENP (file))
 {
-  logfp = stdout;
+  stdlogfp = stdout;
+  logfp = stdlogfp;
 }
   else
 {
-  logfp = fopen (file, appendp ? "a" : "w");
-  if (!logfp)
+  filelogfp = fopen (file, appendp ? "a" : "w");
+  if (!filelogfp)
 {
   fprintf (stderr, "%s: %s: %s\n", exec_name, file, strerror 
(errno));
   exit (WGET_EXIT_GENERIC_ERROR);
 }
+  logfp = filelogfp;
 }
 }
   else
@@ -631,7 +645,8 @@ log_init (const char *file, bool appendp)
  stderr only if the user actually specifies `-O -'.  He says
  this inconsistency is harder to document, but is overall
  easier on the user.  */
-  logfp = stderr;
+  stdlogfp = stderr;
+  logfp = stdlogfp;

   if (1
 #ifdef HAVE_ISATTY
@@ -646,6 +661,11 @@ log_init (const char *file, bool appendp)
   save_context_p = true;
 }
 }
+
+#ifndef WINDOWS
+  /* Initialize this values so we don't have to ask every time we print line */
+  shell_is_interactive = isatty (STDIN_FILENO);
+#endif
 }

 /* Close LOGFP (only if we opened it, not if it's stderr), inhibit
@@ -880,59 +900,78 @@ log_cleanup (void)

 /* When SIGHUP or SIGUSR1 are received, the output is redirected
elsewhere.  Such redirection is only allowed once. */
-static enum { RR_NONE, RR_REQUESTED, RR_DONE } redirect_request = RR_NONE;
 static const char *redirect_request_signal_name;

-/* Redirect output to `wget-log'.  */
+/* Redirect output to `wget-log' or back to stdout/stderr.  */

-static void
-redirect_output (void)
+void
+redirect_output (bool to_file, const char *signal_name)
 {
-  char *logfile;
-  logfp = unique_create (DEFAULT_LOGFILE, false, );
-  if (logfp)
+  if(to_file && logfp != filelogfp)
 {
-  fprintf (stderr, _("\n%s received, redirecting output to %s.\n"),
-   redirect_request_signal_name, quote (logfile));
-  xfree (logfile);
-  /* Dump the context output to the newly opened log.  */
-  log_dump_context ();
+  if (signal_name)
+{
+  fprintf(stderr, "\n%s received.", signal_name);
+}
+  if (!filelogfp)
+{
+  filelogfp = unique_create (DEFAULT_LOGFILE, false, );
+  if (filelogfp)
+{
+  fprintf (stderr, _("\nRedirecting output to %s.\n"),
+  quote (logfile));
+  

[Bug-wget] [PATCH v3] bug #45790: wget prints it's progress even when background

2016-10-06 Thread losgrandes
I've updated patch to not run tcgetpgrp, getpgrp and isatty (for 
shell_is_interactive test) on windows.
I have compiled and tested on linux and (mostly*) on windows. Should be ok.

* - I was able to create working mingw env on linux, but cross-compilation 
worked for me only few times (I know, silly, I broke it somehow).
Fortunately I tested wget.exe in normal mode and background mode (-b). Was ok.
Unfortunately I haven't tested wget.exe with CTRL+Break/CTRL+C (is it really 
works on windows?).
I'm struggling with mingw, but no luck so far.

So here're my asks for you:
1. Could you be so kind and test my wget.exe with CTRL+Break?
and/or
2. Advise me with error I get while compiling:
  main.o:main.c:(.text+0x579): undefined reference to `pipe'
  url.o:url.c:(.text+0x1e78): undefined reference to `libiconv_open'
  url.o:url.c:(.text+0x1f25): undefined reference to `libiconv'
  url.o:url.c:(.text+0x1f57): undefined reference to `libiconv'
  url.o:url.c:(.text+0x1f7e): undefined reference to `libiconv_close'
  url.o:url.c:(.text+0x20ee): undefined reference to `libiconv_close'
  collect2: error: ld returned 1 exit status

This was generated by:
./configure --host=i686-w64-mingw32 --without-ssl --without-libidn 
--without-metalink --with-gpgme-prefix=/dev/null CFLAGS=-I$BUILDDIR/tmp/include 
LDFLAGS=-L$BUILDDIR/tmp/lib --with-libiconv-prefix=$BUILDDIR/tmp CFLAGS=-liconv
make

Thanks
Piotr

---
 src/log.c   | 125 +---
 src/log.h   |   1 +
 src/main.c  |   2 +-
 src/mswindows.c |   5 +--
 4 files changed, 85 insertions(+), 48 deletions(-)

diff --git a/src/log.c b/src/log.c
index a1338ca..9a84c85 100644
--- a/src/log.c
+++ b/src/log.c
@@ -80,6 +80,18 @@ as that of the covered work.  */
logging is inhibited, logfp is set back to NULL. */
 static FILE *logfp;
 
+/* Descriptor of the stdout|stderr */
+static FILE *stdlogfp;
+
+/* Descriptor of the wget.log* file (if created) */
+static FILE *filelogfp;
+
+/* Name of log file */
+static char *logfile;
+
+/* Is interactive shell ? */
+static int shell_is_interactive;
+
 /* A second file descriptor pointing to the temporary log file for the
WARC writer.  If WARC writing is disabled, this is NULL.  */
 static FILE *warclogfp;
@@ -611,16 +623,18 @@ log_init (const char *file, bool appendp)
 {
   if (HYPHENP (file))
 {
-  logfp = stdout;
+  stdlogfp = stdout;
+  logfp = stdlogfp;
 }
   else
 {
-  logfp = fopen (file, appendp ? "a" : "w");
-  if (!logfp)
+  filelogfp = fopen (file, appendp ? "a" : "w");
+  if (!filelogfp)
 {
   fprintf (stderr, "%s: %s: %s\n", exec_name, file, strerror 
(errno));
   exit (WGET_EXIT_GENERIC_ERROR);
 }
+  logfp = filelogfp;
 }
 }
   else
@@ -631,7 +645,8 @@ log_init (const char *file, bool appendp)
  stderr only if the user actually specifies `-O -'.  He says
  this inconsistency is harder to document, but is overall
  easier on the user.  */
-  logfp = stderr;
+  stdlogfp = stderr;
+  logfp = stdlogfp;
 
   if (1
 #ifdef HAVE_ISATTY
@@ -646,6 +661,11 @@ log_init (const char *file, bool appendp)
   save_context_p = true;
 }
 }
+
+#ifndef WINDOWS
+  /* Initialize this values so we don't have to ask every time we print line */
+  shell_is_interactive = isatty (STDIN_FILENO);
+#endif
 }
 
 /* Close LOGFP (only if we opened it, not if it's stderr), inhibit
@@ -880,59 +900,78 @@ log_cleanup (void)
 
 /* When SIGHUP or SIGUSR1 are received, the output is redirected
elsewhere.  Such redirection is only allowed once. */
-static enum { RR_NONE, RR_REQUESTED, RR_DONE } redirect_request = RR_NONE;
 static const char *redirect_request_signal_name;
 
-/* Redirect output to `wget-log'.  */
+/* Redirect output to `wget-log' or back to stdout/stderr.  */
 
-static void
-redirect_output (void)
+void
+redirect_output (bool to_file, const char *signal_name)
 {
-  char *logfile;
-  logfp = unique_create (DEFAULT_LOGFILE, false, );
-  if (logfp)
+  if(to_file && logfp != filelogfp)
 {
-  fprintf (stderr, _("\n%s received, redirecting output to %s.\n"),
-   redirect_request_signal_name, quote (logfile));
-  xfree (logfile);
-  /* Dump the context output to the newly opened log.  */
-  log_dump_context ();
+  if (signal_name)
+{
+  fprintf(stderr, "\n%s received.", signal_name);
+}
+  if (!filelogfp) 
+{
+  filelogfp = unique_create (DEFAULT_LOGFILE, false, );
+  if (filelogfp)
+{
+  fprintf (stderr, _("\nRedirecting output to %s.\n"),
+  quote (logfile));
+  /* Store signal name to tell wget it's permanent redirect to log 
file */
+  redirect_request_signal_name = signal_name;
+  logfp = filelogfp;
+   

[Bug-wget] [bug #49281] wget crash on Windows 10

2016-10-06 Thread anonymous
URL:
  

 Summary: wget crash on Windows 10
 Project: GNU Wget
Submitted by: None
Submitted on: Thu 06 Oct 2016 11:24:17 AM UTC
Category: Crash/Freeze/Infloop
Severity: 3 - Normal
Priority: 5 - Normal
  Status: None
 Privacy: Public
 Assigned to: None
 Originator Name: SUZUKI
Originator Email: 0xbadfc...@gmail.com
 Open/Closed: Open
 Discussion Lock: Any
 Release: 1.18
Operating System: Microsoft Windows
 Reproducibility: Intermittent
   Fixed Release: None
 Planned Release: None
  Regression: None
   Work Required: None
  Patch Included: No

___

Details:

OS: Windows 10 x64 version 1607 (build 14393.222)
Binary: https://eternallybored.org/misc/wget/ wget-1.18-win64.zip
Invoked command: wget --no-config
"https://software-download.microsoft.com/pr/Win10_1607_English_x32.iso?t=8a47e794-9b16-4b6b-88f8-310ae6e67bb3=1475834767=95b80dd2a78471886ab00279c1f91446;
(above URL is temporary. Generate from
https://www.microsoft.com/en-us/software-download/windows10ISO/ .)
wget crash with 0xc374 at finished download.
Sorry, but when --debug is used, couldn't reproduction.



___

File Attachments:


---
Date: Thu 06 Oct 2016 11:24:17 AM UTC  Name: wget.exe_161006_201907.dmp.gz 
Size: 118kB   By: None
Crash dump captured by ProcDump


___

Reply to this item at:

  

___
  Message sent via/by Savannah
  http://savannah.gnu.org/