Skip to content

Instantly share code, notes, and snippets.

@ericlagergren
Created May 31, 2016 16:48
Show Gist options
  • Save ericlagergren/d061e49cfc885f91fe1228d33c252d5b to your computer and use it in GitHub Desktop.
Save ericlagergren/d061e49cfc885f91fe1228d33c252d5b to your computer and use it in GitHub Desktop.
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