qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: "Ilya Leoshkevich" <iii@linux.ibm.com>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] tests/tcg: Test that sigreturn() does not corrupt the signal mask
Date: Mon, 21 Oct 2024 19:05:40 -0700	[thread overview]
Message-ID: <3394cdfd-16e0-4ee5-bafc-92f8e328449f@linaro.org> (raw)
In-Reply-To: <20241017125811.447961-3-iii@linux.ibm.com>

On 10/17/24 05:54, Ilya Leoshkevich wrote:
> Add a small test to prevent regressions.
> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>   tests/tcg/multiarch/sigreturn-sigmask.c | 51 +++++++++++++++++++++++++
>   1 file changed, 51 insertions(+)
>   create mode 100644 tests/tcg/multiarch/sigreturn-sigmask.c


Acked-by: Richard Henderson <richard.henderson@linaro.org>

r~

> 
> diff --git a/tests/tcg/multiarch/sigreturn-sigmask.c b/tests/tcg/multiarch/sigreturn-sigmask.c
> new file mode 100644
> index 00000000000..e6cc904898d
> --- /dev/null
> +++ b/tests/tcg/multiarch/sigreturn-sigmask.c
> @@ -0,0 +1,51 @@
> +/*
> + * Test that sigreturn() does not corrupt the signal mask.
> + * Block SIGUSR2 and handle SIGUSR1.
> + * Then sigwait() SIGUSR2, which relies on it remaining blocked.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +#include <assert.h>
> +#include <pthread.h>
> +#include <signal.h>
> +#include <stdlib.h>
> +#include <unistd.h>
> +
> +int seen_sig = -1;
> +
> +static void signal_func(int sig)
> +{
> +    seen_sig = sig;
> +}
> +
> +static void *thread_func(void *arg)
> +{
> +    kill(getpid(), SIGUSR2);
> +    return NULL;
> +}
> +
> +int main(void)
> +{
> +    struct sigaction act = {
> +        .sa_handler = signal_func,
> +    };
> +    pthread_t thread;
> +    sigset_t set;
> +    int sig;
> +
> +    assert(sigaction(SIGUSR1, &act, NULL) == 0);
> +
> +    assert(sigemptyset(&set) == 0);
> +    assert(sigaddset(&set, SIGUSR2) == 0);
> +    assert(sigprocmask(SIG_BLOCK, &set, NULL) == 0);
> +
> +    kill(getpid(), SIGUSR1);
> +    assert(seen_sig == SIGUSR1);
> +
> +    assert(pthread_create(&thread, NULL, thread_func, NULL) == 0);
> +    assert(sigwait(&set, &sig) == 0);
> +    assert(sig == SIGUSR2);
> +    assert(pthread_join(thread, NULL) == 0);
> +
> +    return EXIT_SUCCESS;
> +}



  reply	other threads:[~2024-10-22  2:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-17 12:54 [PATCH 0/2] linux-user/ppc: Fix sigmask endianness issue in sigreturn Ilya Leoshkevich
2024-10-17 12:54 ` [PATCH 1/2] " Ilya Leoshkevich
2024-10-20 21:20   ` Richard Henderson
2024-10-21  5:45   ` Philippe Mathieu-Daudé
2024-10-25 13:53   ` Michael Tokarev
2024-10-25 13:56     ` Ilya Leoshkevich
2024-10-17 12:54 ` [PATCH 2/2] tests/tcg: Test that sigreturn() does not corrupt the signal mask Ilya Leoshkevich
2024-10-22  2:05   ` Richard Henderson [this message]
2024-10-22 17:51   ` Richard Henderson
2024-10-22 17:52 ` [PATCH 0/2] linux-user/ppc: Fix sigmask endianness issue in sigreturn Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3394cdfd-16e0-4ee5-bafc-92f8e328449f@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=iii@linux.ibm.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).