linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jemma Denson <jdenson@gmail.com>
To: mchehab@osg.samsung.com
Cc: linux-media@vger.kernel.org
Subject: [v4l-utils PATCH-v2 4/4] dvbv5-zap.c: Move common signals code into function
Date: Fri, 18 Dec 2015 14:28:26 +0000	[thread overview]
Message-ID: <1450448906-17000-5-git-send-email-jdenson@gmail.com> (raw)
In-Reply-To: <1450448906-17000-1-git-send-email-jdenson@gmail.com>

Code repeated 3 times; move to common function.

Signed-off-by: Jemma Denson <jdenson@gmail.com>
---
 utils/dvb/dvbv5-zap.c | 33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/utils/dvb/dvbv5-zap.c b/utils/dvb/dvbv5-zap.c
index 2d71307..ef17be9 100644
--- a/utils/dvb/dvbv5-zap.c
+++ b/utils/dvb/dvbv5-zap.c
@@ -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;
-- 
2.1.0


      parent reply	other threads:[~2015-12-18 14:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18 14:28 Patches to dvbv5-zap Jemma Denson
2015-12-18 14:28 ` [v4l-utils PATCH-v2 1/4] dvbv5-zap.c: fix setting signal handlers Jemma Denson
2015-12-18 14:28 ` [v4l-utils PATCH-v2 2/4] dvbv5-zap.c: allow timeout with -x Jemma Denson
2015-12-18 14:28 ` [v4l-utils PATCH-v2 3/4] dvbv5-zap.c: fix wrong signal Jemma Denson
2015-12-18 14:28 ` Jemma Denson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450448906-17000-5-git-send-email-jdenson@gmail.com \
    --to=jdenson@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).