sigpending() incorrectly returns signals pending on other threads

Kenton Varda kenton@cloudflare.com
Sat Jul 6 22:46:00 GMT 2019


Hello Cygwin,

According to the (Linux) man page: "sigpending() returns the set of
signals that are pending for delivery to the calling thread"

However, on Cygwin, sigpending() seems to return the set of signals
pending on any thread, as shown in the attached test program.

Among other things, this can cause deadlocks in programs which use
sigpending() to check for pending signals, then use sigsuspend() to
induce delivery of the specific signals that are pending. Because the
signal is not actually pending on the current thread, sigsuspend()
will unexpectedly block, potentially forever.

Output of test program:
$ uname -srv
CYGWIN_NT-6.1 3.0.7(0.338/5/3) 2019-04-30 18:08
$ gcc -std=c11 -Wall test-sigpending.c -o test-sigpending -pthread &&
./test-sigpending
sending signal to child thread with pthread_kill()...
sigpending() says signal is pending in main thread (WRONG)
sigpending() says signal is pending in child thread (CORRECT)
received signal in child thread (CORRECT)

The program works correctly on Linux.

-Kenton
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-sigpending.c
Type: text/x-csrc
Size: 2518 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20190706/cf9f7317/attachment.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