From 59dc98545a2cbd2a6d057b3ec7fe25ebff25f8a4 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 5 Nov 2009 02:39:31 +0000 Subject: [PATCH] 2009-11-05 Marcus Brinkmann * priv-io.h (IOSPAWN_FLAG_NOCLOSE): New flag. * w32-io.c (_gpgme_io_spawn): Implement this flag. * posix-io.c (_gpgme_io_spawn): Likewise. * w32-glib-io.c (_gpgme_io_spawn): Likewise. * assuan-support.c (my_spawn): Set this flag. --- src/ChangeLog | 6 ++++++ src/assuan-support.c | 2 +- src/posix-io.c | 3 ++- src/priv-io.h | 2 ++ src/w32-glib-io.c | 7 +++++-- src/w32-io.c | 7 +++++-- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index d5aebe3..0ea3a1c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2009-11-05 Marcus Brinkmann + * priv-io.h (IOSPAWN_FLAG_NOCLOSE): New flag. + * w32-io.c (_gpgme_io_spawn): Implement this flag. + * posix-io.c (_gpgme_io_spawn): Likewise. + * w32-glib-io.c (_gpgme_io_spawn): Likewise. + * assuan-support.c (my_spawn): Set this flag. + * decrypt.c (gpgme_op_decrypt_start): Fix use of debug macro. * decrypt-verify.c (gpgme_op_decrypt_verify_start): Likewise. * delete.c (gpgme_op_delete_start): Likewise. diff --git a/src/assuan-support.c b/src/assuan-support.c index b5d2548..4646416 100644 --- a/src/assuan-support.c +++ b/src/assuan-support.c @@ -152,7 +152,7 @@ my_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name, fd_items[i].fd = -1; fd_items[i].dup_to = -1; - err = _gpgme_io_spawn (name, argv, 0, fd_items, r_pid); + err = _gpgme_io_spawn (name, argv, IOSPAWN_FLAG_NOCLOSE, fd_items, r_pid); if (! err) { i = 0; diff --git a/src/posix-io.c b/src/posix-io.c index 1025268..b173f58 100644 --- a/src/posix-io.c +++ b/src/posix-io.c @@ -454,7 +454,8 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags, for (i = 0; fd_list[i].fd != -1; i++) { - _gpgme_io_close (fd_list[i].fd); + if (! (flags & IOSPAWN_FLAG_NOCLOSE)) + _gpgme_io_close (fd_list[i].fd); /* No handle translation. */ fd_list[i].peer_name = fd_list[i].fd; } diff --git a/src/priv-io.h b/src/priv-io.h index 4eb2e36..a9fb02a 100644 --- a/src/priv-io.h +++ b/src/priv-io.h @@ -68,6 +68,8 @@ int _gpgme_io_set_nonblocking (int fd); /* A flag to tell the spawn function to allow the child process to set the foreground window. */ #define IOSPAWN_FLAG_ALLOW_SET_FG 1 +/* Don't close any child FDs. */ +#define IOSPAWN_FLAG_NOCLOSE 2 /* Spawn the executable PATH with ARGV as arguments. After forking close all fds except for those in FD_LIST in the child, then diff --git a/src/w32-glib-io.c b/src/w32-glib-io.c index c1542cc..17d60fc 100644 --- a/src/w32-glib-io.c +++ b/src/w32-glib-io.c @@ -777,8 +777,11 @@ _gpgme_io_spawn (const char *path, char * const argv[], unsigned int flags, TRACE_LOG1 ("CloseHandle of process failed: ec=%d", (int) GetLastError ()); - for (i = 0; fd_list[i].fd != -1; i++) - _gpgme_io_close (fd_list[i].fd); + if (! (flags & IOSPAWN_FLAG_NOCLOSE)) + { + for (i = 0; fd_list[i].fd != -1; i++) + _gpgme_io_close (fd_list[i].fd); + } for (i = 0; fd_list[i].fd != -1; i++) if (fd_list[i].dup_to == -1) diff --git a/src/w32-io.c b/src/w32-io.c index f87db12..e83aa0b 100644 --- a/src/w32-io.c +++ b/src/w32-io.c @@ -1234,8 +1234,11 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags, TRACE_LOG1 ("CloseHandle of process failed: ec=%d", (int) GetLastError ()); - for (i = 0; fd_list[i].fd != -1; i++) - _gpgme_io_close (fd_list[i].fd); + if (! (flags & IOSPAWN_FLAG_NOCLOSE)) + { + for (i = 0; fd_list[i].fd != -1; i++) + _gpgme_io_close (fd_list[i].fd); + } for (i = 0; fd_list[i].fd != -1; i++) if (fd_list[i].dup_to == -1) -- 2.26.2