system vs. execvp ?

Jonathan M Davis jmdavisProg at gmx.com
Sat Sep 22 16:10:11 PDT 2012


On Sunday, September 23, 2012 00:53:48 Peter Sommerfeld wrote:
>   Hi!
> 
> This works as expected:
> 
>    string cmd = "dmd src/xyz.d";
>    int i = system(cmd);
> 
> But this not:
> 
>    string[] cmd;
>    cmd ~= "src/xyz.d";
>    int i = execvp("dmd",cmd);
> 
> Of course, dmd is in PATH (Win7).
> 
> What is wrong here?

Please elaborate on what doesn't work as expected. We can't help you if you 
don't tell us what's wrong.

system should run your command in a new process and return, whereas execvp 
will run it and never return, because the new process replaces your current 
one.

Now, looking at the docs for std.process.execvp, they seem to think that the 
exec functions are going to return, but that's not what the man pages for the 
C functions (which they're calling) say, nor is it how they behave. Maybe 
that's your problem?

http://linux.die.net/man/3/exec
http://msdn.microsoft.com/en-us/library/3xw6zy53.aspx

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list