Skip to content

Commit

Permalink
fix centos5 build
Browse files Browse the repository at this point in the history
  • Loading branch information
varas committed Dec 7, 2020
1 parent f5395c5 commit 8c0d7c9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
19 changes: 19 additions & 0 deletions internal/gobackfill/gte_1_12.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2020 New Relic Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Golang code for Go versions greater or equal than 1.12.
//
// +build go1.12

package gobackfill

import "os/exec"

// ExitCode wrapping to backfill old Golang versions.
// Negative values mean:
// * -1: not exited
// * -2: unknown
func ExitCode(exitError *exec.ExitError) int {
return exitError.ExitCode()
}

14 changes: 14 additions & 0 deletions internal/gobackfill/lt_1_12.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2020 New Relic Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Golang code for Go versions lower than 1.12.
//
// +build !go1.12

package gobackfill

// ExitCode not supported, always value -2, as -1 belong to not finished.
func ExitCode(exitError *exec.ExitError) int {
return -2
}

3 changes: 2 additions & 1 deletion internal/integrations/v4/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os/exec"
"sync"

"github.com/newrelic/infrastructure-agent/internal/gobackfill"
"github.com/newrelic/infrastructure-agent/internal/integrations/v4/constants"
"github.com/newrelic/infrastructure-agent/pkg/helpers"
"github.com/newrelic/infrastructure-agent/pkg/log"
Expand Down Expand Up @@ -101,7 +102,7 @@ func (r *Executor) Execute(ctx context.Context, pidChan, exitCodeCh chan<- int)
out.Errors <- err
if exitCodeCh != nil {
if exitError, ok := err.(*exec.ExitError); ok {
exitCodeCh <- exitError.ExitCode()
exitCodeCh <- gobackfill.ExitCode(exitError)
}
}
}
Expand Down

0 comments on commit 8c0d7c9

Please sign in to comment.