Bug 6709 – execvp eats two bytes of its first argument.

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2011-09-21T19:44:00Z
Last change time
2012-02-24T20:15:23Z
Assigned to
nobody
Creator
rivercheng

Comments

Comment #0 by rivercheng — 2011-09-21T19:44:36Z
#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 by hsteoh — 2012-02-24T19:41:34Z
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.