bug-wget
[Top][All Lists]
Advanced

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

Re: [Bug-wget] Feature: Disabling progress bar when wget is backgrounded


From: Darshit Shah
Subject: Re: [Bug-wget] Feature: Disabling progress bar when wget is backgrounded
Date: Mon, 21 Sep 2015 19:38:01 +0530

This patch has a couple of deficiencies that need to be addressed.

1. The point of the --show-progress switch is to override all other
settings and display a progress bar on screen. This patch does not
take into consideration the --show-progress switch.

2. After this patch, Wget will *never* display a progress bar if it is
invoked from a shell script / another C program. This not only changes
the default behaviour, it is also not something we want. Running the
Perl / Python tests singularly will display this effect. With this
patch in the next release, there will be way too many people
complaining about a missing progress bar.

>From `man tcgetpgrp`:

    The  function tcgetpgrp() returns the process group ID of the
foreground process group on the terminal associated to fd, which must
be the controlling terminal of the calling process.

But, when wget is invoked from within a shell script, its pid != ppid
This causes progress bar to disappear.

If someone wants to background a Wget process, let them use SIGHUP to handle it.
There is also Giuseppe's response on the mailing list which is present
in the links provided by Noel Koethe. We should not change the default
behaviour of Wget. Especially one which helps identify a very common
mistake by many people.

Since the patch in its current form causes more problems than it
solves, I'm reverting it right now. We can discuss an alternative
strategy here and if it works, a new patch can be applied later.

On Thu, Sep 10, 2015 at 1:57 PM, Tim Ruehsen <address@hidden> wrote:
> Thanks, the patch has been pushed.
>
> Regards, Tim
>
> On Wednesday 09 September 2015 10:03:14 Tim Ruehsen wrote:
>> Thanks, Christian.
>>
>> I made a few tests (on Linux) with --progress=bar, ctrl-z + 'bg'. Than put
>> wget to foreground again with 'fg'. Doing it again and again with a good
>> user experience from my side.
>>
>> A very short and elegant patch !
>>
>> If nobody complains, I'll push it.
>>
>> Regards, Tim
>>
>> On Tuesday 08 September 2015 16:29:18 Christian Neukirchen wrote:
>> > Hi,
>> >
>> > Sometimes I start wget, but the remote site is too slow, so I rather
>> > want to run it in background, however when I simply use job control
>> > for that, wget will keep spewing the progress bar all over my
>> > terminal.  I have found the SIGHUP/SIGUSR1 feature to redirect output
>> > to a log file, but I think the following small patch is even more
>> > useful, since the progress bar will simply resume when wget is
>> > foregrounded again (also, the final message is still printed to the
>> > terminal in any case):
>> >
>> > --- src/progress.c
>> > +++ src/progress.c
>> > @@ -1179,10 +1179,12 @@ create_image (struct bar_progress *bp, double
>> > dl_total_time, bool done) static void
>> >
>> >  display_image (char *buf)
>> >  {
>> >
>> > -  bool old = log_set_save_context (false);
>> > -  logputs (LOG_PROGRESS, "\r");
>> > -  logputs (LOG_PROGRESS, buf);
>> > -  log_set_save_context (old);
>> > +  if (tcgetpgrp (fileno (stderr)) == getpid ()) {
>> > +    bool old = log_set_save_context (false);
>> > +    logputs (LOG_PROGRESS, "\r");
>> > +    logputs (LOG_PROGRESS, buf);
>> > +    log_set_save_context (old);
>> > +  }
>> >
>> >  }
>> >
>> >  static void
>> >
>> > This probably needs some guards for portability to all platforms.
>> > Only tested on Linux 4.1 so far.
>> >
>> > Opinions?
>
>



-- 
Thanking You,
Darshit Shah



reply via email to

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