summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2022-03-29 14:43:13 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2022-03-29 14:43:13 +0900
commit660db9c9a90f377fc14a5d659d974d68d782b2d1 (patch)
tree8913899386514e7fb41efabcfe25f02391527bff
parent6e17e70bb7eea1f6ed4c08f795ea65a09f89d38f (diff)
downloadlibgpg-error-660db9c9a90f377fc14a5d659d974d68d782b2d1.tar.gz
w32: Fix handle_to_pid for MinGW-w64.
* src/spawn-w32.c (handle_to_pid): Use pid_t to coerce the type. -- GnuPG-bug-id: 4656 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r--src/spawn-w32.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/spawn-w32.c b/src/spawn-w32.c
index 3ede1f2..1b5f085 100644
--- a/src/spawn-w32.c
+++ b/src/spawn-w32.c
@@ -74,11 +74,14 @@
* long as the range of the value in the type HANDLE can be
* represented by an int, it works.
*
- * FIXME: Breaking ABI for pid_t will be needed when the value won't
- * fit within 32-bit range on 64-bit machine.
+ * FIXME with original MinGW: Breaking ABI for pid_t will be needed
+ * when the value won't fit within 32-bit range on 64-bit machine.
+ *
+ * Note that pid_t is 64-bit integer in sys/types.h with MinGW-w64.
+ * So, no problem with MinGW-w64.
*/
#define pid_to_handle(a) ((HANDLE)(a))
-#define handle_to_pid(a) ((int)(a))
+#define handle_to_pid(a) ((pid_t)(a))
/* Return the maximum number of currently allowed open file
@@ -421,7 +424,7 @@ _gpgrt_spawn_process (const char *pgmname, const char *argv[],
*r_outfp = NULL;
if (r_errfp)
*r_errfp = NULL;
- *pid = (pid_t)(-1); /* Always required. */
+ *pid = (pid_t)INVALID_HANDLE_VALUE; /* Always required. */
if (r_infp)
{
@@ -650,7 +653,7 @@ _gpgrt_spawn_process_fd (const char *pgmname, const char *argv[],
HANDLE stdhd[3];
/* Setup return values. */
- *pid = (pid_t)(-1);
+ *pid = (pid_t)INVALID_HANDLE_VALUE;
/* Prepare security attributes. */
memset (&sec_attr, 0, sizeof sec_attr );
@@ -746,7 +749,7 @@ _gpgrt_wait_processes (const char **pgmnames, pid_t *pids, size_t count,
if (r_exitcodes)
r_exitcodes[i] = -1;
- if (pids[i] == (pid_t)(-1))
+ if (pids[i] == (pid_t)INVALID_HANDLE_VALUE)
return GPG_ERR_INV_VALUE;
procs[i] = pid_to_handle (pids[i]);
@@ -896,7 +899,7 @@ _gpgrt_spawn_process_detached (const char *pgmname, const char *argv[],
void
_gpgrt_kill_process (pid_t pid)
{
- if (pid != (pid_t) INVALID_HANDLE_VALUE)
+ if (pid != (pid_t)INVALID_HANDLE_VALUE)
{
HANDLE process = (HANDLE) pid;