From 761cf00b169554c85df1be6956215ca584798e10 Mon Sep 17 00:00:00 2001 From: Kamal Mostafa Date: Tue, 2 Oct 2012 14:22:38 -0700 Subject: [PATCH] minimodem: handle SIGINT on --rx: close the sa backend and print stats --- src/minimodem.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/minimodem.c b/src/minimodem.c index 89a481e..02aeb2c 100644 --- a/src/minimodem.c +++ b/src/minimodem.c @@ -258,6 +258,15 @@ benchmarks() } +static int rx_stop = 0; + +void +rx_stop_sighandler( int sig ) +{ + rx_stop = 1; +} + + void version() { @@ -810,8 +819,13 @@ main( int argc, char*argv[] ) float track_amplitude = 0.0; + signal(SIGINT, rx_stop_sighandler); + while ( 1 ) { + if ( rx_stop ) + break; + debug_log("advance=%u\n", advance); /* Shift the samples in samplebuf by 'advance' samples */ @@ -1148,6 +1162,8 @@ main( int argc, char*argv[] ) } /* end of the main loop */ + signal(SIGINT, SIG_DFL); + if ( carrier ) { if ( !quiet_mode ) report_no_carrier(fskp, sample_rate, bfsk_data_rate,