From: Marcus Brinkmann Date: Tue, 10 Jul 2007 16:06:44 +0000 (+0000) Subject: 2007-07-10 Marcus Brinkmann X-Git-Tag: gpgme-1.1.6~56 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2d9c4431b883224891d24611536964b4abb492a7;p=gpgme.git 2007-07-10 Marcus Brinkmann * priv-io.h (_gpgme_io_dup): New prototype. * posix-io.c (_gpgme_io_dup): New function. * w32-io.c (_gpgme_io_dup): Likewise. * w32-glib-io.c (_gpgme_io_dup): Likewise. * engine-gpgsm.c (start): Use _gpgme_dup() instead of dup(). --- diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 3b538ef..d2b021d 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,11 @@ +2007-07-10 Marcus Brinkmann + + * priv-io.h (_gpgme_io_dup): New prototype. + * posix-io.c (_gpgme_io_dup): New function. + * w32-io.c (_gpgme_io_dup): Likewise. + * w32-glib-io.c (_gpgme_io_dup): Likewise. + * engine-gpgsm.c (start): Use _gpgme_dup() instead of dup(). + 2007-07-08 Marcus Brinkmann * engine-gpgsm.c [HAVE_W32_SYSTEM]: Enable the bunch of the file. diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index d43a480..0b78c29 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -988,7 +988,8 @@ start (engine_gpgsm_t gpgsm, const char *command) status_fd and register/unregister it manually as needed, but this increases code duplication and is more complicated as we can not use the close notifications etc. */ - gpgsm->status_cb.fd = dup (fdlist[0]); + + gpgsm->status_cb.fd = _gpgme_io_dup (fdlist[0]); if (gpgsm->status_cb.fd < 0) return gpg_error_from_syserror (); diff --git a/gpgme/posix-io.c b/gpgme/posix-io.c index 5cb71f9..82142f8 100644 --- a/gpgme/posix-io.c +++ b/gpgme/posix-io.c @@ -495,3 +495,8 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags) } +int +_gpgme_io_dup (int fd) +{ + return dup (fd); +} diff --git a/gpgme/priv-io.h b/gpgme/priv-io.h index 4c2a604..6b42284 100644 --- a/gpgme/priv-io.h +++ b/gpgme/priv-io.h @@ -64,4 +64,7 @@ int _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock); line that the child process expects. */ int _gpgme_io_fd2str (char *buf, int buflen, int fd); +/* Like dup(). */ +int _gpgme_io_dup (int fd); + #endif /* IO_H */ diff --git a/gpgme/w32-glib-io.c b/gpgme/w32-glib-io.c index 20099ef..183a560 100644 --- a/gpgme/w32-glib-io.c +++ b/gpgme/w32-glib-io.c @@ -660,3 +660,11 @@ leave: free (pollfds_map); return count; } + + +int +_gpgme_io_dup (int fd) +{ + return _dup (fd); +} + diff --git a/gpgme/w32-io.c b/gpgme/w32-io.c index fd53a6f..947bb62 100644 --- a/gpgme/w32-io.c +++ b/gpgme/w32-io.c @@ -1140,6 +1140,25 @@ _gpgme_io_fd2str (char *buf, int buflen, int fd) return snprintf (buf, buflen, "%d", fd); } + +int +_gpgme_io_dup (int fd) +{ + HANDLE handle = fd_to_handle (fd); + HANDLE new_handle = fd_to_handle (fd); + + /* For NT we have to set the sync flag. It seems that the only + * way to do it is by duplicating the handle. Tsss.. */ + if (!DuplicateHandle( GetCurrentProcess(), handle, + GetCurrentProcess(), &new_handle, + 0, FALSE, DUPLICATE_SAME_ACCESS)) + { + DEBUG1 ("** DuplicateHandle failed: ec=%d\n", (int) GetLastError()); + } + + return handle_to_fd (new_handle); +} + /* The following interface is only useful for GPGME Glib. */