diff options
author | Werner Koch <[email protected]> | 2007-08-29 09:51:37 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2007-08-29 09:51:37 +0000 |
commit | b13587ef167d58f960270fbcef674d8c919ba8dc (patch) | |
tree | f8ec6df5208e0f6dc50941d2f833ee2b3803e7ba /common/exechelp.c | |
parent | Add more passphrase policy rules. (diff) | |
download | gnupg-b13587ef167d58f960270fbcef674d8c919ba8dc.tar.gz gnupg-b13587ef167d58f960270fbcef674d8c919ba8dc.zip |
New command --check-programs for gpgconf.
Diffstat (limited to 'common/exechelp.c')
-rw-r--r-- | common/exechelp.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/common/exechelp.c b/common/exechelp.c index 2a65970bd..4ec481f99 100644 --- a/common/exechelp.c +++ b/common/exechelp.c @@ -570,11 +570,13 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[], /* Wait for the process identified by PID to terminate. PGMNAME should - be the same as suplieed to the spawn fucntion and is only used for - diagnostics. Returns 0 if the process succeded, GPG_ERR_GENERAL for - any failures of the spawned program or other error codes.*/ + be the same as supplied to the spawn function and is only used for + diagnostics. Returns 0 if the process succeeded, GPG_ERR_GENERAL + for any failures of the spawned program or other error codes. If + EXITCODE is not NULL the exit code of the process is stored at this + address or -1 if it could not be retrieved. */ gpg_error_t -gnupg_wait_process (const char *pgmname, pid_t pid) +gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode) { gpg_err_code_t ec; @@ -583,6 +585,9 @@ gnupg_wait_process (const char *pgmname, pid_t pid) int code; DWORD exc; + if (exitcode) + *exitcode = -1; + if (pid == (pid_t)(-1)) return gpg_error (GPG_ERR_INV_VALUE); @@ -609,10 +614,16 @@ gnupg_wait_process (const char *pgmname, pid_t pid) { log_error (_("error running `%s': exit status %d\n"), pgmname, (int)exc ); + if (exitcode) + *exitcode = (int)exc; ec = GPG_ERR_GENERAL; } else - ec = 0; + { + if (exitcode) + *exitcode = 0; + ec = 0; + } CloseHandle (proc); break; @@ -626,6 +637,9 @@ gnupg_wait_process (const char *pgmname, pid_t pid) #else /* !HAVE_W32_SYSTEM */ int i, status; + if (exitcode) + *exitcode = -1; + if (pid == (pid_t)(-1)) return gpg_error (GPG_ERR_INV_VALUE); @@ -650,6 +664,8 @@ gnupg_wait_process (const char *pgmname, pid_t pid) { log_error (_("error running `%s': exit status %d\n"), pgmname, WEXITSTATUS (status)); + if (exitcode) + *exitcode = WEXITSTATUS (status); ec = GPG_ERR_GENERAL; } else if (!WIFEXITED (status)) @@ -658,11 +674,14 @@ gnupg_wait_process (const char *pgmname, pid_t pid) ec = GPG_ERR_GENERAL; } else - ec = 0; + { + if (exitcode) + *exitcode = 0; + ec = 0; + } #endif /* !HAVE_W32_SYSTEM */ return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, ec); - } |