[Techtalk] wrapping unix commands

Dan dan at cellectivity.com
Fri Apr 8 18:29:48 EST 2005

> execve("pciconf", args, NULL);

This command does something that surprises a lot of people when they 
first use it. As the man page says, "execve() does not return on 
success, and the text, data, bss, and stack of the  calling  process 
are overwritten  by  that of the program loaded."

In other words, no statements after the excve() command will be 
executed, unless you fork() first.

An alternative is to use system(), which behaves more as you might 
expect (returns after the command has executed). In some cases it's more 
convenient, because its syntax is closer to shell syntax.

However, system() can easily lead to security holes. So execve() is 
probably a better choice for you.

    I'm actually hoping that [Linux] won't take more than 25 or 30%
    of the market. If Linux owned 95% of the market it would be
    ... as sick [as Windows]. There is some need for competition.
                - Linus Torvalds

More information about the Techtalk mailing list