diff options
author | Werner Koch <wk@gnupg.org> | 2007-08-29 18:59:20 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2007-08-29 18:59:20 +0200 |
commit | 8464627bf444de523c05c44a5a174e4d3736549c (patch) | |
tree | 3b4b5ed8df2106cb8afa1e429acaa5a315d3bcbc /common | |
parent | New command --check-programs for gpgconf. (diff) | |
download | gnupg2-8464627bf444de523c05c44a5a174e4d3736549c.tar.xz gnupg2-8464627bf444de523c05c44a5a174e4d3736549c.zip |
Extended the --check-program output: Error messages are now inlcued in an
easy parsable format.
Diffstat (limited to 'common')
-rw-r--r-- | common/ChangeLog | 2 | ||||
-rw-r--r-- | common/exechelp.c | 44 | ||||
-rw-r--r-- | common/exechelp.h | 4 |
3 files changed, 49 insertions, 1 deletions
diff --git a/common/ChangeLog b/common/ChangeLog index e577363c3..8dc830894 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -2,7 +2,7 @@ * exechelp.c (gnupg_wait_process): Add arg EXITCODE. Changed all callers. - + (gnupg_create_inbound_pipe): New. * util.h (GNUPG_MODULE_NAME_GPGSM, GNUPG_MODULE_NAME_GPG): New. * homedir.c (gnupg_module_name): Add them diff --git a/common/exechelp.c b/common/exechelp.c index 4ec481f99..7da7dbd50 100644 --- a/common/exechelp.c +++ b/common/exechelp.c @@ -270,6 +270,50 @@ do_exec (const char *pgmname, const char *argv[], #endif /*!HAVE_W32_SYSTEM*/ +/* Portable function to create a pipe. Under Windows the write end is + inheritable. */ +gpg_error_t +gnupg_create_inbound_pipe (int filedes[2]) +{ + gpg_error_t err = 0; +#if HAVE_W32_SYSTEM + int fds[2]; + + filedes[0] = filedes[1] = -1; + err = gpg_error (GPG_ERR_GENERAL); + if (!create_inheritable_pipe (fds)) + { + filedes[0] = _open_osfhandle (fds[0], 0); + if (filedes[0] == -1) + { + log_error ("failed to translate osfhandle %p\n", (void*)fds[0]); + CloseHandle (fd_to_handle (fds[1])); + } + else + { + filedes[1] = _open_osfhandle (fds[1], 1); + if (filedes[1] == -1) + { + log_error ("failed to translate osfhandle %p\n", (void*)fds[1]); + close (filedes[0]); + filedes[0] = -1; + CloseHandle (fd_to_handle (fds[1])); + } + else + err = 0; + } + } +#else + if (pipe (filedes) == -1) + { + err = gpg_error_from_syserror (); + filedes[0] = filedes[1] = -1; + } +#endif + return err; +} + + /* Fork and exec the PGMNAME, connect the file descriptor of INFILE to stdin, write the output to OUTFILE, return a new stream in STATUSFILE for stderr and the pid of the process in PID. The diff --git a/common/exechelp.h b/common/exechelp.h index 7abc03708..5dd7df4cf 100644 --- a/common/exechelp.h +++ b/common/exechelp.h @@ -21,6 +21,10 @@ #define GNUPG_COMMON_EXECHELP_H +/* Portable function to create a pipe. Under Windows the write end is + inheritable. */ +gpg_error_t gnupg_create_inbound_pipe (int filedes[2]); + /* Fork and exec the PGMNAME, connect the file descriptor of INFILE to stdin, write the output to OUTFILE, return a new stream in |