backport of commit 8ff31f32a525ed32273a65e6d28b88e24e9cf06e (#20895)

Co-authored-by: Anton Averchenkov <84287187+averche@users.noreply.github.com>
This commit is contained in:
hc-github-team-secure-vault-core 2023-05-31 20:37:32 -04:00 committed by GitHub
parent afef4629c8
commit 76929df206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -838,16 +838,21 @@ func (c *AgentCommand) Run(args []string) int {
var exitCode int
if err := g.Run(); err != nil {
c.logger.Error("runtime error encountered", "error", err)
c.UI.Error("Error encountered during run, refer to logs for more details.")
var processExitError *exec.ProcessExitError
if errors.As(err, &processExitError) {
exitCode = processExitError.ExitCode
} else {
exitCode = 1
}
if exitCode != 0 {
c.logger.Error("runtime error encountered", "error", err, "exitCode", exitCode)
c.UI.Error("Error encountered during run, refer to logs for more details.")
}
}
c.notifySystemd(systemd.SdNotifyStopping)
return exitCode
}