当我编译以下代码并在其上运行strace
时,我可以看到它向args[]
数组添加了两个附加元素。
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc,char **argv)
{
char *args[2];
args[0] = "/bin/ls";
args[1] = "-lh";
execve(args[0],args,NULL);
return 1;
}
strace
说,这实际上是所谓的:
execve("/bin/ls",["/bin/ls","-lh","\340\301\361\267","\1"],NULL)