Tidy up QTest::FatalSignalHandler
Rename some variables: avoid abbreviated names. (Don't bother with renaming variables an imminent commit removes, though.) Pick-to: 6.2 6.3 Change-Id: I3bd11f37ca687047555d43dff83c3c2f935135d8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
fcecaf53f5
commit
38a86afcc4
@ -1727,8 +1727,8 @@ public:
|
|||||||
// Block all fatal signals in our signal handler so we don't try to close
|
// Block all fatal signals in our signal handler so we don't try to close
|
||||||
// the testlog twice.
|
// the testlog twice.
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
for (int sig : fatalSignals)
|
for (int signal : fatalSignals)
|
||||||
sigaddset(&act.sa_mask, sig);
|
sigaddset(&act.sa_mask, signal);
|
||||||
|
|
||||||
// The destructor can only restore SIG_DFL, so only register for signals
|
// The destructor can only restore SIG_DFL, so only register for signals
|
||||||
// that had default handling previously.
|
// that had default handling previously.
|
||||||
@ -1744,14 +1744,14 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct sigaction oldact;
|
struct sigaction oldact;
|
||||||
for (int sig : fatalSignals) {
|
for (int signal : fatalSignals) {
|
||||||
// Registering reveals the existing handler:
|
// Registering reveals the existing handler:
|
||||||
if (sigaction(sig, &act, &oldact))
|
if (sigaction(signal, &act, &oldact))
|
||||||
continue; // Failed to set our handler; nothing to restore.
|
continue; // Failed to set our handler; nothing to restore.
|
||||||
if (isDefaultHandler(oldact))
|
if (isDefaultHandler(oldact))
|
||||||
sigaddset(&handledSignals, sig);
|
sigaddset(&handledSignals, signal);
|
||||||
else // Restore non-default handler:
|
else // Restore non-default handler:
|
||||||
sigaction(sig, &oldact, nullptr);
|
sigaction(signal, &oldact, nullptr);
|
||||||
}
|
}
|
||||||
#endif // defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
|
#endif // defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
|
||||||
}
|
}
|
||||||
@ -1772,16 +1772,16 @@ public:
|
|||||||
return old.sa_handler == FatalSignalHandler::signal;
|
return old.sa_handler == FatalSignalHandler::signal;
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
struct sigaction oldact;
|
struct sigaction action;
|
||||||
|
|
||||||
for (int i = 1; i < 32; ++i) {
|
for (int signum = 1; signum < 32; ++signum) {
|
||||||
if (!sigismember(&handledSignals, i))
|
if (!sigismember(&handledSignals, signum))
|
||||||
continue;
|
continue;
|
||||||
if (sigaction(i, nullptr, &oldact))
|
if (sigaction(signum, nullptr, &action))
|
||||||
continue; // Failed to query present handler
|
continue; // Failed to query present handler
|
||||||
|
|
||||||
if (isOurs(oldact))
|
if (isOurs(action))
|
||||||
sigaction(i, &act, nullptr);
|
sigaction(signum, &act, nullptr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user