You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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"
)
funcmain() {
c:=make(chan os.Signal)
signal.Notify(c, syscall.SIGTSTP)
gofunc() {
for {
<-cprintln("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
$ _
The text was updated successfully, but these errors were encountered:
@seankhliao is correct. Setting the local terminal to raw mode (for example via "golang.org/x/crypto/ssh/terminal"s MakeRaw()) makes it work even in go run mode (which also makes ctrl-d work)
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 env
OutputWhat 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-z
is printed but the go process itself is also suspended.The text was updated successfully, but these errors were encountered: