diff options
author | Werner Koch <[email protected]> | 2007-08-29 16:59:20 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2007-08-29 16:59:20 +0000 |
commit | 8464627bf444de523c05c44a5a174e4d3736549c (patch) | |
tree | 3b4b5ed8df2106cb8afa1e429acaa5a315d3bcbc /common/exechelp.c | |
parent | New command --check-programs for gpgconf. (diff) | |
download | gnupg-8464627bf444de523c05c44a5a174e4d3736549c.tar.gz gnupg-8464627bf444de523c05c44a5a174e4d3736549c.zip |
Extended the --check-program output: Error messages are now inlcued in an
easy parsable format.
Diffstat (limited to '')
-rw-r--r-- | common/exechelp.c | 44 |
1 files changed, 44 insertions, 0 deletions
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 |