开发者

Unix FIFO in go?

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 (pi开发者_C百科pe), but no function for creating named pipes.

Am I the only one who needs them?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜