日期:2014-05-16 浏览次数:20685 次
#include <apue.h>
#include <sys/wait.h>
char * env_init[] = {"USER=unknow","PATH=/tmp",NULL};
int main(void)
{
pid_t pid;
if((pid=fork())<0)
{
printf("fork error\n");
}
else if(pid == 0)
{
if(execle("/home/zhuhaichao/apue练习/8.17“,”8.17“,”mysql","MY ARG2",(char *) 0,env_init)<0)
printf("execute error\n"); //我就把pathname改了,要执行的可执行文件8.17在这个目录下
}
if(waitpid(pid,NULL,0)<0)
{
printf("wait error\n");
}
if((pid=fork())<0)
{
printf("fork error\n");
}
else if(pid == 0)
{
if(execlp("8.17","8.17","only 1 arg",(char *) 0)<0)
{
printf("exec error\n");
}
}
exit(0);