Ensure cmd.SysProcAttr is set before modifying it
@@ -60,6 +60,7 @@ func (r *RunCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.Bui
cmd.Stderr = os.Stderr
replacementEnvs := buildArgs.ReplacementEnvs(config.Env)
cmd.Env = replacementEnvs
+ cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
// If specified, run the command as a specific user
if config.User != "" {
@@ -91,7 +92,6 @@ func (r *RunCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.Bui
}
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uid, Gid: gid}
}
- cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
if err := cmd.Start(); err != nil {
return errors.Wrap(err, "starting command")
