Skip to content

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

@sxllwx

Description

@sxllwx

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions