From c7c05c8e5723ed833ed0e73d24d7f7c45169c6e9 Mon Sep 17 00:00:00 2001
From: Ron Yorston <rmy@pobox.com>
Date: Wed, 18 May 2016 11:06:02 +0100
Subject: ash: fix use of pid/handle in waitpid_child

Previously spawn was returning a process handle which was treated as a
pid in certain circumstances.  This resulted in the following failing:

   find . -type f | sed xargs -n 1 sed -n '1 p'

It should output the first line of each file but stopped after the
first.
---
 win32/process.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

(limited to 'win32')

diff --git a/win32/process.c b/win32/process.c
index 8cd1dc28c..9a4b05597 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -332,7 +332,19 @@ mingw_spawn_1(int mode, const char *cmd, const char *const *argv, const char *co
 pid_t FAST_FUNC
 mingw_spawn(char **argv)
 {
-	return mingw_spawn_1(P_NOWAIT, argv[0], (const char *const *)argv, (const char *const *)environ);
+	intptr_t ret;
+
+	ret = mingw_spawn_1(P_NOWAIT, argv[0], (const char *const *)argv,
+			(const char *const *)environ);
+
+	return ret == -1 ? -1 : GetProcessId((HANDLE)ret);
+}
+
+intptr_t FAST_FUNC
+mingw_spawn_proc(char **argv)
+{
+	return mingw_spawn_1(P_NOWAIT, argv[0], (const char *const *)argv,
+			(const char *const *)environ);
 }
 
 int
-- 
cgit v1.2.3-55-g6feb