aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2026-01-08 08:37:14 +0100
committerNIIBE Yutaka <[email protected]>2026-01-08 08:37:14 +0100
commit58c57b25575c83f372deee64d67e359ec1afb5c9 (patch)
treea139ed12aa646e1be7b1fd8d1dafea737810e1d7 /src
parentw32: Fix for process handle. (diff)
downloadgpgme-58c57b25575c83f372deee64d67e359ec1afb5c9.tar.gz
gpgme-58c57b25575c83f372deee64d67e359ec1afb5c9.zip
w32: Use SetHandleInformation for _gpgme_io_pipe.
* src/w32-io.c (_gpgme_io_pipe): Create a pipe with bInheritHandle = TRUE, and then clear an end by SetHandleInformation. -- Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/w32-io.c44
1 files changed, 9 insertions, 35 deletions
diff --git a/src/w32-io.c b/src/w32-io.c
index 313803a2..841cbb31 100644
--- a/src/w32-io.c
+++ b/src/w32-io.c
@@ -1131,7 +1131,7 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
/* Create a pipe. */
memset (&sec_attr, 0, sizeof (sec_attr));
sec_attr.nLength = sizeof (sec_attr);
- sec_attr.bInheritHandle = FALSE;
+ sec_attr.bInheritHandle = TRUE;
if (!CreatePipe (&rh, &wh, &sec_attr, PIPEBUF_SIZE))
{
@@ -1147,45 +1147,19 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
/* Make one end inheritable. */
if (inherit_idx == 0)
{
- HANDLE hd;
- if (!DuplicateHandle (GetCurrentProcess(), rh,
- GetCurrentProcess(), &hd, 0,
- TRUE, DUPLICATE_SAME_ACCESS))
- {
- TRACE_LOG ("DuplicateHandle failed: ec=%d",
- (int) GetLastError ());
- release_fd (rfd);
- release_fd (wfd);
- close_handle (rh);
- close_handle (wh);
- release_hddesc (rhdesc);
- release_hddesc (whdesc);
- gpg_err_set_errno (EIO);
- return TRACE_SYSRES (-1);
+ if (!SetHandleInformation (wh, HANDLE_FLAG_INHERIT, 0))
+ {
+ gpg_err_set_errno (EIO);
+ return TRACE_SYSRES (-1);
}
- close_handle (rh);
- rh = hd;
}
else if (inherit_idx == 1)
{
- HANDLE hd;
- if (!DuplicateHandle( GetCurrentProcess(), wh,
- GetCurrentProcess(), &hd, 0,
- TRUE, DUPLICATE_SAME_ACCESS))
- {
- TRACE_LOG ("DuplicateHandle failed: ec=%d",
- (int) GetLastError ());
- release_fd (rfd);
- release_fd (wfd);
- close_handle (rh);
- close_handle (wh);
- release_hddesc (rhdesc);
- release_hddesc (whdesc);
- gpg_err_set_errno (EIO);
- return TRACE_SYSRES (-1);
+ if (!SetHandleInformation (rh, HANDLE_FLAG_INHERIT, 0))
+ {
+ gpg_err_set_errno (EIO);
+ return TRACE_SYSRES (-1);
}
- close_handle (wh);
- wh = hd;
}
/* Put the HANDLEs of the new pipe into the file descriptor table.