From 37fd42459e98fe84234ecf65083fc75096a75b52 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 2 Mar 2017 22:27:32 -0800 Subject: [PATCH] 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 --- src/3rdparty/forkfd/forkfd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index 309458a3a7..8113fdb9e7 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -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? */