What version of Go are you using (go version)?
$ go version
go version go1.15.2 darwin/amd64
Does this issue reproduce with the latest release?
It is the latest release
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/kimmo/Library/Caches/go-build"
GOENV="/Users/kimmo/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kimmo/Projects/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/kimmo/Projects/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15.2/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/kimmo/Projects/go/src/github.com/Mirantis/mcc/go.mod"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/t5/k06n6kss3qz1z5sf0y8pqsw40000gn/T/go-build559599993=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
I'm trying to write a remote terminal client that needs to relay Ctrl-Z to the remote host. Intercepting Ctrl-C works fine by using signal.Notify(c, os.Interrupt), but signal.Notify(c, syscall.SIGTSTP) works only half way.
package main
import (
"os"
"os/signal"
"syscall"
"time"
)
func main() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGTSTP)
go func() {
for {
<-c
println("received ctrl-z")
}
}()
for {
println("Sleeping...")
time.Sleep(time.Second * 10)
}
}
What did you expect to see?
Pressing Ctrl-Z should be intercepted and the go process should not suspend.
$ go run main.go
Sleeping...
received ctrl-z
Sleeping...
Sleeping...
What did you see instead?
received ctrl-z is printed but the go process itself is also suspended.
$ go run main.go
Sleeping...
received ctrl-z
[1]+ Stopped go run main.go
$ _
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
It is the latest release
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
I'm trying to write a remote terminal client that needs to relay Ctrl-Z to the remote host. Intercepting Ctrl-C works fine by using
signal.Notify(c, os.Interrupt), butsignal.Notify(c, syscall.SIGTSTP)works only half way.What did you expect to see?
Pressing Ctrl-Z should be intercepted and the go process should not suspend.
What did you see instead?
received ctrl-zis printed but the go process itself is also suspended.