Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Named Pipes in Go for both Windows and Linux

Tags:

People also ask

Does Linux have named pipes?

A pipe is an important mechanism in Unix-based systems that allows us to communicate data from one process to another without storing anything on the disk. In Linux, we have two types of pipes: pipes (also known as anonymous or unnamed pipes) and FIFO's (also known as named pipes).

Are named pipes secure Linux?

No. Pipes on Linux are interceptable through /proc/$pid/fd/$thePipeFd as if they were unlinked fifos created by the pipe creator and (I guess with their umask applied?).

What is the difference between ordinary pipes and named pipes?

One of the key differences between regular pipes and named pipes is that named pipes have a presence in the file system. That is, they show up as files. But unlike most files, they never appear to have contents. Even if you write a lot of data to a named pipe, the file appears to be empty.


I am new to Go, I want to create Named Pipes implementation in Go which works on both Windows and Linux.

I managed to get the code working on Ubuntu, but this one does not work on Windows

Isn't there any abstraction in Go which allows you to work with Named Pipes in both environment

Below is piece of my code

//to create pipe: does not work in windows    
syscall.Mkfifo("tmpPipe", 0666)    

// to open pipe to write    
file, err1 := os.OpenFile("tmpPipe", os.O_RDWR, os.ModeNamedPipe)    

//to open pipe to read    
file, err := os.OpenFile("tmpPipe", os.O_RDONLY, os.ModeNamedPipe)

Any help or pointers would help a lot. Thanks