Patches to dvbv5-zap
This patch series replaces the single patch sent earlier today. Essentially it's to allow -t to be used at the same time as -x. We have a requirement to show signal stats in a web interface and a lack of timeout would cause issues when there's no signal.
The other patches are fixing bugs I noticed in adding this and then simplifying the code slightly.
PATCH v2 1/4 dvbv5-zap.c: fix setting signal handlers
Signal handlers are currently out of order - SIGALRM is always set, and SIGINT only set when timeout is set. These should be the other way round.
--- utils/dvb/dvbv5-zap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
utils/dvb/dvbv5-zap.c +2 -2
@@ -959,10 +959,10 @@ int main(int argc, char **argv) goto err; } -signal (SIGALRM , do_timeout);signal (SIGTERM , do_timeout); +signal (SIGINT , do_timeout);if (args.timeout >0 ) { -signal (SIGINT , do_timeout); +signal (SIGALRM , do_timeout);alarm (args.timeout); }
Signature · 1 line
2.1.0
PATCH v2 2/4 dvbv5-zap.c: allow timeout with -x
In reply to Jemma DensonTimeout handlers aren't set when running with -x (exit after tuning). This patch adds handlers so -t can be used with -x.
Without a timeout dvbv5-zap will run forever if there's no signal, preventing it's use by scripts to obtain signal stats.
--- utils/dvb/dvbv5-zap.c | 7 +++++++ 1 file changed, 7 insertions(+)
utils/dvb/dvbv5-zap.c +7 -0
@@ -855,6 +855,13 @@ int main(int argc, char **argv) goto err;if (args.exit_after_tuning) { +signal (SIGTERM , do_timeout); +signal (SIGINT , do_timeout); +if (args.timeout >0 ) { +signal (SIGALRM , do_timeout); +alarm (args.timeout); + } + err =0 ;check_frontend (&args, parms); goto err;
Signature · 1 line
2.1.0
PATCH v2 3/4 dvbv5-zap.c: fix wrong signal
In reply to Jemma DensonSignal here should be SIGALRM and not SIGINT in order to call do_timeout().
--- utils/dvb/dvbv5-zap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
utils/dvb/dvbv5-zap.c +1 -1
@@ -871,7 +871,7 @@ int main(int argc, char **argv)signal (SIGTERM , do_timeout);signal (SIGINT , do_timeout);if (args.timeout >0 ) { -signal (SIGINT , do_timeout); +signal (SIGALRM , do_timeout);alarm (args.timeout); }
Signature · 1 line
2.1.0
PATCH v2 4/4 dvbv5-zap.c: Move common signals code into function
In reply to Jemma DensonCode repeated 3 times; move to common function.
--- utils/dvb/dvbv5-zap.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-)
utils/dvb/dvbv5-zap.c +13 -20
@@ -737,6 +737,16 @@ int do_traffic_monitor(struct arguments *args,return 0 ; } +static void set_signals (struct arguments *args) +{ +signal (SIGTERM , do_timeout); +signal (SIGINT , do_timeout); +if (args->timeout >0 ) { +signal (SIGALRM , do_timeout); +alarm (args->timeout); + } +} +int main (int argc,char **argv) {struct arguments args;
@@ -855,26 +865,14 @@ int main(int argc, char **argv) goto err;if (args.exit_after_tuning) { -signal (SIGTERM , do_timeout); -signal (SIGINT , do_timeout); -if (args.timeout >0 ) { -signal (SIGALRM , do_timeout); -alarm (args.timeout); - } - +set_signals (&args); err =0 ;check_frontend (&args, parms); goto err; }if (args.traffic_monitor) { -signal (SIGTERM , do_timeout); -signal (SIGINT , do_timeout); -if (args.timeout >0 ) { -signal (SIGALRM , do_timeout); -alarm (args.timeout); - } - +set_signals (&args); err =do_traffic_monitor (&args, parms); goto err; }
@@ -966,12 +964,7 @@ int main(int argc, char **argv) goto err; } -signal (SIGTERM , do_timeout); -signal (SIGINT , do_timeout); -if (args.timeout >0 ) { -signal (SIGALRM , do_timeout); -alarm (args.timeout); - } +set_signals (&args);if (!check_frontend (&args, parms)) { err =1 ;
Signature · 1 line
2.1.0