From c5a53a75920e5c496df82496cd8f059b47d981ac Mon Sep 17 00:00:00 2001 From: Jeremy Drake Date: Sun, 8 Nov 2020 11:08:13 -0800 Subject: [PATCH] cygwin: use CREATE_DEFAULT_ERROR_MODE in spawn This allows native processes to get Windows-default error handling behavior (such as invoking the registered JIT debugger), while cygwin processes would quickly set their error mode back to what they expect. Gated by CYGWIN/MSYS=spawndftlerrmode --- winsup/cygwin/environ.cc | 1 + winsup/cygwin/globals.cc | 1 + winsup/cygwin/spawn.cc | 2 ++ 3 files changed, 4 insertions(+) diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 6a54ed4a1e..3d4cfc1b92 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -126,6 +126,7 @@ static struct parse_thing {"winsymlinks", {func: set_winsymlinks}, isfunc, NULL, {{0}, {0}}}, {"disable_pcon", {&disable_pcon}, setbool, NULL, {{false}, {true}}}, {"enable_pcon", {&disable_pcon}, setnegbool, NULL, {{true}, {false}}}, + {"spawndflterrmode", {&spawn_default_errmode}, setbool, NULL, {{false}, {true}}}, {NULL, {0}, setdword, 0, {{0}, {0}}} }; diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc index abe74f21d9..4b3482d660 100644 --- a/winsup/cygwin/globals.cc +++ b/winsup/cygwin/globals.cc @@ -72,6 +72,7 @@ bool reset_com; bool wincmdln = true; winsym_t allow_winsymlinks = WSYM_deepcopy; bool disable_pcon = true; +bool spawn_default_errmode = false; bool NO_COPY in_forkee; diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index c77d629846..e275fdc415 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -446,6 +446,8 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, sigproc_printf ("priority class %d", c_flags); c_flags |= CREATE_SEPARATE_WOW_VDM | CREATE_UNICODE_ENVIRONMENT; + if (spawn_default_errmode) + c_flags |= CREATE_DEFAULT_ERROR_MODE; /* We're adding the CREATE_BREAKAWAY_FROM_JOB flag here to workaround issues with the "Program Compatibility Assistant (PCA) Service".