Skip to content

execution hangs when I try to open named pipe file #58854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
m-abdalrahman opened this issue Mar 3, 2023 · 1 comment
Closed

execution hangs when I try to open named pipe file #58854

m-abdalrahman opened this issue Mar 3, 2023 · 1 comment

Comments

@m-abdalrahman
Copy link

What version of Go are you using (go version)?

go version go1.20 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
GO111MODULE=""
GOARCH="amd64"
GOBIN="/media/user/sda7/golang/go-lib/bin"
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/media/user/sda7/golang/go-lib/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/media/user/sda7/golang/go-lib"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4146817264=/tmp/go-build -gno-record-gcc-switches"

What did you do?

trying to write to named pipe file, example

package main

import (
	"fmt"
	"log"
	"os"
	"syscall"
)

func main() {
	pipePath := "/tmp/myfifo"

	// Create the named pipe file
	err := syscall.Mkfifo(pipePath, 0666)
	if err != nil {
		log.Fatal(err)
	}

	// Open the named pipe file for writing
	file, err := os.OpenFile(pipePath, os.O_WRONLY, os.ModeNamedPipe)
	if err != nil {
		log.Fatal(err)
	}
	defer file.Close()

	fmt.Println("Hello")

	// Write data to the named pipe file
	data := []byte("Hello, world!")
	_, err = file.Write(data)
	if err != nil {
		log.Fatal(err)
	}

	// Remove the named pipe file
	err = os.Remove(pipePath)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("done")
}

What did you expect to see?

printing Hello, and printing done

What did you see instead?

nothing this code standing at os.OpenFile, waiting

@seankhliao
Copy link
Member

There's nothing reading from your pipe.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Mar 3, 2023
@golang golang locked and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants