diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 9e41bcb99..932da0314 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -514,6 +514,13 @@ typedef struct _cef_settings_t { /// runtime on Windows. /// int chrome_app_icon_id; + +#if defined(OS_POSIX) && !defined(OS_ANDROID) + /// + /// Specify whether signal handlers must be disabled on POSIX systems. + /// + bool disable_signal_handlers; +#endif } cef_settings_t; /// diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index 9cc58f6c4..18ceb1bed 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -437,6 +437,10 @@ struct CefSettingsTraits { cef_string_set(src->chrome_policy_id.str, src->chrome_policy_id.length, &target->chrome_policy_id, copy); target->chrome_app_icon_id = src->chrome_app_icon_id; + +#if defined(OS_POSIX) && !defined(OS_ANDROID) + target->disable_signal_handlers = src->disable_signal_handlers; +#endif } }; diff --git a/libcef/browser/main_runner.cc b/libcef/browser/main_runner.cc index 3edd6dd91..9c3a3faa8 100644 --- a/libcef/browser/main_runner.cc +++ b/libcef/browser/main_runner.cc @@ -277,7 +277,13 @@ bool CefMainRunner::Initialize(CefSettings* settings, this, settings, application); exit_code_ = - ContentMainInitialize(args, windows_sandbox_info, &settings->no_sandbox); + ContentMainInitialize(args, windows_sandbox_info, &settings->no_sandbox, +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) + settings->disable_signal_handlers +#else + false +#endif + ); if (exit_code_ >= 0) { LOG(ERROR) << "ContentMainInitialize failed with exit code " << exit_code_; return false; @@ -429,7 +435,8 @@ int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args, int CefMainRunner::ContentMainInitialize(const CefMainArgs& args, void* windows_sandbox_info, - int* no_sandbox) { + int* no_sandbox, + bool disable_signal_handlers) { main_delegate_->BeforeMainThreadInitialize(args); // Initialize the content runner. @@ -452,6 +459,10 @@ int CefMainRunner::ContentMainInitialize(const CefMainArgs& args, main_params.argv = const_cast(args.argv); #endif +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) + main_params.disable_signal_handlers = disable_signal_handlers; +#endif + return content::ContentMainInitialize(std::move(main_params), main_runner_.get()); } diff --git a/libcef/browser/main_runner.h b/libcef/browser/main_runner.h index 6623a4f33..755ad0cc4 100644 --- a/libcef/browser/main_runner.h +++ b/libcef/browser/main_runner.h @@ -60,7 +60,9 @@ class CefMainRunner : public CefMainRunnerHandler { // Called from Initialize(). int ContentMainInitialize(const CefMainArgs& args, void* windows_sandbox_info, - int* no_sandbox); + int* no_sandbox, + bool disable_signal_handlers); + int ContentMainRun(bool* initialized, base::OnceClosure context_initialized); // CefMainRunnerHandler methods: diff --git a/patch/patches/content_main_654986.patch b/patch/patches/content_main_654986.patch index cf726a40b..87ab82d6b 100644 --- a/patch/patches/content_main_654986.patch +++ b/patch/patches/content_main_654986.patch @@ -12,7 +12,7 @@ index 79ba3ac1913f8..46bcb4366d2f8 100644 if (main_argv) setproctitle_init(main_argv); diff --git content/app/content_main.cc content/app/content_main.cc -index 96c28a7ce3183..3d60ab170e9a5 100644 +index 96c28a7ce3183..8a396ce7adf86 100644 --- content/app/content_main.cc +++ content/app/content_main.cc @@ -174,11 +174,8 @@ ContentMainParams::~ContentMainParams() = default; @@ -39,7 +39,18 @@ index 96c28a7ce3183..3d60ab170e9a5 100644 // A flag to indicate whether Main() has been called before. On Android, we // may re-run Main() without restarting the browser process. This flag -@@ -274,14 +268,6 @@ RunContentProcess(ContentMainParams params, +@@ -266,7 +260,9 @@ RunContentProcess(ContentMainParams params, + // default, "C", locale. + setlocale(LC_NUMERIC, "C"); + +- SetupSignalHandlers(); ++ if (!params.disable_signal_handlers) { ++ SetupSignalHandlers(); ++ } + #endif + + #if BUILDFLAG(IS_WIN) +@@ -274,14 +270,6 @@ RunContentProcess(ContentMainParams params, #endif #if BUILDFLAG(IS_MAC) @@ -54,7 +65,7 @@ index 96c28a7ce3183..3d60ab170e9a5 100644 InitializeMac(); #endif -@@ -329,12 +315,46 @@ RunContentProcess(ContentMainParams params, +@@ -329,12 +317,46 @@ RunContentProcess(ContentMainParams params, if (IsSubprocess()) CommonSubprocessInit(); @@ -149,10 +160,22 @@ index cbbc2f3ec12fa..f097b3cdded2f 100644 int RunBrowser(MainFunctionParams main_function_params, bool start_minimal_browser); diff --git content/public/app/content_main.h content/public/app/content_main.h -index 7f9b515297357..89b52e34fa31a 100644 +index 7f9b515297357..5606867e43780 100644 --- content/public/app/content_main.h +++ content/public/app/content_main.h -@@ -94,6 +94,13 @@ struct CONTENT_EXPORT ContentMainParams { +@@ -66,6 +66,11 @@ struct CONTENT_EXPORT ContentMainParams { + // are left uninitialized. + bool minimal_browser_mode = false; + ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) ++ // Indicates whether to disable signal handlers ++ bool disable_signal_handlers = false; ++#endif ++ + #if BUILDFLAG(IS_MAC) + // The outermost autorelease pool to pass to main entry points. + STACK_ALLOCATED_IGNORE("https://crbug.com/1424190") +@@ -94,6 +99,13 @@ struct CONTENT_EXPORT ContentMainParams { } };