src: add flags for controlling process behavior · nodejs/node@3b72788 · GitHub
Skip to content

Commit 3b72788

Browse files
zcbenzmhdawson
authored andcommitted
src: add flags for controlling process behavior
PR-URL: #40339 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent 4cf5563 commit 3b72788

3 files changed

Lines changed: 88 additions & 50 deletions

File tree

src/node.cc

Lines changed: 62 additions & 46 deletions

src/node.h

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ namespace node {
214214
class IsolateData;
215215
class Environment;
216216

217+
namespace ProcessFlags {
218+
enum Flags : uint64_t {
219+
kNoFlags = 0,
220+
// Enable stdio inheritance, which is disabled by default.
221+
kEnableStdioInheritance = 1 << 0,
222+
// Disable reading the NODE_OPTIONS environment variable.
223+
kDisableNodeOptionsEnv = 1 << 1,
224+
// Do not parse CLI options.
225+
kDisableCLIOptions = 1 << 2,
226+
// Do not initialize ICU.
227+
kNoICU = 1 << 3,
228+
};
229+
} // namespace ProcessFlags
230+
217231
// TODO(addaleax): Officially deprecate this and replace it with something
218232
// better suited for a public embedder API.
219233
NODE_EXTERN int Start(int argc, char* argv[]);
@@ -226,9 +240,16 @@ NODE_EXTERN int Stop(Environment* env);
226240
// from argv, fill exec_argv, and possibly add errors resulting from parsing
227241
// the arguments to `errors`. The return value is a suggested exit code for the
228242
// program; If it is 0, then initializing Node.js succeeded.
229-
NODE_EXTERN int InitializeNodeWithArgs(std::vector<std::string>* argv,
230-
std::vector<std::string>* exec_argv,
231-
std::vector<std::string>* errors);
243+
NODE_EXTERN int InitializeNodeWithArgs(
244+
std::vector<std::string>* argv,
245+
std::vector<std::string>* exec_argv,
246+
std::vector<std::string>* errors);
247+
// TODO(zcbenz): Turn above overloaded version into below's default argument.
248+
NODE_EXTERN int InitializeNodeWithArgs(
249+
std::vector<std::string>* argv,
250+
std::vector<std::string>* exec_argv,
251+
std::vector<std::string>* errors,
252+
ProcessFlags::Flags flags);
232253

233254
enum OptionEnvvarSettings {
234255
kAllowedInEnvironment,

src/node_internals.h

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)