[newlib-cygwin] Cygwin: raise: change to call pthread_kill

Corinna Vinschen corinna@sourceware.org
Wed Jan 30 11:19:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a52396bd079a22be539df4d63d42425413e0a51c

commit a52396bd079a22be539df4d63d42425413e0a51c
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Wed Jan 30 11:36:45 2019 +0100

    Cygwin: raise: change to call pthread_kill
    
    POSIX requires that raise(3) is equivalent to
    
      pthread_kill(pthread_self(), sig);
    
    in multi-threaded applications.  Our raise just called kill(sig).
    Fix that.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/release/3.0 | 3 +++
 winsup/cygwin/signal.cc   | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/release/3.0 b/winsup/cygwin/release/3.0
index 79affdb..49edb38 100644
--- a/winsup/cygwin/release/3.0
+++ b/winsup/cygwin/release/3.0
@@ -89,3 +89,6 @@ Bug Fixes
 
 - Disallow seteuid on disabled or locked out accounts.
   Addresses: https://cygwin.com/ml/cygwin/2019-01/msg00197.html
+
+- Fix raise to work as required by POSIX.
+  (Partially) addresses: https://cygwin.com/ml/cygwin/2019-01/msg00149.html
diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc
index abefedd..9c51ec1 100644
--- a/winsup/cygwin/signal.cc
+++ b/winsup/cygwin/signal.cc
@@ -300,7 +300,10 @@ _pinfo::kill (siginfo_t& si)
 extern "C" int
 raise (int sig)
 {
-  return kill (myself->pid, sig);
+  pthread *thread = _my_tls.tid;
+  if (!thread)
+    return kill (myself->pid, sig);
+  return pthread_kill (thread, sig);
 }
 
 static int



More information about the Cygwin-cvs mailing list