1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

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.
This commit is contained in:
Werner Koch 2021-09-13 17:07:18 +02:00
parent 265d993c76
commit f2b01025c3
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -903,10 +903,14 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
BOOL in_job = FALSE; BOOL in_job = FALSE;
gpg_err_code_t ec; gpg_err_code_t ec;
int rc; int rc;
int jobdebug;
/* We don't use ENVP. */ /* We don't use ENVP. */
(void)envp; (void)envp;
cmdline = getenv ("GNUPG_EXEC_DEBUG_FLAGS");
jobdebug = (cmdline && (atoi (cmdline) & 1));
if ((ec = gnupg_access (pgmname, X_OK))) if ((ec = gnupg_access (pgmname, X_OK)))
return gpg_err_make (default_errsource, ec); return gpg_err_make (default_errsource, ec);
@ -955,14 +959,16 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
else if ((info.BasicLimitInformation.LimitFlags & else if ((info.BasicLimitInformation.LimitFlags &
JOB_OBJECT_LIMIT_BREAKAWAY_OK)) 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; cr_flags |= CREATE_BREAKAWAY_FROM_JOB;
} }
else if ((info.BasicLimitInformation.LimitFlags & else if ((info.BasicLimitInformation.LimitFlags &
JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK)) JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK))
{ {
/* The child process should automatically detach from the job. */ /* The child process should automatically detach from the job. */
log_info ("Not using CREATE_BREAKAWAY_FROM_JOB flag; " if (jobdebug)
log_debug ("Not using CREATE_BREAKAWAY_FROM_JOB flag; "
"JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK is set\n"); "JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK is set\n");
} }
else else
@ -970,9 +976,15 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
/* It seems that the child process must remain in the job. /* It seems that the child process must remain in the job.
* This is not necessarily an error, although it can cause premature * This is not necessarily an error, although it can cause premature
* termination of the child process when the job is closed. */ * 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", */ /* log_debug ("CreateProcess(detached), path='%s' cmdline='%s'\n", */
/* pgmname, cmdline); */ /* pgmname, cmdline); */