mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 23:16:14 +01:00
Revert "gmain: Use alternate signal stack if the application provides one"
This reverts commit 280c8d41fb
.
It breaks the unit tests on macOS (see #3314) and no fix has been
forthcoming.
The alternate stack changes can be resubmitted once they include a
working unit test on macOS, as evidently its treatment of alternate
stacks differs from that on Linux, and hence needs testing.
Helps: #3314
This commit is contained in:
parent
3ac632b406
commit
3bf2875ce4
@ -5670,9 +5670,6 @@ ref_unix_signal_handler_unlocked (int signum)
|
||||
action.sa_flags = SA_RESTART | SA_NOCLDSTOP;
|
||||
#else
|
||||
action.sa_flags = SA_NOCLDSTOP;
|
||||
#endif
|
||||
#ifdef SA_ONSTACK
|
||||
action.sa_flags |= SA_ONSTACK;
|
||||
#endif
|
||||
sigaction (signum, &action, NULL);
|
||||
}
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "glib-unix.h"
|
||||
#include "gstdio.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
@ -508,7 +507,6 @@ on_sig_received_2 (gpointer data)
|
||||
static void
|
||||
test_signal (int signum)
|
||||
{
|
||||
struct sigaction action;
|
||||
GMainLoop *mainloop;
|
||||
int id;
|
||||
|
||||
@ -517,17 +515,6 @@ test_signal (int signum)
|
||||
sig_received = FALSE;
|
||||
sig_counter = 0;
|
||||
g_unix_signal_add (signum, on_sig_received, mainloop);
|
||||
|
||||
g_assert_no_errno (sigaction (signum, NULL, &action));
|
||||
|
||||
g_assert_true (action.sa_flags & SA_NOCLDSTOP);
|
||||
#ifdef SA_RESTART
|
||||
g_assert_true (action.sa_flags & SA_RESTART);
|
||||
#endif
|
||||
#ifdef SA_ONSTACK
|
||||
g_assert_true (action.sa_flags & SA_ONSTACK);
|
||||
#endif
|
||||
|
||||
kill (getpid (), signum);
|
||||
g_assert (!sig_received);
|
||||
id = g_timeout_add (5000, on_sig_timeout, mainloop);
|
||||
@ -567,46 +554,6 @@ test_sigterm (void)
|
||||
test_signal (SIGTERM);
|
||||
}
|
||||
|
||||
static void
|
||||
test_signal_alternate_stack (int signal)
|
||||
{
|
||||
#ifndef SA_ONSTACK
|
||||
g_test_skip ("alternate stack is not supported");
|
||||
#else
|
||||
guint8 stack_memory[MINSIGSTKSZ];
|
||||
guint8 zero_mem[MINSIGSTKSZ];
|
||||
stack_t stack = { .ss_sp = stack_memory, .ss_size = MINSIGSTKSZ };
|
||||
stack_t old_stack = { 0 };
|
||||
|
||||
memset (stack_memory, 0, MINSIGSTKSZ);
|
||||
memset (zero_mem, 0, MINSIGSTKSZ);
|
||||
g_assert_cmpmem (stack_memory, MINSIGSTKSZ, zero_mem, MINSIGSTKSZ);
|
||||
|
||||
g_assert_no_errno (sigaltstack (&stack, &old_stack));
|
||||
|
||||
test_signal (signal);
|
||||
|
||||
/* Very stupid check to ensure that the alternate stack is used instead of
|
||||
* the default one. This test would fail if SA_ONSTACK wouldn't be set.
|
||||
*/
|
||||
g_assert_cmpint (memcmp (stack_memory, zero_mem, MINSIGSTKSZ), !=, 0);
|
||||
|
||||
g_assert_no_errno (sigaltstack (&old_stack, NULL));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
test_sighup_alternate_stack (void)
|
||||
{
|
||||
test_signal_alternate_stack (SIGHUP);
|
||||
}
|
||||
|
||||
static void
|
||||
test_sigterm_alternate_stack (void)
|
||||
{
|
||||
test_signal_alternate_stack (SIGTERM);
|
||||
}
|
||||
|
||||
static void
|
||||
test_sighup_add_remove (void)
|
||||
{
|
||||
@ -860,9 +807,6 @@ main (int argc,
|
||||
g_test_add_func ("/glib-unix/sighup", test_sighup);
|
||||
g_test_add_func ("/glib-unix/sigterm", test_sigterm);
|
||||
g_test_add_func ("/glib-unix/sighup_again", test_sighup);
|
||||
g_test_add_func ("/glib-unix/sighup/alternate-stack", test_sighup_alternate_stack);
|
||||
g_test_add_func ("/glib-unix/sigterm/alternate-stack", test_sigterm_alternate_stack);
|
||||
g_test_add_func ("/glib-unix/sighup_again/alternate-stack", test_sighup_alternate_stack);
|
||||
g_test_add_func ("/glib-unix/sighup_add_remove", test_sighup_add_remove);
|
||||
g_test_add_func ("/glib-unix/sighup_nested", test_sighup_nested);
|
||||
g_test_add_func ("/glib-unix/callback_after_signal", test_callback_after_signal);
|
||||
|
Loading…
Reference in New Issue
Block a user