Documentation ¶
Overview ¶
Example (WithUnregisteredSignals) ¶
dctx, cancel := context.WithTimeout(context.TODO(), time.Millisecond*100) defer cancel() ctx := WithSignals(dctx, syscall.SIGUSR1) go func() { time.Sleep(10 * time.Millisecond) // after some time SIGUSR2 is sent // mimicking a signal from the outside, WithSignals will not handle it syscall.Kill(syscall.Getpid(), syscall.SIGUSR2) }() <-ctx.Done() fmt.Println("finished")
Output: finished
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithSignals ¶
WithSignals returns a context that is canceled with any signal in sigs.
Example ¶
ctx := WithSignals(context.Background(), syscall.SIGUSR1) go func() { time.Sleep(500 * time.Millisecond) // after some time SIGUSR1 is sent // mimicking a signal from the outside syscall.Kill(syscall.Getpid(), syscall.SIGUSR1) }() <-ctx.Done() fmt.Println("finished")
Output: finished
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.