2007-07-10 Marcus Brinkmann <marcus@g10code.de>

* 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().
This commit is contained in:
Marcus Brinkmann 2007-07-10 16:06:44 +00:00
parent 4718b14e18
commit 2d9c4431b8
6 changed files with 45 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2007-07-10 Marcus Brinkmann <marcus@g10code.de>
* 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 <marcus@g10code.de> 2007-07-08 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c [HAVE_W32_SYSTEM]: Enable the bunch of the file. * engine-gpgsm.c [HAVE_W32_SYSTEM]: Enable the bunch of the file.

View File

@ -988,7 +988,8 @@ start (engine_gpgsm_t gpgsm, const char *command)
status_fd and register/unregister it manually as needed, but this status_fd and register/unregister it manually as needed, but this
increases code duplication and is more complicated as we can not increases code duplication and is more complicated as we can not
use the close notifications etc. */ 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) if (gpgsm->status_cb.fd < 0)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();

View File

@ -495,3 +495,8 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags)
} }
int
_gpgme_io_dup (int fd)
{
return dup (fd);
}

View File

@ -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. */ line that the child process expects. */
int _gpgme_io_fd2str (char *buf, int buflen, int fd); int _gpgme_io_fd2str (char *buf, int buflen, int fd);
/* Like dup(). */
int _gpgme_io_dup (int fd);
#endif /* IO_H */ #endif /* IO_H */

View File

@ -660,3 +660,11 @@ leave:
free (pollfds_map); free (pollfds_map);
return count; return count;
} }
int
_gpgme_io_dup (int fd)
{
return _dup (fd);
}

View File

@ -1140,6 +1140,25 @@ _gpgme_io_fd2str (char *buf, int buflen, int fd)
return snprintf (buf, buflen, "%d", 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. */ /* The following interface is only useful for GPGME Glib. */