pkg/osutil: remove appengine tag

Appengine doesn't provide appengine tag anymore.
Resort to use of syscall package for ExitStatus instead.
This commit is contained in:
Dmitry Vyukov 2020-07-06 15:29:02 +02:00
parent 4e3820bfb2
commit 36db93ffb9
10 changed files with 12 additions and 59 deletions

View File

@ -10,6 +10,7 @@ import (
"os"
"os/exec"
"path/filepath"
"syscall"
"time"
)
@ -61,10 +62,16 @@ func Run(timeout time.Duration, cmd *exec.Cmd) ([]byte, error) {
if <-timedout {
text = fmt.Sprintf("timedout %q", cmd.Args)
}
exitCode := 0
if exitErr, ok := err.(*exec.ExitError); ok {
if status, ok := exitErr.Sys().(syscall.WaitStatus); ok {
exitCode = status.ExitStatus()
}
}
return output.Bytes(), &VerboseError{
Title: text,
Output: output.Bytes(),
ExitCode: exitCode(err),
ExitCode: exitCode,
}
}
return output.Bytes(), nil

View File

@ -1,7 +1,7 @@
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// +build akaros,!appengine
// +build akaros
package osutil

View File

@ -1,31 +0,0 @@
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// +build appengine
package osutil
import (
"os/exec"
)
func Sandbox(cmd *exec.Cmd, user, net bool) error {
return nil
}
func SandboxChown(file string) error {
return nil
}
func setPdeathsig(cmd *exec.Cmd) {
}
func killPgroup(cmd *exec.Cmd) {
}
func exitCode(err error) int {
// We are stuck on Go 1.11 on appengine.
// 1.11 does not have ProcessState.ExitCode.
// Once we upgrade to 1.12, we should remove this.
return 0
}

View File

@ -1,7 +1,7 @@
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// +build freebsd,!appengine netbsd,!appengine openbsd,!appengine
// +build freebsd netbsd openbsd
package osutil

View File

@ -1,8 +1,6 @@
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// +build !appengine
package osutil
import (

View File

@ -1,7 +1,7 @@
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// +build fuchsia,!appengine
// +build fuchsia
package osutil

View File

@ -1,8 +1,6 @@
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// +build !appengine
package osutil
import (

View File

@ -1,17 +0,0 @@
// Copyright 2020 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// +build !appengine
package osutil
import (
"os/exec"
)
func exitCode(err error) int {
if exitError, ok := err.(*exec.ExitError); ok {
return exitError.ProcessState.ExitCode()
}
return 0
}

View File

@ -1,7 +1,7 @@
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// +build freebsd,!appengine netbsd,!appengine openbsd,!appengine linux,!appengine darwin,!appengine
// +build freebsd netbsd openbsd linux darwin
package osutil

View File

@ -1,8 +1,6 @@
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// +build !appengine
package osutil
import (