进程小问题

thesecretblue 2009-05-24 10:56:02
#include<stdio.h>
int main()
{ int pid;
pid=fork();
if(pid==0) {
printf("I am the child.\n");
execl("/bin/ls¡±,¡±ls",0);
perror("exec error.\n");
}
else if(pid>0)
printf("I am the parent.\n");
else printf("fork failed.\n");
printf("program end.\n");
return 0;
}

编译时出现的错误:
cc -o exe-os131 os131.c
os131.c: In function ‘main’:
os131.c:8: warning: not enough variable arguments to fit a sentinel

请教一下,该如何解决??

...全文
124 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
rendengke7213 2009-05-25
  • 打赏
  • 举报
回复
up
thesecretblue 2009-05-25
  • 打赏
  • 举报
回复
肯定正确,
因为我是在vi下编辑的,用了很多次了,很好用的。
Treazy 2009-05-25
  • 打赏
  • 举报
回复
请确认你的编译器是否安装正确!
Wolf0403 2009-05-25
  • 打赏
  • 举报
回复
http://www.linuxonly.nl/docs/2/2_GCC_4_warnings_about_sentinels.html
thesecretblue 2009-05-25
  • 打赏
  • 举报
回复
#include <stdio.h>
#include<unistd.h>
int main()
{ int pid;
pid=fork();
if(pid==0) {
printf("I am the child.\n");
execl("/bin/ls¡±,¡±ls",0);
perror("exec error.\n");
}
else if(pid>0)
printf("I am the parent.\n");
else printf("fork failed.\n");
printf("program end.\n");
return 0;
}

os131.c: In function ‘main’:
os131.c:8: warning: not enough variable arguments to fit a sentinel
警告是:没有足够的变量来满足

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧