Documentation
¶
Overview ¶
Package sigmod provides signal listening as a module.
Index ¶
Examples ¶
Constants ¶
View Source
const ID = "sigmod"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
func New ¶
New creates signal listener for given signals. If no signal is provided, os.Interrupt will be used.
Example ¶
package main
import (
"os"
"syscall"
"time"
"github.com/go-srvc/mods/sigmod"
"github.com/go-srvc/srvc"
)
func main() {
//nolint: errcheck
go func() {
// Send SIGINT after 1 second.
time.Sleep(time.Second)
p, _ := os.FindProcess(syscall.Getegid())
p.Signal(os.Interrupt)
}()
srvc.RunAndExit(
sigmod.New(os.Interrupt),
)
}
Output:
Click to show internal directories.
Click to hide internal directories.