linux 下的execle()函数
程序中见到这么一句话
if (interp == NULL) {
execle(cmd, cmd, (char *) 0, envp); /* (char *) 0 to squash warning */
} else {
/*changed start*/
interp = "/home/linaro/http/tool/uav.cgi";
/*envp[20] = '\0'; */
/*changed end*/
execle(interp, interp, cmd, (char *) 0, envp);
}
这句话的意思应该是如果interp为空,执行cmd,并传递环境参数,否则执行cgi.
那么来看看这个execle()函数的原型,
int execle(const char *path, const char *arg, ..., char * const envp[]);
示例程序:execle.c
hello.c
#include <unistd.h> #include <stdio.h> extern char** environ; int main(void) { printf("hello pid=%d\n", getpid()); int i; for (i=0; environ[i]!=NULL; ++i) { printf("%s\n", environ[i]); } return 0; }