github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/pkg/sys/signal_unix.go (about)

     1  //go:build !windows && !plan9 && !js
     2  // +build !windows,!plan9,!js
     3  
     4  package sys
     5  
     6  import (
     7  	"os"
     8  	"os/signal"
     9  	"syscall"
    10  )
    11  
    12  func notifySignals() chan os.Signal {
    13  	// This catches every signal regardless of whether it is ignored.
    14  	sigCh := make(chan os.Signal, sigsChanBufferSize)
    15  	signal.Notify(sigCh)
    16  	// Calling signal.Notify will reset the signal ignore status, so we need to
    17  	// call signal.Ignore every time we call signal.Notify.
    18  	//
    19  	// TODO: Remove this if, and when, job control is implemented. This
    20  	// handles the case of running an external command from an interactive
    21  	// prompt.
    22  	//
    23  	// See https://b.elv.sh/988.
    24  	signal.Ignore(syscall.SIGTTIN, syscall.SIGTTOU, syscall.SIGTSTP)
    25  	return sigCh
    26  }