问题描述
在Linux(2.6.35-22版)中,man pipe
指出
In Linux (2.6.35-22-generic), man pipe
states that
在FreeBSD(6.3-RELEASE-p5)中,man pipe
指出
In FreeBSD (6.3-RELEASE-p5), man pipe
states that
一个是单向的,另一个是双向的.我希望这不是一个愚蠢的问题,但是哪种方法是实现此目的的标准方法?它们都符合POSIX吗?
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?
为了明确我的意图,我在一次考试中损失了一些分数,因为相信pipe()是一种方法,并且我正在寻找一些弹药来收回任何分数; p
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
推荐答案
起初,我是以此作为对Greg答案的评论,但是我发现它更紧密地回答了您的特定问题:
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()
的文档在POSIX标准中明确指出:所讨论的行为是未指定"的-即,虽然未禁止pipe()
双向,但它不是必需的. Linux是单向的,FreeBSD是双向的.两者都是合规的,只是实现了不需要的其他行为(但不会破坏为在兼容系统上运行而构建的应用程序).
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.
这篇关于POSIX:FreeBSD与Linux中的管道系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!