[MLton-user] Posix.Process.exece on MinGW

Vesa Karvonen vesa.a.j.k at gmail.com
Fri Jun 1 04:49:56 PDT 2007


On 5/30/07, Dave Herman <dherman at ccs.neu.edu> wrote:
> The MLton.World.load call uses Posix.Process.exece to restart the
> program with the special @MLton commands to load a world file, but in
> MinGW this isn't implemented.

Note that as described on the http://mlton.org/MLtonWorld page, one
can use a runtime option to load a saved world.  The runtime option
doesn't seem to require exece and also seems to work on MinGW.  So, if
all you want is to save the world of your interpreter after the
libraries have been loaded and then be able to start the interpreter
without having to perform the costly loading of libraries, you can
already do that on MinGW. All you have to do is to have a script that
passes the load-world runtime option to the interpreter executable. I
would recommend considering this alternative.

I also took a look at implementing exece on MinGW.  It turns out that
MinGW already provides an execve (and an execvp) function.  Their
prototypes are in the <process.h> header.  To use them one only needs
to remove the exece and execp stubs from

  basis-library/posix/stub-mingw.sml

I did that and wrote a simple program that uses MLton.World.load:

open MLton.World
val file = "world.saved"
val () =
    case CommandLine.arguments () of
       ["load"] => (load file ; print "You should never see this!\n")
     | _        =>
       case save file of
          Original => print "I am the original.\n"
        | Clone    =>
          (print "I am the clone, say something: "
         ; case TextIO.inputLine TextIO.stdIn of
              NONE => print "Have it your way then!\n"
            | SOME t => print ("You said: "^t))

The above worked as I expected it to in Linux. In Windows/MinGW,
however, the exece (execve) call seemed to detach the process from the
console, but the world was loaded.  I'm not sure where the problem is,
but it might be possible to work around/fix it.

-Vesa Karvonen



More information about the MLton-user mailing list