Skip to content

Commit

Permalink
Fix signal handler from getting stuck in an endless loop
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Tobias Girstmair authored and steve-m committed Dec 17, 2022
1 parent 5e73f90 commit 142325a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/rtl_adsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/rtl_fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/rtl_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ sighandler(int signum)
#else
static void sighandler(int signum)
{
signal(SIGPIPE, SIG_IGN);
do_exit++;
multi_bail();
}
Expand Down
1 change: 1 addition & 0 deletions src/rtl_sdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/rtl_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/rtl_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 142325a

Please sign in to comment.