I'm trying to trap CTRL-Z, in Linux, to avoid that the process can run in background, but it does not works
// * * *
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
)
func main() {
sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGTSTP) // CTRL-Z
L:
for {
select {
case <-sig:
case <-time.After(10 * time.Second):
fmt.Println("timed out")
break L
}
}
fmt.Println("exit")
}
// * * *
And according to the next documentation, SIGTSTP is the signal used at pressing CTRL-Z:
http://www2.chrishardick.com:1099/Notes/Computing/C/UnixSignals.htmlWhy is failling? Do I have used a worng signal to be caught?