进程间如何通信!?

Xfly 2000-06-27 05:52:00
我要写一个perl程序,要求是多进程的,子进程与父进程之间需要通信,
并且父进程不定期的需要给子进程发送数据信息,子进程再对这些数据做处理!

哪为高手能给些这方面的指点,感激不尽!

以下这段函数利用管道实现了进程间的通信,但是无法做到“父进程不定期的给
子进程
发送数据信息,子进程接收这些数据信息”!希望高手能帮忙改一下!
#! /usr/bin/perl
pipe(INPUT, OUTPUT);
$retval = fork();
if ($retval != 0) {
# this is the parent process
close (INPUT);
print ("Enter a line of input:\n");
$line = <STDIN>;
print OUTPUT ($line);
print "Parent\n";
} else {
# this is the child process
close (OUTPUT);
$line = <INPUT>;
print ($line);
print "Child\n";
}
...全文
104 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunsetyang 2000-06-27
  • 打赏
  • 举报
回复
You can try to use pipe.The parent can write to the pipe,while the child process read the pipe.If the pipe is empty,the child process will block.

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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