Skip to content
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

x/sys/windows: syscall.CREATE_BREAKAWAY_FROM_JOB isn't defined #22801

Closed
kenhys opened this issue Nov 18, 2017 · 2 comments
Closed

x/sys/windows: syscall.CREATE_BREAKAWAY_FROM_JOB isn't defined #22801

kenhys opened this issue Nov 18, 2017 · 2 comments

Comments

@kenhys
Copy link

@kenhys kenhys commented Nov 18, 2017

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

% go version
go version go1.9.2 linux/amd64

Does this issue reproduce with the latest release?

Yes, because the flag is not defined in master.

ref. https://github.com/golang/sys/blob/master/windows/types_windows.go#L161-L162

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

I've noticed this issue to use sample program with gox.

% go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/kenhys/go"
GORACE=""
GOROOT="/home/kenhys/.anyenv/envs/goenv/versions/1.9.2"
GOTOOLDIR="/home/kenhys/.anyenv/envs/goenv/versions/1.9.2/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build954881475=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

% cat sample.go
package main

import (
        "golang.org/x/sys/windows"
        "log"
        "os/exec"
        "syscall"
)

func Launch(path string, args []string) {
        command := exec.Command(path, args...)
        // CREATE_BREAKAWAY_FROM_JOB = 0x01000000
        command.SysProcAttr = &syscall.SysProcAttr{CreationFlags: syscall.CREATE_BREAKAWAY_FROM_JOB}
        // Current workaround for CREATE_BREAKAWAY_FROM_JOB flag
        //command.SysProcAttr = &syscall.SysProcAttr{CreationFlags: 0x01000000}
        err := command.Start()
        if err != nil {
                log.Fatal(err)
        }
}

func main() {
        Launch("host.exe", []string{})
}

https://play.golang.org/p/wjYmyv81ph

What did you expect to see?

syscall.CREATE_BREAKAWAY_FROM_JOB is defined as follows.

See
https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
about CREATE_BREAKAWAY_FROM_JOB itself.

diff --git a/windows/types_windows.go b/windows/types_windows.go
index 78b714c..2ba3a7d 100644
--- a/windows/types_windows.go
+++ b/windows/types_windows.go
@@ -161,6 +161,7 @@ const (

        CREATE_NEW_PROCESS_GROUP   = 0x00000200
        CREATE_UNICODE_ENVIRONMENT = 0x00000400
+       CREATE_BREAKAWAY_FROM_JOB  = 0x01000000

        PROCESS_TERMINATE         = 1
        PROCESS_QUERY_INFORMATION = 0x00000400

What did you see instead?

syscall.CREATE_BREAKAWAY_FROM_JOB is undefined.

+ gox -os=windows temp_sample/sample
Number of parallel builds: 7

-->   windows/amd64: temp_sample/sample
-->     windows/386: temp_sample/sample

2 errors occurred:
--> windows/386 error: exit status 2
Stderr: # temp_sample/sample
src/temp_sample/sample/sample.go:4:2: imported and not used: "golang.org/x/sys/windows"
src/temp_sample/sample/sample.go:13:60: undefined: syscall.CREATE_BREAKAWAY_FROM_JOB
@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Nov 18, 2017

The syscall package is frozen. (see its package docs) If somebody wants to add it to x/sys/windows, that's fine.

/cc @crunk1 @alexbrainman @awnumar @tmm1

@bradfitz bradfitz added the OS-Windows label Nov 18, 2017
@gopherbot
Copy link

@gopherbot gopherbot commented Nov 18, 2017

Change https://golang.org/cl/78618 mentions this issue: windows: add process creation flags

@golang golang locked and limited conversation to collaborators Nov 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.