Skip to content

os: could not iterate over named pipes on Windows #32423

@Codehardt

Description

@Codehardt

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

$ go version
go version go1.12.5 windows/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\mars9\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\mars9\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\mars9\AppData\Local\Temp\go-build413446826=/tmp/go-build -gno-record-gcc-switches

What did you do?

I wanted to iterate over Windows' named pipes using os package:

	f, err := os.Open(`\\.\pipe`)
	if err != nil {
		log.Fatalf("Could not open pipe list: %s", err)
	}
	defer f.Close()
	stat, err := f.Stat()
	if err != nil {
		log.Fatalf("Could not get file stats: %s", err)
	}
	log.Printf("Is Directory: %t", stat.IsDir()) // output: false
	pipelist, err := f.Readdir(-1)
	if os.IsNotExist(err) {
		log.Print("Pipe list does not exist")
	} else if err != nil {
		log.Printf("Could not read pipe list: %s", err)
	}
	for _, pipe := range pipelist {
		log.Printf("Pipe found: %s", pipe.Name())
	}

What did you expect to see?

The same result as in Python:

for pipeName in os.listdir(r'\\.\pipe'):
    print("Pipe found: %s" % pipeName)
Pipe found: InitShutdown
Pipe found: lsass
Pipe found: ntsvcs
Pipe found: scerpc
...

What did you see instead?

Is Directory: false
Pipe list does not exist

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions