Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Clarification for the handling of sigwaitinfo()

7 views
Skip to first unread message

Markus Elfring

unread,
Nov 16, 2013, 10:16:42 AM11/16/13
to
Hello,

I try to wait for various signals in a dedicated thread on my openSUSE system as
you can see it from the attached source file.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigwaitinfo.html

I wonder why this small test program does not work as expected so far. I get the
error message "my_receiver: Signal wait failed." after a signal was sent to the
corresponding process.

I would appreciate your advices.

Regards,
Markus
sigwait.c

Chris Vine

unread,
Nov 16, 2013, 3:23:21 PM11/16/13
to
I may have missed it (the code is quite dense) but I could not see
on a quick read where you blocked asynchronous delivery of the signal to
the process, so that sigwait() could pick it up.

Chris

Markus Elfring

unread,
Nov 17, 2013, 4:50:16 AM11/17/13
to
> I may have missed it (the code is quite dense) but I could not see
> on a quick read where you blocked asynchronous delivery of the signal to
> the process, so that sigwait() could pick it up.

I thought that my function call "pthread_sigmask(SIG_SETMASK, &signal_set,
NULL)" does this. Did I interpret the return value of the function "sigwaitinfo"
in the wrong way here?

Regards,
Markus

Chris Vine

unread,
Nov 17, 2013, 6:11:01 AM11/17/13
to
So you did, and you preceded it with sigfillset(), so that is fine.

Yes I think it is the return value of sigwaitinfo() which you are
interpreting incorrectly. According to POSIX:

"Upon successful completion (that is, one of the signals specified by
set is pending or is generated) sigwaitinfo() ... shall return the
selected signal number. Otherwise, the function shall return a value of
-1 and set errno to indicate the error."

I presume here "return the selected signal number" means really return,
not (in the case of success) providing it via the 'info' out parameter
(which it is also required to do if not NULL). Since no signal number
has value 0, neither success nor failure will return 0.

This is quite confusing, as sigwait() does return 0 in case of success
and provide the signal number via its out parameter.

Chris

Markus Elfring

unread,
Nov 17, 2013, 7:30:31 AM11/17/13
to
> Yes I think it is the return value of sigwaitinfo() which you are
> interpreting incorrectly.

Thanks for your feedback.

My source file seems to work as expected after a small adjustment.

Regards,
Markus
sigwait.c
0 new messages