posix: Added option to disable signal handlers

See https://github.com/chromiumembedded/java-cef/issues/477
This commit is contained in:
Loic Frasse-Mathon 2024-08-05 12:16:49 -04:00 committed by Marshall Greenblatt
parent fe6e44886b
commit 686a5cab52
6 changed files with 61 additions and 14 deletions

View File

@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal // way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash // hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected. // values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "231671a5669eaa29cd2c01a2e459857945c4ea01" #define CEF_API_HASH_UNIVERSAL "bb414cc95e84099084c9476c468846e483ef7a0f"
#if defined(OS_WIN) #if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "f8a2808cad9b2250c0a5096c043547f8942e2b7d" #define CEF_API_HASH_PLATFORM "1a921f6a2c91bc5369afce001c37645ef726e804"
#elif defined(OS_MAC) #elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "064c88eb32b8b9932d85ed8023a11656647a3ac0" #define CEF_API_HASH_PLATFORM "8c96e8a60224dc40ec40067b6a515af79dd47f8f"
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "e934aa611c47fda69dbef4e46e11255300e37f9c" #define CEF_API_HASH_PLATFORM "693e114620a780000fbb7334537145caed271c66"
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -486,6 +486,13 @@ typedef struct _cef_settings_t {
/// Windows. /// Windows.
/// ///
int chrome_app_icon_id; 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; } cef_settings_t;
/// ///

View File

@ -432,6 +432,10 @@ struct CefSettingsTraits {
cef_string_set(src->chrome_policy_id.str, src->chrome_policy_id.length, cef_string_set(src->chrome_policy_id.str, src->chrome_policy_id.length,
&target->chrome_policy_id, copy); &target->chrome_policy_id, copy);
target->chrome_app_icon_id = src->chrome_app_icon_id; 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
} }
}; };

View File

@ -101,7 +101,13 @@ bool CefMainRunner::Initialize(CefSettings* settings,
application_ = application; application_ = application;
exit_code_ = 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) { if (exit_code_ >= 0) {
LOG(ERROR) << "ContentMainInitialize failed with exit code " << exit_code_; LOG(ERROR) << "ContentMainInitialize failed with exit code " << exit_code_;
return false; return false;
@ -253,7 +259,8 @@ int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args,
int CefMainRunner::ContentMainInitialize(const CefMainArgs& args, int CefMainRunner::ContentMainInitialize(const CefMainArgs& args,
void* windows_sandbox_info, void* windows_sandbox_info,
int* no_sandbox) { int* no_sandbox,
bool disable_signal_handlers) {
BeforeMainInitialize(args); BeforeMainInitialize(args);
main_delegate_ = main_delegate_ =
@ -278,6 +285,10 @@ int CefMainRunner::ContentMainInitialize(const CefMainArgs& args,
main_params.argv = const_cast<const char**>(args.argv); main_params.argv = const_cast<const char**>(args.argv);
#endif #endif
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
main_params.disable_signal_handlers = disable_signal_handlers;
#endif
return content::ContentMainInitialize(std::move(main_params), return content::ContentMainInitialize(std::move(main_params),
main_runner_.get()); main_runner_.get());
} }

View File

@ -62,7 +62,9 @@ class CefMainRunner final {
// Called from Initialize(). // Called from Initialize().
int ContentMainInitialize(const CefMainArgs& args, int ContentMainInitialize(const CefMainArgs& args,
void* windows_sandbox_info, void* windows_sandbox_info,
int* no_sandbox); int* no_sandbox,
bool disable_signal_handlers);
int ContentMainRun(bool* initialized, base::OnceClosure context_initialized); int ContentMainRun(bool* initialized, base::OnceClosure context_initialized);
static void BeforeMainInitialize(const CefMainArgs& args); static void BeforeMainInitialize(const CefMainArgs& args);

View File

@ -12,7 +12,7 @@ index 79ba3ac1913f8..46bcb4366d2f8 100644
if (main_argv) if (main_argv)
setproctitle_init(main_argv); setproctitle_init(main_argv);
diff --git content/app/content_main.cc content/app/content_main.cc diff --git content/app/content_main.cc content/app/content_main.cc
index 4251459b695e6..d74286fec151b 100644 index 96c28a7ce3183..8a396ce7adf86 100644
--- content/app/content_main.cc --- content/app/content_main.cc
+++ content/app/content_main.cc +++ content/app/content_main.cc
@@ -174,11 +174,8 @@ ContentMainParams::~ContentMainParams() = default; @@ -174,11 +174,8 @@ ContentMainParams::~ContentMainParams() = default;
@ -39,7 +39,18 @@ index 4251459b695e6..d74286fec151b 100644
// A flag to indicate whether Main() has been called before. On Android, we // A flag to indicate whether Main() has been called before. On Android, we
// may re-run Main() without restarting the browser process. This flag // may re-run Main() without restarting the browser process. This flag
@@ -275,14 +269,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 #endif
#if BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_MAC)
@ -54,7 +65,7 @@ index 4251459b695e6..d74286fec151b 100644
InitializeMac(); InitializeMac();
#endif #endif
@@ -330,12 +316,46 @@ RunContentProcess(ContentMainParams params, @@ -329,12 +317,46 @@ RunContentProcess(ContentMainParams params,
if (IsSubprocess()) if (IsSubprocess())
CommonSubprocessInit(); CommonSubprocessInit();
@ -103,7 +114,7 @@ index 4251459b695e6..d74286fec151b 100644
} }
diff --git content/app/content_main_runner_impl.cc content/app/content_main_runner_impl.cc diff --git content/app/content_main_runner_impl.cc content/app/content_main_runner_impl.cc
index eedd753c7990a..87f342581607b 100644 index 78b9930f1ca5c..1d93552c3da25 100644
--- content/app/content_main_runner_impl.cc --- content/app/content_main_runner_impl.cc
+++ content/app/content_main_runner_impl.cc +++ content/app/content_main_runner_impl.cc
@@ -52,6 +52,7 @@ @@ -52,6 +52,7 @@
@ -114,7 +125,7 @@ index eedd753c7990a..87f342581607b 100644
#include "base/time/time.h" #include "base/time/time.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "build/build_config.h" #include "build/build_config.h"
@@ -1361,6 +1362,11 @@ void ContentMainRunnerImpl::Shutdown() { @@ -1342,6 +1343,11 @@ void ContentMainRunnerImpl::Shutdown() {
is_shutdown_ = true; is_shutdown_ = true;
} }
@ -149,10 +160,22 @@ index cbbc2f3ec12fa..f097b3cdded2f 100644
int RunBrowser(MainFunctionParams main_function_params, int RunBrowser(MainFunctionParams main_function_params,
bool start_minimal_browser); bool start_minimal_browser);
diff --git content/public/app/content_main.h content/public/app/content_main.h 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
+++ 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 {
} }
}; };