Fix signal handler from getting stuck in an endless loop

The signal handler for SIGINT/TERM/QUIT and, importantly, SIGPIPE tries
to write an informational message to stderr. When however stderr is
redirected to a closed pipe, this will cause (another) SIGPIPE, and in
turn the signal handler will get called again, and again and again.

Since we intend to exit rtl_fm anyways, we can just ignore this signal.
This commit is contained in:
Tobias Girstmair 2022-11-18 16:20:14 +01:00 committed by Steve Markgraf
parent 5e73f90f1d
commit 142325a93c
6 changed files with 6 additions and 0 deletions

View File

@ -123,6 +123,7 @@ sighandler(int signum)
#else
static void sighandler(int signum)
{
signal(SIGPIPE, SIG_IGN);
fprintf(stderr, "Signal caught, exiting!\n");
do_exit = 1;
rtlsdr_cancel_async(dev);

View File

@ -246,6 +246,7 @@ sighandler(int signum)
#else
static void sighandler(int signum)
{
signal(SIGPIPE, SIG_IGN);
fprintf(stderr, "Signal caught, exiting!\n");
do_exit = 1;
rtlsdr_cancel_async(dongle.dev);

View File

@ -195,6 +195,7 @@ sighandler(int signum)
#else
static void sighandler(int signum)
{
signal(SIGPIPE, SIG_IGN);
do_exit++;
multi_bail();
}

View File

@ -74,6 +74,7 @@ sighandler(int signum)
#else
static void sighandler(int signum)
{
signal(SIGPIPE, SIG_IGN);
fprintf(stderr, "Signal caught, exiting!\n");
do_exit = 1;
rtlsdr_cancel_async(dev);

View File

@ -144,6 +144,7 @@ sighandler(int signum)
#else
static void sighandler(int signum)
{
signal(SIGPIPE, SIG_IGN);
fprintf(stderr, "Signal caught, exiting!\n");
rtlsdr_cancel_async(dev);
do_exit = 1;

View File

@ -115,6 +115,7 @@ sighandler(int signum)
#else
static void sighandler(int signum)
{
signal(SIGPIPE, SIG_IGN);
fprintf(stderr, "Signal caught, exiting!\n");
do_exit = 1;
rtlsdr_cancel_async(dev);