Skip to content

os/exec: document that ExtraFiles does not work on Windows #26182

Closed
@FMNSSun

Description

@FMNSSun

Please answer these questions before submitting your issue. Thanks!

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

1.10.3 windows/amd64

Does this issue reproduce with the latest release?

1.10.3 seems to be currently the latest release so: yep.

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

windows 10 home, amd64, Intel i5-6200U

set GOARCH=amd64
set GOBIN=%GOPATH%\bin
set GOCACHE=C:\Users\me\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\me\go
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 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 -fmessage-length=0 -fdebug-prefix-map=C:\Users\me\AppData\Local\Temp\go-build361648014=/tmp/go-build -gno-record-gcc-switches

BTW: Having GOBIN=%GOPATH%\bin causes a lot of packages (from github) to not compile for some reason. (It works if one overrides it with manually expanding GOPATH).

What did you do?

The package os.Exec mentions that some examples assume Unix and might not work on Windows but it doesn't mention that it doesn't support windows and by looking at the source code it oughta support it.

fork/exec prog.exe: not supported by windows
cmd := exec.Command(normCmd)

	// direct access to datafile
	cmd.Stdin = rawfile

	// metadata-filtered observations on stdout
	obspipe, err := cmd.StdoutPipe()
	if err != nil {
		return err
	}

	// pass through stderr
	cmd.Stderr = os.Stderr

	// metadata on fd 3
	metapipeCmd, metapipe, err := os.Pipe()
	if err != nil {
		return err
	}

	cmd.ExtraFiles = make([]*os.File, 1)
	cmd.ExtraFiles[0] = metapipeCmd

	// start the command
	if err := cmd.Start(); err != nil { // errors on windows
		log.Fatal(err) 
		return err
	}

What did you expect to see?

The program being run.

What did you see instead?

An error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions