I'm trying to run a separated program from an ocaml program (linked with
"-subsystem windows" flexlink option). I'm using mingw flavour of Ocaml.
The program to run separately is also an ocaml program, linked with
"-subsystem windows".
The problem is that a "c:\windows\system32\cmd.exe" windows pops up: I'd
like to avoid this.
I tried Sys.command and Unix.system without success.
Is there any way to run a program and get the process status without
using cmd.exe ?
Thanks
Matt
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
Both Sys.command and Unix.system use cmd in order to provide command line
parsing (it gives the closest equivalent to the Unix version - except for
the usual quoting weirdness of cmd as compared to bash!)
> I tried Sys.command and Unix.system without success.
>
> Is there any way to run a program and get the process status without
> using cmd.exe ?
It's been on my todo list to wrap the CreateProcess Win32 API function[1] in
a C stub function - someone else may have done this (possibly in
ocaml-win32[2] or something like that), though. The API is very simple (most
parameters will be NULL) so the stub would not take long to write.
David
[1] http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx
[2] http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=371
Matt
If i find a way to read the exit status of the process…
Pass a PROCESS_INFORMATION structure to CreateProcess (in order to get the hProcess for the process you created) and then use GetExitCodeProcess[1]. You can use WaitForSingleObject passing hProcess to it if you need to block until the process has actually terminated or you can loop on GetExitCodeProcess until the result is not equal to STILL_ACTIVE.
David
[1] http://msdn.microsoft.com/en-us/library/ms683189(VS.85).aspx
[2] http://msdn.microsoft.com/en-us/library/ms687032(VS.85).aspx
---
Adrien Nader
Did you try Unix.create_process?
Alain
Something like
Unix.waitpid []
(Unix.create_process
external_prog args
Unix.stdin Unix.stdout Unix.stderr)
does it.
Salutations
Matt