summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2015-09-18 11:50:41 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2015-09-18 13:01:06 +0200
commit3adde88a642a7e3018ab53adf082d51cb326be94 (patch)
treefadc7b2c70e99847c3ff7866991c085c120d34f0
parent59b387bb38e6b434d572d17c744cd0a48647c8af (diff)
downloadcanutils-3adde88a642a7e3018ab53adf082d51cb326be94.tar.gz
cansequence: use sigaction() instead of signal
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r--src/cansequence.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cansequence.c b/src/cansequence.c
index 6fa3abb..d916576 100644
--- a/src/cansequence.c
+++ b/src/cansequence.c
@@ -70,7 +70,7 @@ static void print_usage(char *prg)
prg, CAN_ID_DEFAULT);
}
-static void sigterm(int signo)
+static void sig_handler(int signo)
{
running = false;
}
@@ -208,6 +208,9 @@ static void do_send()
int main(int argc, char **argv)
{
+ struct sigaction act = {
+ .sa_handler = sig_handler,
+ };
struct ifreq ifr;
struct sockaddr_can addr;
char *interface = "can0";
@@ -216,8 +219,9 @@ int main(int argc, char **argv)
int receive = 0;
int opt;
- signal(SIGTERM, sigterm);
- signal(SIGHUP, sigterm);
+ sigaction(SIGINT, &act, NULL);
+ sigaction(SIGTERM, &act, NULL);
+ sigaction(SIGHUP, &act, NULL);
struct option long_options[] = {
{ "extended", no_argument, 0, 'e' },