POSIX:FreeBSD 与 Linux 中的管道系统调用
在 Linux (2.6.35-22-generic) 中,man pipeline
指出
pipe() 创建一个管道,一个可用于进程间通信的单向数据通道。”
在 FreeBSD (6.3-RELEASE-p5) 中,man pipeline
指出
pipe()系统调用创建一个管道,它是一个允许双向数据流的对象,并分配一对文件描述符。”
一个是单向的,另一个是双向的。我希望这不是一个愚蠢的问题,但是哪个方法是这样做的标准方法吗?
为了明确我的意图,我在考试中失去了一些分数,因为我相信 pipeline() 是一种方法,并且正在寻找一些弹药来恢复任何分数;p
In Linux (2.6.35-22-generic), man pipe
states that
pipe() creates a pipe, a unidirectional data channel that can be used for interprocess communication."
In FreeBSD (6.3-RELEASE-p5), man pipe
states that
The pipe() system call creates a pipe, which is an object allowing bidirectional data flow, and allocates a pair of file descriptors."
One is unidirectional, the other is bidirectional. I hope this isn't a silly question, but which method is the standard way of doing this? Are they both POSIX compliant?
To make my intentions clear, I lost some points on an exam for believing pipe() was one way and am looking for some ammo to get any points back ;p
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我一开始是作为对 Greg 答案的评论开始的,但我发现它更接近地回答了您的具体问题:
pipe()
s POSIX 标准中的文档 明确指出所讨论的行为是“未指定的”——即pipe()< /code> 并不要求是双向的,但并不禁止。 Linux 是单向的,FreeBSD 是双向的。两者都是兼容的,其中一种只是实现了不需要的额外行为(但不会破坏为在兼容系统上运行而构建的应用程序)。
我不会指望拿回积分(尽管你应该这样做)。教授们倾向于忽视现实世界,而倾向于他们认为正确的事物。
I started this as a comment on Greg's answer at first, but it occurs to me that it more closely answers your specific question:
pipe()
s documentation in the POSIX standard explicitly states that the behavior in question is "unspecified" -- that is,pipe()
is not required to be bidirectional, though it's not forbidden. Linux's is unidirectional, FreeBSD's is bidirectional. Both are compliant, one just implements additional behavior that is not required (but doesn't break apps built to work on compliant systems).I wouldn't count on getting the points back (though you should). Professors have a tendency to ignore the real world in favor of whatever they've decided is correct.
FreeBSD 的
pipe
手册页在这一点上非常清楚:The FreeBSD man page for
pipe
is pretty clear on this point: