Unix FIFO在go中怎么实现?

huangapple go评论102阅读模式
英文:

Unix FIFO in go?

问题

有没有办法用Go语言创建一个Unix FIFO?在os包中没有MkfifoMknod,尽管我预期在posix操作系统中会广泛使用命名的FIFO。实际上,有一个用于创建无名FIFO(管道)的函数,但没有用于创建命名管道的函数。

只有我一个人需要它们吗?

英文:

Is there any way to create a unix FIFO with Go language? There is no Mkfifo, nor Mknod in os package, though I expected named FIFOs are largely used in posix OS's. In fact, there is a function for creating an unnamed FIFO (pipe), but no function for creating named pipes.

Am I the only one who needs them?

答案1

得分: 13

为了让它在Linux上运行,我只需执行以下操作:

syscall.Mknod(fullPath, syscall.S_IFIFO|0666, 0)

这似乎起到了作用。

这里是底层mknod()调用的参考链接:

英文:

In order to get it to work on Linux, I simply did a

syscall.Mknod(fullPath, syscall.S_IFIFO|0666, 0)

It seemed to do the trick.

Here is a reference for the underlying mknod() call

答案2

得分: 3

有一个Mkfifo,但它在syscall包中 Unix FIFO在go中怎么实现?

通过搜索源代码,我感觉它只在OS X和FreeBSD上可用:http://www.google.com/codesearch#search&q=Mkfifo+package:http://go%5C.googlecode%5C.com

我没有准备好的Unix机器来测试。如果你愿意,可以使用cgo构建一个C接口包,以便为您导出它。

英文:

There is a Mkfifo, but it's in the syscall-package Unix FIFO在go中怎么实现?

Searching through the source gives me the feeling it's not available on anything but OS X and FreeBSD though: http://www.google.com/codesearch#search&q=Mkfifo+package:http://go%5C.googlecode%5C.com

I don't have a unix machine ready to test with. You can use cgo if you like to build a C-interface package which exports it for you.

huangapple
  • 本文由 发表于 2011年6月22日 22:39:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/6441754.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定