Skip to content

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

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
FMNSSun opened this issue Jul 2, 2018 · 3 comments
Closed

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

FMNSSun opened this issue Jul 2, 2018 · 3 comments
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@FMNSSun
Copy link

FMNSSun commented Jul 2, 2018

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.

@FMNSSun FMNSSun changed the title os.Exec not working on windows? os/exec not working on windows? Jul 2, 2018
@ianlancetaylor ianlancetaylor changed the title os/exec not working on windows? os/exec: not working on windows? Jul 2, 2018
@ianlancetaylor
Copy link
Member

The os/exec package does work on Windows. What doesn't work on Windows is setting the ExtraFiles field of exec.Command.

@ianlancetaylor ianlancetaylor changed the title os/exec: not working on windows? os/exec: document that ExtraFiles does not work on Windows Jul 2, 2018
@gopherbot gopherbot added the Documentation Issues describing a change to documentation. label Jul 2, 2018
@ianlancetaylor ianlancetaylor added help wanted and removed Documentation Issues describing a change to documentation. labels Jul 2, 2018
@gopherbot gopherbot added the Documentation Issues describing a change to documentation. label Jul 2, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.12 milestone Jul 2, 2018
@gopherbot gopherbot added the Documentation Issues describing a change to documentation. label Jul 2, 2018
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 2, 2018
@ianlancetaylor
Copy link
Member

Changing this to a documentation issue.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/123855 mentions this issue: os/exec: document ExtraFiles is not supported on windows

@golang golang locked and limited conversation to collaborators Jul 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants