From: Thomas Huth <thuth@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: "Bin Meng" <bin.meng@windriver.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PULL 15/16] tests/qtest: libqtest: Install signal handler via signal()
Date: Wed, 12 Oct 2022 16:33:15 +0200 [thread overview]
Message-ID: <20221012143316.988561-16-thuth@redhat.com> (raw)
In-Reply-To: <20221012143316.988561-1-thuth@redhat.com>
From: Bin Meng <bin.meng@windriver.com>
At present the codes uses sigaction() to install signal handler with
a flag SA_RESETHAND. Such usage can be covered by the signal() API
that is a simplified interface to the general sigaction() facility.
Update to use signal() to install the signal handler, as it is
available on Windows which we are going to support.
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20221006151927.2079583-11-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/libqtest.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 7b6152807b..b23eb3edc3 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -66,7 +66,7 @@ struct QTestState
};
static GHookList abrt_hooks;
-static struct sigaction sigact_old;
+static void (*sighandler_old)(int);
static int qtest_query_target_endianness(QTestState *s);
@@ -179,20 +179,12 @@ static void sigabrt_handler(int signo)
static void setup_sigabrt_handler(void)
{
- struct sigaction sigact;
-
- /* Catch SIGABRT to clean up on g_assert() failure */
- sigact = (struct sigaction){
- .sa_handler = sigabrt_handler,
- .sa_flags = SA_RESETHAND,
- };
- sigemptyset(&sigact.sa_mask);
- sigaction(SIGABRT, &sigact, &sigact_old);
+ sighandler_old = signal(SIGABRT, sigabrt_handler);
}
static void cleanup_sigabrt_handler(void)
{
- sigaction(SIGABRT, &sigact_old, NULL);
+ signal(SIGABRT, sighandler_old);
}
static bool hook_list_is_empty(GHookList *hook_list)
--
2.31.1
next prev parent reply other threads:[~2022-10-12 14:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 14:33 [PULL 00/16] qtest patches (and one unit test and one avocado fix) Thomas Huth
2022-10-12 14:33 ` [PULL 01/16] qtest: "-display none" is set in qtest_init() Thomas Huth
2022-10-12 14:33 ` [PULL 02/16] tests/migration: remove the unused local variable Thomas Huth
2022-10-12 14:33 ` [PULL 03/16] tests/x86: add helper qtest_qmp_device_del_send() Thomas Huth
2022-10-12 14:33 ` [PULL 04/16] tests/x86: Add subtest with 'q35' machine type to device-plug-test Thomas Huth
2022-10-12 14:33 ` [PULL 05/16] tests/x86: Refactor hot unplug hd-geo-test Thomas Huth
2022-10-12 14:33 ` [PULL 06/16] tests/x86: Add 'q35' machine type to override-tests in hd-geo-test Thomas Huth
2022-10-12 14:33 ` [PULL 07/16] tests/x86: Add 'q35' machine type to hotplug hd-geo-test Thomas Huth
2022-10-12 14:33 ` [PULL 08/16] tests/x86: Fix comment typo in drive_del-test Thomas Huth
2022-10-12 14:33 ` [PULL 09/16] tests/x86: replace snprint() by g_strdup_printf() " Thomas Huth
2022-10-12 14:33 ` [PULL 10/16] tests/x86: Add 'q35' machine type to drive_del-test Thomas Huth
2022-10-12 14:33 ` [PULL 11/16] tests/x86: Add 'q35' machine type to ivshmem-test Thomas Huth
2022-10-12 14:33 ` [PULL 12/16] tests/avocado: Add missing require_netdev('user') checks Thomas Huth
2022-10-12 14:33 ` [PULL 13/16] qtest: start a VNC test Thomas Huth
2022-10-12 14:33 ` [PULL 14/16] tests/qtest: migration-test: Avoid using hardcoded /tmp Thomas Huth
2022-10-12 14:33 ` Thomas Huth [this message]
2022-10-12 14:33 ` [PULL 16/16] tests/unit/test-image-locking: Fix handling of temporary files Thomas Huth
2022-10-13 20:29 ` [PULL 00/16] qtest patches (and one unit test and one avocado fix) Stefan Hajnoczi
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=20221012143316.988561-16-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=bin.meng@windriver.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).