зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1837907 [Linux] Enable AppShell SIGTERM signal handler for Firefox r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D194183
This commit is contained in:
Родитель
ca66547202
Коммит
ff8cc581ed
|
@ -431,6 +431,10 @@ int main(int argc, char* argv[], char* envp[]) {
|
|||
mozilla::CreateAndStorePreXULSkeletonUI(GetModuleHandle(nullptr), argc, argv);
|
||||
#endif
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
setenv("MOZ_ENABLE_APPSHELL_SIG_HANDLER", "1", true);
|
||||
#endif
|
||||
|
||||
nsresult rv = InitXPCOMGlue(LibLoadingStrategy::ReadAhead);
|
||||
if (NS_FAILED(rv)) {
|
||||
return 255;
|
||||
|
|
|
@ -332,6 +332,15 @@ void nsAppShell::TermSignalHandler(int signo) {
|
|||
}
|
||||
|
||||
void nsAppShell::InstallTermSignalHandler() {
|
||||
if (!PR_GetEnv("MOZ_ENABLE_APPSHELL_SIG_HANDLER")) {
|
||||
return;
|
||||
}
|
||||
unsetenv("MOZ_ENABLE_APPSHELL_SIG_HANDLER");
|
||||
|
||||
if (!XRE_IsParentProcess() || PR_GetEnv("MOZ_DISABLE_SIG_HANDLER")) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct sigaction act = {}, oldact;
|
||||
act.sa_handler = TermSignalHandler;
|
||||
sigfillset(&act.sa_mask);
|
||||
|
@ -446,9 +455,7 @@ nsresult nsAppShell::Init() {
|
|||
mTag = g_source_attach(source, nullptr);
|
||||
g_source_unref(source);
|
||||
|
||||
if (XRE_IsParentProcess() && !PR_GetEnv("MOZ_DISABLE_SIG_HANDLER")) {
|
||||
InstallTermSignalHandler();
|
||||
}
|
||||
InstallTermSignalHandler();
|
||||
|
||||
return nsBaseAppShell::Init();
|
||||
failed:
|
||||
|
@ -476,6 +483,11 @@ void nsAppShell::ScheduleNativeEventCallback() {
|
|||
Unused << write(mPipeFDs[1], buf, 1);
|
||||
}
|
||||
|
||||
void nsAppShell::ScheduleQuitEvent() {
|
||||
unsigned char buf[] = {QUIT_TOKEN};
|
||||
Unused << write(mPipeFDs[1], buf, 1);
|
||||
}
|
||||
|
||||
bool nsAppShell::ProcessNextNativeEvent(bool mayWait) {
|
||||
if (mSuspendNativeCount) {
|
||||
return false;
|
||||
|
@ -483,8 +495,3 @@ bool nsAppShell::ProcessNextNativeEvent(bool mayWait) {
|
|||
bool didProcessEvent = g_main_context_iteration(nullptr, mayWait);
|
||||
return didProcessEvent;
|
||||
}
|
||||
|
||||
void nsAppShell::ScheduleQuitEvent() {
|
||||
unsigned char buf[] = {QUIT_TOKEN};
|
||||
Unused << write(mPipeFDs[1], buf, 1);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче