signal

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// MAXSIG is the largest number of non-realtime signals (on Linux).
	// 32..64 are realtime signals and irrelevant to us at this point.
	MAXSIG = 31
)

Variables

This section is empty.

Functions

func Alarm

func Alarm(seconds int)

Alarm sets up a timer so a SIGALRM signal is fired after 'seconds' seconds.

Example
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.Signal(syscall.SIGALRM))

Alarm(1)

t0 := time.Now().Unix()
fmt.Println("... do work here ...")

sig := <-sigs // wait for SIGALRM
fmt.Printf("Got '%s' after %ds\n", sig.String(), time.Now().Unix()-t0)
Output:

... do work here ...
Got 'alarm clock' after 1s

Types

type Handler

type Handler struct {
	Chan chan os.Signal
}

Handler is used to handle the handle INT, TERM and CHLD signals.

func New

func New() Handler

New initializes the signal handlers. We now get events for all signals. Read the Handler.Chan and handle them appropriately.

func NewAlarmHupUsr1

func NewAlarmHupUsr1() Handler

NewAlarmHupUsr1 initializes signal handlers for ALRM, HUP and USR1. Read the Handler.Chan and handle them appropriately.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL