LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 956|回复: 2

关于LINUX 进程通信的相关问题。

[复制链接]
发表于 2003-6-30 23:27:02 | 显示全部楼层 |阅读模式
刚开始内核研究,很多不懂的地方请赐教哈
一个很简单的实验程序
---------------------------
#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任务,然后创建多个子进程,个进程协同完成,对共享资源加锁,请问利用管道方式如何实现?

谢谢!
发表于 2003-7-1 21:33:25 | 显示全部楼层
intx,fd[2]; 改为int x ,fd[2];
发表于 2004-4-10 11:01:26 | 显示全部楼层
老大,你也太低级了吧。明显的错误吗
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表