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

Closed
vicuna opened this issue Feb 28, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@vicuna
Copy link

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:

=== foo_ml.ml ===
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 foo_ml.ml
gcc -o foo_c.exe foo_c.c
./foo_ml.exe

File attachments

@vicuna

This comment has been minimized.

Copy link
Author

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
You can’t perform that action at this time.