* 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-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>
* engine-gpgsm.c [HAVE_W32_SYSTEM]: Enable the bunch of the file.
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 ();
}
+int
+_gpgme_io_dup (int fd)
+{
+ return dup (fd);
+}
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 */
free (pollfds_map);
return count;
}
+
+
+int
+_gpgme_io_dup (int fd)
+{
+ return _dup (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);
+}
+
\f
/* The following interface is only useful for GPGME Glib. */