[PATCH] Clean up correctly on more signals
Mike Crowe
mac at mcrowe.com
Mon Oct 20 07:05:07 PDT 2014
On Monday 20 October 2014 at 14:23:53 +0100, dinkypumpkin wrote:
> On 20/10/2014 13:20, Mike Crowe wrote:
> >Ensure that everything is cleaned up even if get_iplayer is killed by other
> >signals.
> >
> >Signed-off-by: Mike Crowe <mac at mcrowe.com>
> >---
> > get_iplayer | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/get_iplayer b/get_iplayer
> >index 6225c74..5079742 100755
> >--- a/get_iplayer
> >+++ b/get_iplayer
> >@@ -573,7 +573,7 @@ for ( progclass() ) {
> > }
> >
> > # Setup signal handlers
> >-$SIG{INT} = $SIG{PIPE} = \&cleanup;
> >+$SIG{TERM} = $SIG{HUP} = $SIG{ALRM} = $SIG{INT} = $SIG{PIPE} = \&cleanup;
> >
> > # Other Non option-dependant vars
> > my $historyfile = "${profile_dir}/download_history";
> >
>
> Signal handlers get reset and restored in run_cmd(). Did you
> intentionally leave that code as-is? It seems like you would want
> to handle HUP and ALRM there as well. That's where get_iplayer
> spends most of its time, running rtmpdump.
This patch is rather old. I added it during a time that my Internet
connection was rather unreliable and I was killing off get_iplayer after a
certain period of time so that it didn't consume bandwidth during the
day. Perhaps it didn't help as much as I thought it did. I'll have another
look at it more carefully.
Even on the brief second look now I realise that SIGALRM isn't very helpful
in this case anyway. It would seem logical for SIGHUP and SIGTERM to be
treated similarly to SIGINT though.
Sorry for the noise.
Mike.
More information about the get_iplayer
mailing list