From 8464627bf444de523c05c44a5a174e4d3736549c Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 29 Aug 2007 16:59:20 +0000 Subject: Extended the --check-program output: Error messages are now inlcued in an easy parsable format. --- common/exechelp.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'common/exechelp.c') 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 -- cgit v1.2.3