gmain: Use alternate signal stack if the application provides one

Some applications, toolkits or languages may define an alternative stack
to use for traces. This is for example the case of go.

So, in case an application defines an alternate signal stack, GLib should
use that instead of the default one to receive signals otherwise it may
break the application expectations and write where it's not allowed to.
This commit is contained in:
Marco Trevisan (Treviño)
2024-03-25 20:28:21 +01:00
parent 4607dd77a1
commit 137db219a7
2 changed files with 59 additions and 0 deletions

View File

@@ -5670,6 +5670,9 @@ 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);
}