execgate

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package execgate is the exec gate: bitc re-executes itself as "__exec-gate-1" so the command's process exists, in its own group, before the command runs. The supervisor records that process (pid, start time, group) in the ticket and only then releases the gate, which execs the command. A supervisor killed before the record leaves a gate, never a running command.

The gate runs in init() when os.Args[1] is Verb and never returns. It writes nothing to stdout or stderr on any path it controls.

Protocol, over two descriptors the supervisor passes as ExtraFiles:

  • gatefd, the read end of a pipe: one byte releases the gate; EOF means the supervisor is gone, and the gate exits 125 without running the command.
  • statusfd, the write end of a pipe: the gate writes the Hello byte first. After the release, a successful exec closes statusfd (it is close-on-exec) with nothing more written; a failed exec writes the errno as 4 little-endian bytes and the gate exits 127.

Signals: the gate catches QUIT only (exit 131). TERM, INT and HUP keep the Go runtime's default, a synchronous death by that signal, which is what the command would have done. The gate inherits SIG_DFL for all four, because the supervisor catches them, and the command gets SIG_DFL, as without a gate. Go's default for a signal nobody asked for (USR1, ALRM, WINCH and the like) is to drop it, so such a signal sent to the group from outside before the exec is swallowed; that is accepted.

Known side effects: LD_PRELOAD and DYLD_* in the job's environment also load into the gate, and GOTRACEBACK, GODEBUG and GOMAXPROCS apply to it. A QUIT to the group from outside in the instant between the gate's runtime start and its handler gives a Go traceback on stderr.

Index

Constants

View Source
const (
	HoldEnv   = "BITC_EXECGATE_TEST_HOLD"
	HoldAtEnv = "BITC_EXECGATE_TEST_HOLD_AT"
)

HoldEnv and HoldAtEnv are a test-only hold. HoldEnv names a FIFO; HoldAtEnv names the stage at which the gate blocks reading one byte from it: HoldHello (before it writes the hello byte) or HoldExec (after the release byte, before the exec). A test writes a byte to let the gate go on. Both are honoured, and stripped from the command's environment, only in a test binary.

View Source
const (
	HoldHello = "hello"
	HoldExec  = "exec"
)

The stages HoldAtEnv names.

View Source
const Hello byte = 'H'

Hello is the first byte the gate writes to statusfd.

View Source
const Verb = "__exec-gate-1"

Verb is the first argument of a gate process: <self> __exec-gate-1 <gatefd> <statusfd> <path> <argv...>.

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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