aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2022-11-25 04:04:57 +0000
committerNIIBE Yutaka <[email protected]>2022-11-25 04:04:57 +0000
commit62496e9f30349020f2f95306eb0cc9f1c4628c66 (patch)
treec90ce0af9cc2a83a12f03865b11711268c44d5fb
parentFix gnupg_process_release. (diff)
downloadgnupg-62496e9f30349020f2f95306eb0cc9f1c4628c66.tar.gz
gnupg-62496e9f30349020f2f95306eb0cc9f1c4628c66.zip
Support gnupg_process_spawn with R_PROC=NULL.
-- The use case of system(3) call. Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--common/exechelp-posix.c11
-rw-r--r--common/exechelp-w32.c10
2 files changed, 18 insertions, 3 deletions
diff --git a/common/exechelp-posix.c b/common/exechelp-posix.c
index 7a4f9e251..8f21cbf75 100644
--- a/common/exechelp-posix.c
+++ b/common/exechelp-posix.c
@@ -1118,7 +1118,8 @@ gnupg_process_spawn (const char *pgmname, const char *argv1[],
check_syscall_func ();
- *r_process = NULL;
+ if (r_process)
+ *r_process = NULL;
/* Create the command line argument array. */
i = 0;
@@ -1305,6 +1306,13 @@ gnupg_process_spawn (const char *pgmname, const char *argv1[],
process->wstatus = -1;
process->terminated = 0;
+ if (r_process == NULL)
+ {
+ ec = gnupg_process_wait (process, 1);
+ gnupg_process_release (process);
+ return ec;
+ }
+
*r_process = process;
return 0;
}
@@ -1496,7 +1504,6 @@ gnupg_process_wait (gnupg_process_t process, int hang)
int status;
pid_t pid;
-
if (process->terminated)
/* Already terminated. */
return 0;
diff --git a/common/exechelp-w32.c b/common/exechelp-w32.c
index 9ca2bab2d..1c4b8ac36 100644
--- a/common/exechelp-w32.c
+++ b/common/exechelp-w32.c
@@ -1224,7 +1224,8 @@ gnupg_process_spawn (const char *pgmname, const char *argv[],
check_syscall_func ();
- *r_process = NULL;
+ if (r_process)
+ *r_process = NULL;
/* Build the command line. */
ec = build_w32_commandline (pgmname, argv, &cmdline);
@@ -1486,6 +1487,13 @@ gnupg_process_spawn (const char *pgmname, const char *argv[],
process->exitcode = -1;
process->terminated = 0;
+ if (r_process == NULL)
+ {
+ ec = gnupg_process_wait (process, 1);
+ gnupg_process_release (process);
+ return ec;
+ }
+
*r_process = process;
return 0;
}