D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6709 - execvp eats two bytes of its first argument.
Summary: execvp eats two bytes of its first argument.
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-21 19:44 UTC by Cheng Wei
Modified: 2012-02-24 20:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Cheng Wei 2011-09-21 19:44:36 UTC
#import std.process
void main() {
    execvp("ip", "route");
}

result:
Object "ute" is unknown, try "ip help".

That is the first two bytes are lost

Adding two spaces works:
#import std.process
void main() {
    execvp("ip", "  route");
}

Version 2.055, linux, 32bit

Thanks.
Comment 1 hsteoh 2012-02-24 19:41:34 UTC
You're calling execvp with the wrong arguments. You need to call it like this:

execvp("ip", ["ip", "route"]);

because argv[0] is supposed to be the name of the program, and argv[1]... are the program arguments.

As for the actual bug (first two characters get eaten), it's not a Phobos bug, it's a bug in /bin/ip. To prove this, try this (from your home directory):

ln -s /bin/ip ./route
./route

You'll get the same error message, because argv in this case = ["ip"]. It appears that /bin/ip is doing something strange when argv[0] is not equal to "ip", but there's not much Phobos can do about it.