1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
//go:build linux

package main

import (
	"os"

	"github.com/nixos/lix/gonix/builder"
)

// maybeRunBuilder checks whether this process was re-exec'd as the sandbox
// launcher ("__builder") and, if so, runs the launcher (which never returns).
// Must be called as the very first thing in main, before any arg parsing,
// because the launcher communicates over fd 0 and expects a pristine process.
func maybeRunBuilder() {
	if len(os.Args) >= 2 && os.Args[1] == builder.BuilderSubcommand {
		builder.LauncherMain()
	}
}