Comment #0 by golovanov_alexey — 2009-07-01T04:27:17Z
Phobos in DMD 2.030 and DMD 1.045 on Windows XP SP3:
function std.process.execv(in string pathname, in immutable(char)[][] argv)
don't pass argv parameters to executed program correctly. First element of argv not passed (replaced by program name, or removed).
Short example - caller.exe should run called.exe with parameters "arg1", "arg2", "arg3", then called.exe should save passed parameters into log file:
/*** begin file caller.d */
import std.process;
void main()
{
string[] args = ["arg1", "arg2", "arg3"];
std.process.execv("called.exe", args);
}
/*** end file caller.d */
/*** begin file called.d */
import std.file;
import std.string;
void main(string[] args)
{
string s = std.string.join(args, " ");
std.file.write("called.log", s);
}
/*** end file called.d */
In Windiws XP environment called.log will contain line:
"called.exe arg2 arg3"
but expected:
"called.exe arg1 arg2 arg3"
Comment #1 by golovanov_alexey — 2009-07-01T04:28:48Z
Created attachment 408
caller program using std.process.execv()
Comment #2 by golovanov_alexey — 2009-07-01T04:29:33Z
Created attachment 409
called programm, received parameters
Comment #3 by golovanov_alexey — 2009-07-09T00:48:35Z
this behaviour repeated in DMD 2.031
Comment #4 by repeatedly — 2010-05-28T13:36:35Z
This behavior is caused by dmc(I tested on Windows XP).
called.c
-----
#include <stdio.h>
int main(int argc, char* argv[])
{
int i = 0;
for (; i < argc; i++)
printf("%s ", argv[i]);
}
-----
caller.c
-----
#include <stdlib.h>
int main()
{
const char* const argv[] = {"a1", "a2", "a3", NULL};
execv("called.exe", argv);
return 0;
}
-----
dmc prints "called.exe a2 a3" but gcc prints "a1 a2 a3". I think expected behavior is gcc result(not "called.exe arg1 arg2 arg3").
Comment #5 by dlang-bugzilla — 2014-02-10T07:28:49Z
execv is now deprecated, and customizing argument 0 is not supported by the new std.process. If you require this functionality for something, please reopen or file an enhancement request.