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

os/exec: context becomes done, but Cmd.Run() still blocks for a long time #56187

Closed
sxllwx opened this issue Oct 13, 2022 · 3 comments
Closed

Comments

@sxllwx
Copy link
Contributor

sxllwx commented Oct 13, 2022

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

$ go version
go version go1.19.2 linux/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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ubuntu/.cache/go-build"
GOENV="/home/ubuntu/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ubuntu/.gvm/pkgsets/go1.19.2/global/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ubuntu/.gvm/pkgsets/go1.19.2/global"
GOPRIVATE=""
GOPROXY="https://goproxy.woa.com,direct"
GOROOT="/home/ubuntu/.gvm/gos/go1.19.2"
GOSUMDB="sum.woa.com+643d7a06+Ac5f5VOC4N8NUXdmhbm8pZSXIWfhek5JSmWdWrq7pLX4"
GOTMPDIR=""
GOTOOLDIR="/home/ubuntu/.gvm/gos/go1.19.2/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3184007767=/tmp/go-build -gno-record-gcc-switches"

What did you do?

golang-code: https://go.dev/play/p/YZ7rxFZihNv

main.sh:

#!/bin/bash
sleep 10000

please chmod +x ./main.sh

What did you expect to see?

It is expected that after one second, cmd.Run() exits and returns the error that the process is Killed.

What did you see instead?

cmd.Run() blocks forever and cannot return.

@gopherbot
Copy link

Change https://go.dev/cl/442500 mentions this issue: os/exec: exit cmd.Run() when context becomes done

sxllwx added a commit to sxllwx/go that referenced this issue Oct 13, 2022
@bcmills
Copy link
Contributor

bcmills commented Oct 13, 2022

Duplicate of #23019

@bcmills bcmills marked this as a duplicate of #23019 Oct 13, 2022
@bcmills
Copy link
Contributor

bcmills commented Oct 13, 2022

#50436 proposes a solution to this that does not break backward compatibility.

@bcmills bcmills closed this as not planned Won't fix, can't repro, duplicate, stale Oct 13, 2022
@golang golang locked and limited conversation to collaborators Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants