From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63906 invoked by alias); 5 Apr 2019 10:17:52 -0000 Mailing-List: contact cygwin-cvs-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-cvs-owner@cygwin.com Received: (qmail 63822 invoked by uid 9078); 5 Apr 2019 10:17:52 -0000 Date: Fri, 05 Apr 2019 10:17:00 -0000 Message-ID: <20190405101752.63816.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_0-branch] Cygwin: signals: restore sigmask from context given to signal handler X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/cygwin-3_0-branch X-Git-Oldrev: b9009a58802ffe0c1419bc5f517cfb5e09b7c80b X-Git-Newrev: a5da9128ebbe2df954b43c0127f00ef0d4d15ed4 X-SW-Source: 2019-q2/txt/msg00007.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a5da9128ebbe2df954b43c0127f00ef0d4d15ed4 commit a5da9128ebbe2df954b43c0127f00ef0d4d15ed4 Author: Corinna Vinschen Date: Wed Apr 3 18:14:30 2019 +0200 Cygwin: signals: restore sigmask from context given to signal handler In case SA_SIGINFO flag is given, the signal handler may change the context and the application is supposed to pick up from the changed context. So far we don't do that, so the context given to the signal handler is basically read-only, unless the signal handler calls setcontext or swapcontext. For a start, restore the thread's signal mask from the uc_sigmask value of the context given to the signal handler. If that's feasible for Cygwin, we restore the entire context from the context changed by the signal handler in a followup patch. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/exceptions.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index da4348f..a9b3781 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1818,7 +1818,8 @@ _cygtls::call_signal_handler () incyg = true; - set_signal_mask (_my_tls.sigmask, this_oldmask); + set_signal_mask (_my_tls.sigmask, (this_sa_flags & SA_SIGINFO) + ? context.uc_sigmask : this_oldmask); if (this_errno >= 0) set_errno (this_errno); }