Created
May 31, 2016 16:48
-
-
Save ericlagergren/d061e49cfc885f91fe1228d33c252d5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func makePipe(path string) (file *os.File, err error) { | |
err = unix.Mkfifo(path, 0777) | |
if err != nil { | |
return nil, err | |
} | |
// mkfifo(3) states: | |
// "It is modified by the process's | |
// umask in the usual way: the permissions of the created file are | |
// (mode & ~umask)." | |
// The pipe must be writeable by other users. | |
err = os.Chmod(path, 0777) | |
if err != nil { | |
return nil, err | |
} | |
return os.OpenFile(path, os.O_CREATE|unix.O_NONBLOCK, os.ModeNamedPipe) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment