英文:
Unix FIFO in go?
问题
有没有办法用Go语言创建一个Unix FIFO?在os
包中没有Mkfifo
或Mknod
,尽管我预期在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
包中
通过搜索源代码,我感觉它只在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
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论