sighandling

package
v0.0.0-...-44b9737 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: Apache-2.0, MIT Imports: 7 Imported by: 12

Documentation

Overview

Package sighandling contains helpers for handling signals to applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreChildStop

func IgnoreChildStop() error

IgnoreChildStop sets the SA_NOCLDSTOP flag, causing child processes to not generate SIGCHLD when they stop.

func KillItself

func KillItself() error

KillItself sends SIGKILL to the current process, bypassing the init process restriction.

The standard `kill(getpid(), SIGKILL)` syscall doesn't work when the current process is the init process within its PID namespace. This is a "known" Linux feature.

This function uses the rt_tgqueueinfo syscall to send a "kernel-generated" SIGKILL.

func ReplaceSignalHandler

func ReplaceSignalHandler(sig unix.Signal, handler uintptr, previous *uintptr) error

ReplaceSignalHandler replaces the existing signal handler for the provided signal with the function pointer at `handler`. This bypasses the Go runtime signal handlers, and should only be used for low-level signal handlers where use of signal.Notify is not appropriate.

It stores the value of the previously set handler in previous.

func StartSignalForwarding

func StartSignalForwarding(handler func(linux.Signal)) func()

StartSignalForwarding ensures that synchronous signals are passed to the given handler function and returns a callback that stops signal delivery.

Note that this function permanently takes over signal handling. After the stop callback, signals revert to the default Go runtime behavior, which cannot be overridden with external calls to signal.Notify.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳