forkfd: fix calling the old signal handler when there wasn't one

On some stupid systems, execve() may clear the handler but not clear
the SA_SIGINFO flag.

This change now requires that sa_handler and sa_sigaction be in a union
together. We can't operate otherwise.

Task-number: QTBUG-59246
Change-Id: I33850dcdb2ce4a47878efffd14a84b48a8f6b1e8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Thiago Macieira 2017-03-02 22:27:32 -08:00
parent a1c27748d2
commit 37fd42459e

View File

@ -297,10 +297,12 @@ static void sigchld_handler(int signum, siginfo_t *handler_info, void *handler_c
* But we pass them anyway. Let's call the chained handler first, while
* those two arguments have a chance of being correct.
*/
if (old_sigaction.sa_flags & SA_SIGINFO)
old_sigaction.sa_sigaction(signum, handler_info, handler_context);
else if (old_sigaction.sa_handler != SIG_IGN && old_sigaction.sa_handler != SIG_DFL)
old_sigaction.sa_handler(signum);
if (old_sigaction.sa_handler != SIG_IGN && old_sigaction.sa_handler != SIG_DFL) {
if (old_sigaction.sa_flags & SA_SIGINFO)
old_sigaction.sa_sigaction(signum, handler_info, handler_context);
else
old_sigaction.sa_handler(signum);
}
if (ffd_atomic_load(&forkfd_status, FFD_ATOMIC_RELAXED) == 1) {
/* is this one of our children? */