Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix.open_process fails to pass empty arguments #6332

vicuna opened this issue Feb 28, 2014 · 1 comment

Unix.open_process fails to pass empty arguments #6332

vicuna opened this issue Feb 28, 2014 · 1 comment


Copy link

@vicuna vicuna commented Feb 28, 2014

Original bug ID: 6332
Reporter: prevosto
Assigned to: @damiendoligez
Status: closed (set by @damiendoligez on 2014-05-16T18:51:01Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: x86
OS: Windows
OS Version: 7
Version: 4.01.0
Fixed in version: 4.02.0+dev
Category: platform support (windows, cross-compilation, etc)
Monitored by: bobot

Bug description

As mentioned in #6107, under Windows, Unix.open_process and friends build a command-line string from the argv array.

Doing this, they fail to properly quote an empty string given as argument, as can be seen with the following example:

=== ===
let a = [| "./foo_c.exe"; ""; |];;

Printf.printf "number of args passed to create_process is %d\n%!" (Array.length a);
Unix.create_process "./foo_c.exe" a Unix.stdin Unix.stdout Unix.stderr

exit 0;;

=== foo_c.c ===== (taken from #2939)
#include <stdio.h>
#include <windows.h>

int main(int argc, char ** argv)
int i;
printf("Raw command line is:\n%s\n", GetCommandLine());
printf("Number of args is: %d\n",argc);
printf("Parsed command line is:\n");
for (i = 0; i < argc; i++) printf("\targv[%d] = %s\n", i, argv[i]);
return 0;

The attached patch will take care of the issue

Steps to reproduce

ocamlc -o foo_ml.exe unix.cma
gcc -o foo_c.exe foo_c.c

File attachments

Copy link

@vicuna vicuna commented May 16, 2014

Comment author: @damiendoligez

Fixed in 4.02+dev7 (commit 14888)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants