mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
tests/qtest: libqtest: Install signal handler via signal()
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>
This commit is contained in:
parent
e5553c1b8d
commit
969d1f6e13
1 changed files with 3 additions and 11 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue