X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:to:subject:message-id:reply-to
	:references:mime-version:content-type:in-reply-to; q=dns; s=
	default; b=CtlXtpEOKjNLKk3tSpe2j33iGtWdQsRzfqaUwr3j8yyKVA0hDlqkm
	pF/4mYorHzC6/iXmfujQQqHaYRYa7xXGGNBdToZ5wlot4x1WfYkTStxH9Qgmcpfh
	X1lHLC+u9uIbp7tnbkSDV7za3J/0j+Qv6I/I1OoFx4GfJlP8e0Ry0U=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:to:subject:message-id:reply-to
	:references:mime-version:content-type:in-reply-to; s=default;
	 bh=X9IIsRVF7eMvcF6POjfrbXtnt0g=; b=kfd+hrBiN5lwxvPA8TQCmLESIzGk
	GPZi8ctNzamsH0loeMVyE5tcy3AtQ4CSX2crWBZGHA/qXdONYN993uW4sY5At+M0
	c49daNWZT3dRpaaNoEwSs8yQTvJAJeNpmMZAXL9W1uabeDwQGkH/LuQWf/n63zZM
	haL4tUkqvXmqx0U=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-101.7 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=k, provisions, sko, blocked
X-HELO: mout.kundenserver.de
Date: Wed, 3 Apr 2019 14:15:55 +0200
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: uc_sigmask set in a sigaction signal handler not honored
Message-ID: <20190403121555.GV3337@calimero.vinschen.de>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <366918d8-b505-45be-dc28-303579f17341@gmail.com>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;	protocol="application/pgp-signature"; boundary="JaBjgNvtdKe5H086"
Content-Disposition: inline
In-Reply-To: <366918d8-b505-45be-dc28-303579f17341@gmail.com>
User-Agent: Mutt/1.11.3 (2019-02-01)

--JaBjgNvtdKe5H086
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Apr  3 11:27, Petr Sko=C4=8D=C3=ADk wrote:
> Hi. Correct me if I'm wrong but POSIX appears to define
>=20
> https://pubs.opengroup.org/onlinepubs/7908799/xsh/ucontext.h.html
>=20
> as, among other things, containing the field:
>=20
> sigset_t    uc_sigmask  the set of signals that are blocked when this
>                         context is active
>=20
> and it also specifies that the third argument to a .sa_sigaction
> signal handler is a ucontext_t* cast to void*.
>=20
> So it should follow that doing
>=20
> void act(int Sig, siginfo_t *Info, void *Uctx)
> {
> 	ucontext_t *uctx =3D Uctx;
> 	sigfillset(&uctx->uc_sigmask);
> }
>=20
> from a signal handler should alter the signal mask of the thread the
> signal ran on.
>=20
> This is how Linux and MacOS behave, but not CygWin, as the following
> program shows:

What you're asking for is really complicated.

The context given to act is the context at the time the signal function
is called.  In Cygwin (lower case w) this is a copy of the context.

sigfillset() has not the faintest clue where this context comes from, it
just sets the signal mask value without taking any further action.

There are no provisions to control if the called function changes the
context, other than via setcontext / swapcontext, and I don't see that
POSIX requires anything else.  Both functions change the current
thread's sigmask according to the value of uc_sigmask.


HTH,
Corinna

--=20
Corinna Vinschen
Cygwin Maintainer

--JaBjgNvtdKe5H086
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlyko/sACgkQ9TYGna5E
T6D0Ew/6A98DJoEc/j/eJuo9uteZBn4CQTsSS2peXanQloP8yC5Q4Ie79ZRZXtPf
7t/uWb/k2Hy+mHy9ahxPBLqIXnBaAwIdkuYGz7M2OTCBHZvu+rbJYb7zqC5j7MlQ
uHTfGirVInmlnGLosvwb+jb1ERnCxVk5WbvqscYvlmNViV5ZIc+J8aVASBPqsz8z
Ft6AphcDayUO8aTmAbsM9Ej3T0Y9nwMcOeIJ+JOwy/aUxtR2LTL6d+fxkLUovRNx
Gi9cQ+IihbF92NNCDAqSBebuxOHHjxe9tpbYJij2C0zDt4cR+EJV7nUf1ZGi0NNG
J6rJkmtXeV2TyiiNcTL/fwymqqGTFzBLaHJJFOtezjOXLWUHy43SDtpyiaaZP0sG
oTapu33FwdTMIxYbt21rVQkQq82RAmwt0xH6/97z8f+GKVPQ8iNTlBK0+3AGW6Dg
SparYzKQPjKbkwnnN72o1eB0HCMXF8VZmfQgksW3VIFeVDaBSBrQcP/ZV/VrInns
wE/DWapBTJBdW7VsHnvcBfhgJjq1RpxRrOJXkJnHrhsrE04fNXIM9us4WENIYb/h
LuE7IA7pbEIW5EOm+ZjRyrchKRZ4oBLT2jUw2y3qqhZ+DE1plOcMIDbyAIT5NYMx
0cmfG3zd0FfkqDjSaEZn0KithtfiVk54lUUG2OYzIRhoTGUrWTE=
=KSVJ
-----END PGP SIGNATURE-----

--JaBjgNvtdKe5H086--
