// Package pause holds every process of a step's sandbox stopped while the // runner reads the sandbox's workspace (spec §3, "What it renders"; plan // task 9). // // The pause is signals only: SIGSTOP to every descendant of the sandbox's // first process, rescanning /proc until each one reads stopped, and // SIGCONT to all of them on every way out. No cgroup is frozen: freezing a // slice systemd spawns into once stalled PID 1. package pause import ( "errors" "time" ) // Bound is the longest a sandbox stays paused: stopping it and the work // done inside the pause together (spec §3: "at most 10 seconds"). const Bound = 10 * time.Second // Process is a sandbox's first process as containment recorded it when it // started: its host pid, its start time in clock ticks (field 22 of // /proc//stat) and its pid namespace link ("pid:[...]"; "" skips // that check). type Process struct { PID int StartTicks uint64 Namespace string } var ( // ErrBusy: the sandbox could not be held stopped within the bound, or // the work inside the pause ran past it. Everything is resumed. ErrBusy = errors.New("sandbox could not be paused in time") // ErrGone: the recorded first process is no longer the one running // at that pid (it exited, or the pid was reused). Nothing is signalled. ErrGone = errors.New("sandbox process is gone") // ErrUnsupported: this system has no pause (only Linux does). ErrUnsupported = errors.New("pausing a sandbox is not supported on this system") )