2024-06-09 09:35:16 +00:00
|
|
|
// +build unix
|
2022-03-16 23:44:32 +00:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2022-05-22 00:53:36 +00:00
|
|
|
"syscall"
|
2022-03-16 23:44:32 +00:00
|
|
|
)
|
|
|
|
|
2022-05-22 00:53:36 +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
|
|
|
|
}
|