REVISITED: Signal delivered while blocked
Houder
houder@xs4all.nl
Wed Aug 16 21:22:00 GMT 2017
Hi,
Please read this post first:
https://cygwin.com/ml/cygwin/2017-08/msg00048.html
( Signal delivered while blocked -- by Noah Misch, August 4th 2017 )
This post is not intended to "hijack" the post by Noah Misch; this post
only
ships an alternative (i.e. revised) testcase for the one by provided by
Noah
Misch.
The alternative testcase in fact consists of 2 testcases (2 files):
1. sigprocmask-exclusion4.c
2. sigprocmask-exclusion5.c
The 1st testcase uses sigaction() (i.c. sa_mask) in order to keep both
signal
handlers "out of each other's hair".
The 2nd testcase achieves this by protecting the "vital part" of each of
the
signal handlers using sigprocmask() ...
Using sigprocmask() and SIG_BLOCK (1st argument), the other signal is
added
to the signal mask at the start of the "vital part" of the signal
handler.
To restore the signal mask at the end of the "vital part" of the
handler, it
is possible to choose between the following options:
a. using sigprocmask() and SIG_SETMASK in order to reinstate the mask
as it
was at the beginning of the "vital part" of the handler
b. using sigprocmask() and SIG_UNBLOCK to remove the other signal from
the
signal mask
Both testcases confirm that Cygwin _sometimes_ delivers a signal,
although
the signal mask specifies (verified by the test case) it should not.
Typical runs:
64-@@ ./sigprocmask-exclusion4
-
pid=2728 inundating pid=3504 with SIGUSR1 and SIGCHLD
--
ERROR: handler2: No 1 running
cnt_usr1 = 424, cnt_chld = 305, cnt_int = 0
ERROR: handler2: No 1 running
cnt_usr1 = 1212, cnt_chld = 1262, cnt_int = 0
ERROR: handler: No 2 running
cnt_usr1 = 4341, cnt_chld = 3827, cnt_int = 0
ERROR: handler: No 2 running
cnt_usr1 = 5289, cnt_chld = 4171, cnt_int = 0
ERROR: handler: No 2 running
cnt_usr1 = 5499, cnt_chld = 4354, cnt_int = 0
ERROR: handler: No 2 running
cnt_usr1 = 6769, cnt_chld = 6295, cnt_int = 0
ERROR: handler2: nesting self!
cnt_usr1 = 10463, cnt_chld = 9243, cnt_int = 0
ERROR: handler2: nesting self!
cnt_usr1 = 12390, cnt_chld = 10869, cnt_int = 0
ERROR: handler: No 2 running
cnt_usr1 = 14046, cnt_chld = 14771, cnt_int = 0
ERROR: handler2: No 1 running
cnt_usr1 = 16111, cnt_chld = 15785, cnt_int = 0
cnt_usr1 = 16959, cnt_chld = 16790, cnt_int = 1
child done
xcnt_usr1 = 13295798, xcnt_chld = 13295797
64-@@
64-@@ ./sigprocmask-exclusion5
-
--
pid=4132 inundating pid=5976 with SIGUSR1 and SIGCHLD
ERROR: handler: No 2 running
cnt_usr1 = 1, cnt_chld = 2, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 228, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 1444, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 1585, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 1830, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 2588, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 2719, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 2795, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 3332, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 3340, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 3353, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 4130, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 4136, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 5256, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 6548, cnt_chld = 6, cnt_int = 0
ERROR: handler: nesting self!
cnt_usr1 = 8292, cnt_chld = 6, cnt_int = 0
cnt_usr1 = 11223, cnt_chld = 6, cnt_int = 1
child done
xcnt_usr1 = 4149717, xcnt_chld = 4149717
64-@@
Both runs were terminated by SIGINT (^C).
When running for an extended period (hours), the run-away stack did not
show
up (Linux).
Environment:
64-@@ uname -a
CYGWIN_NT-6.1 Seven 2.9.0(0.316/5/3) x86_64 Cygwin
64-@@ gcc --version
gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE
Regards,
Henri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sigprocmask-exclusion4.c
Type: text/x-c
Size: 8685 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20170816/e99c42ad/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sigprocmask-exclusion5.c
Type: text/x-c
Size: 10252 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20170816/e99c42ad/attachment-0001.bin>
-------------- next part --------------
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list