From f2b01025c3da97068b699c1f51309e18730a4bdb Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 13 Sep 2021 17:07:18 +0200 Subject: [PATCH] common: New envvar GNUPG_EXEC_DEBUG_FLAGS. * common/exechelp-w32.c (gnupg_spawn_process_detached): Silence breakaway messages and turn them again into debug messages. --- common/exechelp-w32.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/common/exechelp-w32.c b/common/exechelp-w32.c index 2a3a55073..92be5cd52 100644 --- a/common/exechelp-w32.c +++ b/common/exechelp-w32.c @@ -903,10 +903,14 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], BOOL in_job = FALSE; gpg_err_code_t ec; int rc; + int jobdebug; /* We don't use ENVP. */ (void)envp; + cmdline = getenv ("GNUPG_EXEC_DEBUG_FLAGS"); + jobdebug = (cmdline && (atoi (cmdline) & 1)); + if ((ec = gnupg_access (pgmname, X_OK))) return gpg_err_make (default_errsource, ec); @@ -955,24 +959,32 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], else if ((info.BasicLimitInformation.LimitFlags & JOB_OBJECT_LIMIT_BREAKAWAY_OK)) { - log_info ("Using CREATE_BREAKAWAY_FROM_JOB flag\n"); + if (jobdebug) + log_debug ("Using CREATE_BREAKAWAY_FROM_JOB flag\n"); cr_flags |= CREATE_BREAKAWAY_FROM_JOB; } else if ((info.BasicLimitInformation.LimitFlags & JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK)) { /* The child process should automatically detach from the job. */ - log_info ("Not using CREATE_BREAKAWAY_FROM_JOB flag; " - "JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK is set\n"); + if (jobdebug) + log_debug ("Not using CREATE_BREAKAWAY_FROM_JOB flag; " + "JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK is set\n"); } else { /* It seems that the child process must remain in the job. * This is not necessarily an error, although it can cause premature * termination of the child process when the job is closed. */ - log_info ("Not using CREATE_BREAKAWAY_FROM_JOB flag\n"); + if (jobdebug) + log_debug ("Not using CREATE_BREAKAWAY_FROM_JOB flag\n"); } } + else + { + if (jobdebug) + log_debug ("Process is not in a Job\n"); + } /* log_debug ("CreateProcess(detached), path='%s' cmdline='%s'\n", */ /* pgmname, cmdline); */