mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-11 22:01:08 +02:00
w32: Make pipes really pollable.
* common/exectool.c (gnupg_exec_tool_stream) [W32]: Use _get_osfhandle to print the fd for the command line. * common/exechelp-w32.c (create_pipe_and_estream): Use es_sysopen so that the streams are actually pollable. -- This addresses two bugs: - Using the "-&@INEXTRA@" kludges requires that we pass the value of the handle on the command line and not the libc fd. - gpgrt_poll requires the use of the ReadFile/WriteFile backend which is currently only used when the stream has been created with gpgrt_sysopen. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
f5782e11a5
commit
1192449207
@ -309,6 +309,7 @@ create_pipe_and_estream (int filedes[2], int flags,
|
|||||||
{
|
{
|
||||||
gpg_error_t err = 0;
|
gpg_error_t err = 0;
|
||||||
HANDLE fds[2];
|
HANDLE fds[2];
|
||||||
|
es_syshd_t syshd;
|
||||||
|
|
||||||
filedes[0] = filedes[1] = -1;
|
filedes[0] = filedes[1] = -1;
|
||||||
err = my_error (GPG_ERR_GENERAL);
|
err = my_error (GPG_ERR_GENERAL);
|
||||||
@ -337,10 +338,17 @@ create_pipe_and_estream (int filedes[2], int flags,
|
|||||||
|
|
||||||
if (! err && r_fp)
|
if (! err && r_fp)
|
||||||
{
|
{
|
||||||
|
syshd.type = ES_SYSHD_HANDLE;
|
||||||
if (!outbound)
|
if (!outbound)
|
||||||
*r_fp = es_fdopen (filedes[0], nonblock? "r,nonblock" : "r");
|
{
|
||||||
|
syshd.u.handle = fds[0];
|
||||||
|
*r_fp = es_sysopen (&syshd, nonblock? "r,nonblock" : "r");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
*r_fp = es_fdopen (filedes[1], nonblock? "w,nonblock" : "w");
|
{
|
||||||
|
syshd.u.handle = fds[1];
|
||||||
|
*r_fp = es_sysopen (&syshd, nonblock? "w,nonblock" : "w");
|
||||||
|
}
|
||||||
if (!*r_fp)
|
if (!*r_fp)
|
||||||
{
|
{
|
||||||
err = my_error_from_syserror ();
|
err = my_error_from_syserror ();
|
||||||
|
@ -384,7 +384,12 @@ gnupg_exec_tool_stream (const char *pgmname, const char *argv[],
|
|||||||
/* Now find the argument marker and replace by the pipe's fd.
|
/* Now find the argument marker and replace by the pipe's fd.
|
||||||
Yeah, that is an ugly non-thread safe hack but it safes us to
|
Yeah, that is an ugly non-thread safe hack but it safes us to
|
||||||
create a copy of the array. */
|
create a copy of the array. */
|
||||||
|
#ifdef HAVE_W32_SYSTEM
|
||||||
|
snprintf (extrafdbuf, sizeof extrafdbuf, "-&%lu",
|
||||||
|
(unsigned long)(void*)_get_osfhandle (extrapipe[0]));
|
||||||
|
#else
|
||||||
snprintf (extrafdbuf, sizeof extrafdbuf, "-&%d", extrapipe[0]);
|
snprintf (extrafdbuf, sizeof extrafdbuf, "-&%d", extrapipe[0]);
|
||||||
|
#endif
|
||||||
for (argsaveidx=0; argv[argsaveidx]; argsaveidx++)
|
for (argsaveidx=0; argv[argsaveidx]; argsaveidx++)
|
||||||
if (!strcmp (argv[argsaveidx], "-&@INEXTRA@"))
|
if (!strcmp (argv[argsaveidx], "-&@INEXTRA@"))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user