In the above code the invoker will return immediately with "success". It
ought to be possible to modify the code to use Posix.Process.waitpid to
wait for the child process. Possibly something along the lines of
SOME pid =>
(case Posix.Process.waitpid(Posix.Process.W_CHILD pid, []) of
W_EXITED => OS.Process.exit OS.Process.success
| W_EXITSTATUS n => Posix.Process.exit n
| _ => ???
)

However you do this you probably want to avoid using Posix.Process.fork
on Cygwin (if that's relevant) since it's very expensive so it might be
a good idea to try using Posix.Process.exec first and only use "fork" if
you get ENOTSUP. It would certainly be worth looking at Makarius' code.

Well, it seems as if the problem for exec is just on MacOS, and I'm happy to 
fork there, even if it's annoying to have to do so.  Cygwin is not really 
relevant, but I suppose that, out of idle curiosity, it would nice to know if 
Posix.Process.exec worked there.  My application really only wants to exec, not 
fork.

This does look like something non-standard in Apple's code. The detailed
page for Posix "exec" simply says, "A call to any exec function from a
process with more than one thread shall result in all threads being
terminated and the new executable image being loaded and executed. No
destructor functions or cleanup handlers shall be called."

A spec that we know is implementable because Linux manages it...

Michael
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to