I am working on the signal handler
to deal with reap signals, randomly I am getting the signal with offset when I call sigwaitinfo
function. All the signal attributes are right, except for info.si_addr
. This offset in info.si_addr
is causing a segmentation fault.
This offset seems to be the same - I have tried removing the offset and that works, but I need a correct solution to go forward.
static void *signalHandler(void *vptr_args __attribute__((unused)))
{
sigset_t signal_set;
siginfo_t info;
sigemptyset(&signal_set);
sigaddset(&signal_set, SIG_REAP);
sigaddset(&signal_set, SIG_ISOC_CANCEL);
sigaddset(&signal_set, SIGTERM);
sigaddset(&signal_set, SIGPIPE);
while (true) {
int rc = sigwaitinfo(&signal_set, &info);
//...
if (rc > 0)
{
if(info.si_signo == SIG_REAP)
{
// Reap URBs after some simple checks
if ((info.si_code != SI_ASYNCIO) &&
(info.si_code != SI_KERNEL)) {
printf("Bad si_code %d in SIG_REAP", info.si_code);
continue;
}
else {
printf("OK si_code %d in SIG_REAP", info.si_code);
}
struct usbdevfs_urb *ioctl_urb = (struct usbdevfs_urb*)info.si_addres
if (!ioctl_urb) {
printf("SIG_REAP gave NULL ioctl_urb");
continue;
}
UrbInfo *urbInfo = ioctl_urb->usercontext;
if (!urbInfo) {
printf("SIG_REAP gave NULL urbInfo");
continue;
}