mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 171343 - use SA_SIGINFO and sa_sigaction when hooking up FatalSignalHandler() so that we don't lose parameters if there are other handlers which want all 3 arguments. r=ccarlen, sr=brendan.
This commit is contained in:
parent
50be3cbecb
commit
16b3767234
@ -1625,7 +1625,11 @@ static struct sigaction SIGABRT_oldact;
|
||||
static struct sigaction SIGSEGV_oldact;
|
||||
static struct sigaction SIGTERM_oldact;
|
||||
|
||||
void nsProfileLock::FatalSignalHandler(int signo)
|
||||
// There is no standard type definition for the type of sa_sigaction.
|
||||
typedef void (*my_sigaction_t)(int, siginfo_t*, void*);
|
||||
|
||||
void nsProfileLock::FatalSignalHandler(int signo, siginfo_t* info,
|
||||
void* context)
|
||||
{
|
||||
// Remove any locks still held.
|
||||
RemovePidLockFiles();
|
||||
@ -1660,12 +1664,22 @@ void nsProfileLock::FatalSignalHandler(int signo)
|
||||
break;
|
||||
}
|
||||
|
||||
if (oldact &&
|
||||
oldact->sa_handler &&
|
||||
oldact->sa_handler != SIG_DFL &&
|
||||
oldact->sa_handler != SIG_IGN)
|
||||
{
|
||||
oldact->sa_handler(signo);
|
||||
if (oldact) {
|
||||
if (oldact->sa_flags & SA_SIGINFO) {
|
||||
if (oldact->sa_sigaction &&
|
||||
oldact->sa_sigaction != (my_sigaction_t) SIG_DFL &&
|
||||
oldact->sa_sigaction != (my_sigaction_t) SIG_IGN)
|
||||
{
|
||||
oldact->sa_sigaction(signo, info, context);
|
||||
}
|
||||
} else {
|
||||
if (oldact->sa_handler &&
|
||||
oldact->sa_handler != SIG_DFL &&
|
||||
oldact->sa_handler != SIG_IGN)
|
||||
{
|
||||
oldact->sa_handler(signo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Backstop exit call, just in case.
|
||||
@ -1929,14 +1943,16 @@ nsresult nsProfileLock::Lock(nsILocalFile* aFile)
|
||||
// Don't arm a handler if the signal is being ignored, e.g.,
|
||||
// because mozilla is run via nohup.
|
||||
struct sigaction act, oldact;
|
||||
act.sa_handler = FatalSignalHandler;
|
||||
act.sa_flags = 0;
|
||||
act.sa_sigaction = FatalSignalHandler;
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
sigfillset(&act.sa_mask);
|
||||
|
||||
#define CATCH_SIGNAL(signame) \
|
||||
PR_BEGIN_MACRO \
|
||||
if (sigaction(signame, NULL, &oldact) == 0 && \
|
||||
oldact.sa_handler != SIG_IGN) \
|
||||
((oldact.sa_flags & SA_SIGINFO) ? \
|
||||
(oldact.sa_sigaction != (my_sigaction_t) SIG_IGN) : \
|
||||
(oldact.sa_handler != SIG_IGN))) \
|
||||
{ \
|
||||
sigaction(signame, &act, &signame##_oldact); \
|
||||
} \
|
||||
|
@ -33,6 +33,10 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef XP_UNIX
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
class ProfileStruct
|
||||
{
|
||||
public:
|
||||
@ -198,7 +202,8 @@ private:
|
||||
LHANDLE mLockFileHandle;
|
||||
#elif defined (XP_UNIX)
|
||||
static void RemovePidLockFiles();
|
||||
static void FatalSignalHandler(int signo);
|
||||
static void FatalSignalHandler(int signo, siginfo_t* info,
|
||||
void* context);
|
||||
static PRCList mPidLockList;
|
||||
char* mPidLockFileName;
|
||||
int mLockFileDesc;
|
||||
|
Loading…
Reference in New Issue
Block a user