Linux系统管理综合辅导:vfork创建进程使用execl函数
日期:2014-04-29 14:40
.h
int main(int argc,char **argv)
{
if(argc2)
{
perror(you haven't input the filename!\n);
exit(EXIT_FAILURE);
}
pid_t pid;
pid=vfork();
if(pid0)
{
printf(Fork Error!\n);
exit(1);
}
else if(pid==0)
{
printf(I am the child.\n);
if(execl(./ceshi,ceshi,argv[1],NULL)0)
perror(execl error!\n);
}
else{
printf(I am the father\n);
return 0;
}
}
2/3 下一页 上一页 首页 尾页
返回
刷新
WAP首页
网页版
登录
05/19 22:37