shutdown

package
v0.1.0-proto2l Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package shutdown is the PID-1 teardown executor (GAPI-DIV-027): a correct init shutdown is StopAll -> sync -> reverse umount -> reboot(2), replacing the naive grace + SIGKILL pattern. The privileged surface is an interface so the exact call order is asserted in unit tests without rebooting anything.

Index

Constants

reboot(2) commands, aliased so tests assert the mapping portably.

Variables

This section is empty.

Functions

func SystemShutdown

func SystemShutdown(sys Syscalls, mgr AgentStopper, mountTable []mounts.MountSpec, action Action, grace time.Duration) error

SystemShutdown runs the phased teardown. StopAll is bounded by grace - a hung agent cannot block sync() - and the deadline derives from context.Background(), never an already-cancelled signal context. Unmount and StopAll failures are logged, not fatal: the machine is going down either way, and the remaining phases only make that safer.

Types

type Action

type Action int

Action selects the final reboot(2) command.

const (
	PowerOff Action = iota
	Reboot
	Halt
)

type AgentStopper

type AgentStopper interface {
	StopAll() error
}

AgentStopper is the slice of the agent manager teardown needs.

type SysCalls

type SysCalls struct{}

SysCalls is the real privileged surface.

func (SysCalls) Reboot

func (SysCalls) Reboot(cmd int) error

func (SysCalls) Sync

func (SysCalls) Sync()

func (SysCalls) Unmount

func (SysCalls) Unmount(target string, flags int) error

type Syscalls

type Syscalls interface {
	Sync()
	Unmount(target string, flags int) error
	Reboot(cmd int) error
}

Syscalls is the privileged surface: sync(2), umount2(2), reboot(2).

Jump to

Keyboard shortcuts

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