Avoid duplicate --attached flag when re-exec-ing boot process.

Some parameters are not already part of os.Args because they are solely
configured by Boot.Execute(). These need to be manually added in
Boot.prepareArgs(). But --attached is *not* one of these parameters. It is
not configured by boot process, it is configured by invokers of boot process.

PiperOrigin-RevId: 529264276
This commit is contained in:
Ayush Ranjan
2023-05-03 19:56:26 -07:00
committed by gVisor bot
parent 05bd5da348
commit 18a4f0c214
+3 -7
View File
@@ -452,14 +452,10 @@ func (b *Boot) prepareArgs(exclude ...string) []string {
}
}
args = append(args, arg)
// Strategically add parameters after the command and before the container
// ID at the end.
// Some parameters are not already part of os.Args because they are
// solely configured by Boot.Execute(). Strategically add these parameters
// after the command and before the container ID at the end.
if arg == "boot" {
if b.attached {
// This is needed to ensure the new process is killed when the parent
// process terminates.
args = append(args, "--attached")
}
if b.procMountSyncFD != -1 {
args = append(args, fmt.Sprintf("--proc-mount-sync-fd=%d", b.procMountSyncFD))
}