[MLton-commit] r7166
Matthew Fluet
fluet at mlton.org
Wed Jun 17 15:15:35 PDT 2009
Use Cygwin waitpid for spawn-ed processes.
----------------------------------------------------------------------
U mlton/trunk/basis-library/posix/process.sml
U mlton/trunk/runtime/platform/cygwin.c
----------------------------------------------------------------------
Modified: mlton/trunk/basis-library/posix/process.sml
===================================================================
--- mlton/trunk/basis-library/posix/process.sml 2009-06-17 21:55:41 UTC (rev 7165)
+++ mlton/trunk/basis-library/posix/process.sml 2009-06-17 22:15:35 UTC (rev 7166)
@@ -1,4 +1,5 @@
-(* Copyright (C) 1999-2006, 2008 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2009 Matthew Fluet.
+ * Copyright (C) 1999-2006, 2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
* Copyright (C) 1997-2000 NEC Research Institute.
*
@@ -102,7 +103,7 @@
fun wait (wa, status, flags) =
let
val useCwait =
- Primitive.MLton.Platform.OS.useWindowsProcess
+ Primitive.MLton.Platform.OS.host = Primitive.MLton.Platform.OS.MinGW
andalso case wa of W_CHILD _ => true | _ => false
val pid =
case wa of
Modified: mlton/trunk/runtime/platform/cygwin.c
===================================================================
--- mlton/trunk/runtime/platform/cygwin.c 2009-06-17 21:55:41 UTC (rev 7165)
+++ mlton/trunk/runtime/platform/cygwin.c 2009-06-17 22:15:35 UTC (rev 7166)
@@ -129,56 +129,3 @@
/* cygwin has a different method for working with its fds */
setmode (fd, O_TEXT);
}
-
-/* ------------------------------------------------- */
-/* Process */
-/* ------------------------------------------------- */
-
-C_Errno_t(C_PId_t) MLton_Process_cwait (C_PId_t pid, Ref(C_Status_t) status) {
- HANDLE h;
-
- h = (HANDLE)pid;
- /* -1 on error, the casts here are due to bad types on both sides */
- return cwait ((int*)status, (pid_t)h, 0);
-}
-
-/* 20070822, fluet: The following 'pure win32' implementation of cwait
- * no longer works on recent Cygwin versions. It always takes the
- * {errno = ECHILD; return -1} branch, even when the child process
- * exists.
- */
-
-/* Cygwin replaces cwait with a call to waitpid.
- * waitpid only works when the process was created by cygwin and there
- * is a secret magical pipe for sending signals and exit statuses over.
- * Screw that. We implement our own cwait using pure win32.
- */
-/* C_Errno_t(C_PId_t) MLton_Process_cwait(C_PId_t pid, Ref(C_Status_t) status) { */
-/* HANDLE h; */
-
-/* h = (HANDLE)pid; */
-/* /\* This all works on Win95+ *\/ */
-/* while (1) { */
-/* /\* Using an open handle we can get the exit status *\/ */
-/* unless (GetExitCodeProcess (h, (DWORD*)status)) { */
-/* /\* An error probably means the child does not exist *\/ */
-/* errno = ECHILD; */
-/* return -1; */
-/* } */
-/* /\* Thank you windows API. */
-/* * I hope no process ever exits with STILL_ACTIVE. */
-/* * At least most other windows programs have this bug too. */
-/* *\/ */
-/* if (*(DWORD*)status != STILL_ACTIVE) /\* 259 *\/ */
-/* break; */
-/* /\* Wait for h to change state for up to one second. */
-/* * We don't wait longer b/c there is a race condition */
-/* * between checking the exit status and calling this method. */
-/* * By only waiting 1s, no infinite loop can result. */
-/* *\/ */
-/* WaitForSingleObject (h, 1000); */
-/* } */
-/* /\* Cleanup the process handle -- don't call this method again *\/ */
-/* CloseHandle (h); */
-/* return pid; */
-/* } */
More information about the MLton-commit
mailing list