diff --git a/src/node.cc b/src/node.cc index c5b6c2b8444499..d10e73d78b4fc6 100644 --- a/src/node.cc +++ b/src/node.cc @@ -431,7 +431,13 @@ void ResetSignalHandlers() { #endif // __POSIX__ } +// We use uint32_t since that can be accessed as a lock-free atomic +// variable on all platforms that we support, which we require in +// order for its value to be usable inside signal handlers. static std::atomic init_process_flags = 0; +static_assert( + std::is_same_v, + uint32_t>); static void PlatformInit(ProcessInitializationFlags::Flags flags) { // init_process_flags is accessed in ResetStdio(), @@ -1057,7 +1063,7 @@ std::unique_ptr InitializeOncePerProcess( } void TearDownOncePerProcess() { - const uint64_t flags = init_process_flags.load(); + const uint32_t flags = init_process_flags.load(); ResetStdio(); if (!(flags & ProcessInitializationFlags::kNoDefaultSignalHandling)) { ResetSignalHandlers(); diff --git a/src/node.h b/src/node.h index 561af155561923..ca7b100311071b 100644 --- a/src/node.h +++ b/src/node.h @@ -227,10 +227,8 @@ class Environment; class MultiIsolatePlatform; class InitializationResultImpl; -namespace ProcessFlags { -// TODO(addaleax): Switch to uint32_t to match std::atomic -// init_process_flags in node.cc -enum Flags : uint64_t { +namespace ProcessInitializationFlags { +enum Flags : uint32_t { kNoFlags = 0, // Enable stdio inheritance, which is disabled by default. // This flag is also implied by kNoStdioInitialization. @@ -270,9 +268,8 @@ enum Flags : uint64_t { kNoParseGlobalDebugVariables | kNoAdjustResourceLimits | kNoUseLargePages | kNoPrintHelpOrVersionOutput, }; -} // namespace ProcessFlags -// TODO(addaleax): Make this the canonical name, as it is more descriptive. -namespace ProcessInitializationFlags = ProcessFlags; +} // namespace ProcessInitializationFlags +namespace ProcessFlags = ProcessInitializationFlags; // Legacy alias. class NODE_EXTERN InitializationResult { public: