Skip to content

Commit

Permalink
fix isSystemd()
Browse files Browse the repository at this point in the history
  • Loading branch information
kongfei605 committed Oct 18, 2023
1 parent afd0e0e commit 1845c51
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions agent/install/service_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,19 @@ func isSystemd() bool {
var stdout bytes.Buffer
var stderr bytes.Buffer

command := "ls -l /sbin/init"
cmd := exec.Command(command) //nolint:gosec
cmd := exec.Command("ls", "-l", "/sbin/init") //nolint:gosec
cmd.Stdout = &stdout
cmd.Stderr = &stderr

err, timeout := cmdx.RunTimeout(cmd, time.Second*2)
if timeout {
log.Printf("E! run command: %s timeout", command)
log.Printf("E! run command: %s timeout", cmd)
return false
}

if err != nil {
fmt.Errorf("failed to run command: %s | error: %v | stdout: %s | stderr: %s",
command, err, stdout.String(), stderr.String())
cmd, err, stdout.String(), stderr.String())
return false
}

Expand Down

0 comments on commit 1845c51

Please sign in to comment.