Replace 43 test files with their upstream/main versions to eliminate test file merge conflicts entirely (43 files, 604 markers → 0). Fork-only test functions are extracted to *_ext_test.go files (19 files) which have no upstream counterpart and thus never conflict. Source-level upstream alignment: - config/defaults: AllowRemote defaults to true - config/migration: model names match upstream (gpt-5.4) - session/manager: sanitizeFilename replaces / and \ - state: log.Printf instead of log.Fatalf on mkdir failure - wecom: verifySignature returns false on empty token (fail-closed) - openclaw migration: preserves AllowRemote default Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
567 B
Go
35 lines
567 B
Go
package tools
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
"syscall"
|
|
)
|
|
|
|
func processRunning(pid int) bool {
|
|
if pid <= 0 {
|
|
return false
|
|
}
|
|
|
|
err := syscall.Kill(pid, 0)
|
|
if err != nil && err != syscall.EPERM {
|
|
return false
|
|
}
|
|
|
|
data, readErr := os.ReadFile("/proc/" + strconv.Itoa(pid) + "/stat")
|
|
if readErr != nil {
|
|
return false
|
|
}
|
|
raw := string(data)
|
|
end := strings.LastIndex(raw, ")")
|
|
if end == -1 || end+2 >= len(raw) {
|
|
return true
|
|
}
|
|
fields := strings.Fields(raw[end+2:])
|
|
if len(fields) == 0 {
|
|
return true
|
|
}
|
|
state := fields[0]
|
|
return state != "Z"
|
|
}
|