php/pkg/php/services_unix.go
Snider 74ef3ec5e4
Some checks failed
CI / PHP 8.4 (push) Failing after 2m8s
CI / PHP 8.3 (push) Failing after 2m18s
refactor: move Go source files to pkg/php/
Restructure for production embedding — all Go source now under pkg/php/
with locales embedded alongside. Entry point at cmd/core-php/ imports
forge.lthn.ai/core/php/pkg/php. Prepares for Gin router frontend and
native binary production deployment.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-12 19:14:14 +00:00

41 lines
869 B
Go

//go:build unix
package php
import (
"os/exec"
"syscall"
)
// setSysProcAttr sets Unix-specific process attributes for clean process group handling.
func setSysProcAttr(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
}
}
// signalProcessGroup sends a signal to the process group.
// On Unix, this uses negative PID to signal the entire group.
func signalProcessGroup(cmd *exec.Cmd, sig syscall.Signal) error {
if cmd.Process == nil {
return nil
}
pgid, err := syscall.Getpgid(cmd.Process.Pid)
if err == nil {
return syscall.Kill(-pgid, sig)
}
// Fallback to signaling just the process
return cmd.Process.Signal(sig)
}
// termSignal returns SIGTERM for Unix.
func termSignal() syscall.Signal {
return syscall.SIGTERM
}
// killSignal returns SIGKILL for Unix.
func killSignal() syscall.Signal {
return syscall.SIGKILL
}