bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Wajda, Piotr
Subject: Re: [Bug-wget] bug #45790: wget prints it's progress even when background
Date: Tue, 27 Sep 2016 16:57:05 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

Hi,
The case with stopping wget is obvious. CTRL+Z and bg should make wget write to file and I can catch bg with SIGCONT. But I wonder what to do when after CTRL+Z and bg, user runs fg. In this case there's no signal between bg anf fg, and I can only check for getpgrp() == tcgetpgrp(STDOUT_FILENO) in e.g. check_redirect_output(), right? In other words, is there better approach than checking getpgrp() == tcgetpgrp(STDOUT_FILENO) before printing every line?

Thanks
Piotr

On 19/09/16 19:30, Darshit Shah wrote:
Hi Piotr,

The patch looks fine. However, when Wget is foregrounded again, the
progress bar remains invisible. When the process is foregrounded again,
you should undo the effects of `redirect_output_signal()`

* address@hidden <address@hidden> [160919 18:01]:
Hi Darshit,
Sorry for pasting patch into email incorrectly. I've send 2 other
patches before, but as attachments, so they should be fine.

Thanks
Piotr

W dniu 19.09.2016 o 17:28, Darshit Shah pisze:
Hi Piotr,

Thanks for your interest in Wget. I shall review your patch soon.
However, for future reference please do not send patches that are
pasted into the mail like this. It makes it extremely difficult for
us to apply the patch. I was unable to apply the provided diff after
simply saving your email.
Either use `git format-patch` to create a patch file that you attach
to the emails, or use `git send-email` to correctly send an inline diff.

* address@hidden <address@hidden> [160918 18:41]:
Hi,
I've implemented fix for bug #45790. Basically I used approach Noel
showed in comment.
Please check below diff if it's sane.

diff --git a/src/main.c b/src/main.c
index ac6ee2c..f324253 100644
--- a/src/main.c
+++ b/src/main.c
@@ -113,7 +113,7 @@ int numurls = 0;
  setting up gettext's message catalog using bindtextdomain and
  textdomain.  Does nothing if NLS is disabled or missing.  */

-#if defined(SIGHUP) || defined(SIGUSR1)
+#if defined(SIGHUP) || defined(SIGUSR1) || defined(SIGCONT)
/* Hangup signal handler.  When wget receives SIGHUP or SIGUSR1, it
  will proceed operation as usual, trying to write into a log file.
  If that is impossible, the output will be turned off.  */
@@ -131,12 +131,20 @@ redirect_output_signal (int sig)
 if (sig == SIGUSR1)
   signal_name = "SIGUSR1";
#endif
+#ifdef SIGCONT
+  if(sig == SIGCONT) {
+    /* If process goes to foreground, don't redirect output */
+    if(getpgrp() == tcgetpgrp(STDOUT_FILENO))
+      return;
+    signal_name = "SIGCONT";
+  }
+#endif

 log_request_redirect_output (signal_name);
 progress_schedule_redirect ();
 signal (sig, redirect_output_signal);
}
-#endif /* defined(SIGHUP) || defined(SIGUSR1) */
+#endif /* defined(SIGHUP) || defined(SIGUSR1) || defined(SIGCONT)*/

static void
i18n_initialize (void)
@@ -2003,6 +2011,9 @@ only if outputting to a regular file.\n"));
#ifdef SIGUSR1
 signal (SIGUSR1, redirect_output_signal);
#endif
+#ifdef SIGCONT
+  signal (SIGCONT, redirect_output_signal);
+#endif
#ifdef SIGPIPE
 /* Writing to a closed socket normally signals SIGPIPE, and the
    process exits.  What we want is to ignore SIGPIPE and just check

Thanks
Piotr







reply via email to

[Prev in Thread] Current Thread [Next in Thread]