sigutil

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package sigutil provides signal-handling utilities for graceful cleanup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SignalCleanupGuard

type SignalCleanupGuard struct {
	// contains filtered or unexported fields
}

SignalCleanupGuard ensures a cleanup function runs exactly once when the process exits normally, on error, or via SIGINT/SIGTERM. Create one via NewSignalCleanupGuard and defer its Close method.

func NewSignalCleanupGuard

func NewSignalCleanupGuard(cleanup func(), logger *slog.Logger) *SignalCleanupGuard

NewSignalCleanupGuard registers SIGINT and SIGTERM handlers that invoke the cleanup function exactly once. The caller must defer Close() to ensure cleanup runs on normal/error exit and the signal handler is deregistered. A nil cleanup function is treated as a no-op.

func (*SignalCleanupGuard) Close

func (g *SignalCleanupGuard) Close()

Close performs cleanup (if not already done) and deregisters the signal handler.

Jump to

Keyboard shortcuts

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