mask all signals in libhackrf transfer_threadproc (#1330)

* mask all signals in libhackrf transfer_threadproc

hackrf_transfer uses pause() and SIGALRM to print statistics and POSIX doesn't
specify which thread must recieve the signal, block all signals here, so we
don't interrupt their reception by hackrf_transfer or any other app which uses
the library (#1323)

* fix windows build and remove empty line
This commit is contained in:
bsdmp
2023-09-13 18:20:14 +03:00
committed by GitHub
parent dab548bf29
commit ed8a1a6f53

View File

@ -27,6 +27,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
#include <string.h>
#ifndef _WIN32
#include <unistd.h>
#include <signal.h>
#endif
#include <libusb.h>
@ -1763,6 +1764,20 @@ static void* transfer_threadproc(void* arg)
int error;
struct timeval timeout = {0, 500000};
/*
* hackrf_transfer uses pause() and SIGALRM to print statistics and
* POSIX doesn't specify which thread must recieve the signal, block all
* signals here, so we don't interrupt their reception by
* hackrf_transfer or any other app which uses the library (#1323)
*/
#ifndef _WIN32
sigset_t signal_mask;
sigfillset(&signal_mask);
if (pthread_sigmask(SIG_BLOCK, &signal_mask, NULL) != 0) {
return NULL;
}
#endif
while (device->do_exit == false) {
error = libusb_handle_events_timeout(g_libusb_context, &timeout);
if ((error != 0) && (error != LIBUSB_ERROR_INTERRUPTED)) {