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:
@ -27,6 +27,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
#endif
|
#endif
|
||||||
#include <libusb.h>
|
#include <libusb.h>
|
||||||
|
|
||||||
@ -1763,6 +1764,20 @@ static void* transfer_threadproc(void* arg)
|
|||||||
int error;
|
int error;
|
||||||
struct timeval timeout = {0, 500000};
|
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) {
|
while (device->do_exit == false) {
|
||||||
error = libusb_handle_events_timeout(g_libusb_context, &timeout);
|
error = libusb_handle_events_timeout(g_libusb_context, &timeout);
|
||||||
if ((error != 0) && (error != LIBUSB_ERROR_INTERRUPTED)) {
|
if ((error != 0) && (error != LIBUSB_ERROR_INTERRUPTED)) {
|
||||||
|
Reference in New Issue
Block a user