2022-03-16 23:44:32 +00:00
|
|
|
// +build linux darwin
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2022-05-21 10:03:53 +00:00
|
|
|
"syscall"
|
2022-03-16 23:44:32 +00:00
|
|
|
)
|
|
|
|
|
2022-05-21 10:03:53 +00:00
|
|
|
var bgProcAttr *syscall.SysProcAttr = &syscall.SysProcAttr{
|
|
|
|
Setpgid: true,
|
|
|
|
}
|
|
|
|
|
2022-03-18 00:22:30 +00:00
|
|
|
func findExecutable(path string, inPath, dirs bool) error {
|
2022-03-16 23:44:32 +00:00
|
|
|
f, err := os.Stat(path)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-03-18 00:22:30 +00:00
|
|
|
if dirs {
|
|
|
|
if m := f.Mode(); m & 0111 != 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if m := f.Mode(); !m.IsDir() && m & 0111 != 0 {
|
|
|
|
return nil
|
|
|
|
}
|
2022-03-16 23:44:32 +00:00
|
|
|
}
|
|
|
|
return errNotExec
|
|
|
|
}
|