Skip to content

syscall: add mechanism to steal the controlling terminal from a different session group on Linux #20454

@devimc

Description

@devimc

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

go version devel +5e79787 Mon May 22 13:44:12 2017 +0000 linux/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/X/gopath/"
GORACE=""
GOROOT="/home/X/gopath/src/github.com/golang/go-linux-amd64-bootstrap"
GOTOOLDIR="/home/X/gopath/src/github.com/golang/go-linux-amd64-bootstrap/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build111441286=/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?

cmd := exec.Command(config.Path)
cmd.Env = os.Environ()
f, err = os.OpenFile(params.Console, os.O_RDWR, 0660)
if err != nil {
	return -1, err
}
cmd.Stdin = f
cmd.Stdout = f
cmd.Stderr = f
cmd.SysProcAttr = &syscall.SysProcAttr{
	// Create Session
	Setsid: true,
	// Set Controlling terminal to Ctty
	Setctty: true,
	Ctty:    int(f.Fd()),
}
if err := cmd.Start(); err != nil {
	return -1, err
}

What did you expect to see?

A processes running using the assigned terminal

What did you see instead?

fork/exec X: operation not permitted

Solution

Allow spawned processes steal the terminal

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions