|
刚开始内核研究,很多不懂的地方请赐教哈
一个很简单的实验程序
---------------------------
#include <stdio.h>
main()
{
intx,fd[2];
char buf[30],s[30];
pipe(fd);
while((x=fork())==-1);
if(x==0)
{
sprintf(buf,"this is an example\n");
write(fd[1],buf,30);
exit(0);
}
else
{
wait(0);
read(fd[0],s,30);
printf("%s",s);
}
}
-------------
KATE
输出
cd '/home/pupie'
[pupie@localhost pupie]$ cd '/home/pupie'
[pupie@localhost pupie]$ gcc 69.c
69.c: In function `main':
69.c:4: `intx' undeclared (first use in this function)
69.c:4: (Each undeclared identifier is reported only once
69.c:4: for each function it appears in.)
69.c:4: `fd' undeclared (first use in this function)
69.c:7: `x' undeclared (first use in this function)
[pupie@localhost pupie]$
我是再MAGIC LINUX1.1 下,请问这么简单的个程序,怎么编译还出错,说未定义不会是系统的原因吧另外
还有一父子进程协同工作的问题
比如,父进程创建一个print任务,然后创建多个子进程,个进程协同完成,对共享资源加锁,请问利用管道方式如何实现?
谢谢! |
|