From 62496e9f30349020f2f95306eb0cc9f1c4628c66 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 25 Nov 2022 13:04:57 +0900 Subject: Support gnupg_process_spawn with R_PROC=NULL. -- The use case of system(3) call. Signed-off-by: NIIBE Yutaka --- common/exechelp-posix.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'common/exechelp-posix.c') 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; -- cgit v1.2.3