inline execve

Signed-off-by: Jean-Francois Roy <jeroy@nvidia.com>
This commit is contained in:
Jean-Francois Roy 2024-10-30 08:57:21 -07:00
parent 8d8dbd38c3
commit 0c1e76a221

View File

@ -42,11 +42,16 @@ func main() {
} }
argv := []string{"runc"} argv := []string{"runc"}
argv = append(argv, os.Args[1:]...) argv = append(argv, os.Args[1:]...)
execve(program, argv, os.Environ()) if err := unix.Exec(program, argv, os.Environ()); err != nil {
log.Fatalf("failed to exec %s: %v", program, err)
}
} }
argv := makeArgv(program) argv := makeArgv(program)
envv := makeEnvv(program) envv := makeEnvv(program)
execve(program+".real", argv, envv) if err := unix.Exec(program+".real", argv, envv); err != nil {
log.Fatalf("failed to exec %s: %v", program+".real", err)
}
} }
func isRuntimeWrapper(program string) bool { func isRuntimeWrapper(program string) bool {
@ -107,9 +112,3 @@ func makeEnvv(program string) []string {
} }
return append(env, os.Environ()...) return append(env, os.Environ()...)
} }
func execve(program string, argv []string, envv []string) {
if err := unix.Exec(program, argv, envv); err != nil {
log.Fatalf("failed to exec %s: %v", program, err)
}
}