This repository has been archived on 2026-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
go-php/services_unix.go
Snider d2081d91e7
Some checks failed
Security Scan / security (push) Successful in 8s
Test / test (push) Failing after 26s
feat: merge core/php CLI commands into go-php
Combines FrankenPHP handler package with PHP dev CLI commands
(build, deploy, QA, dev server, etc) from core/php. This frees
the core/php namespace for the Laravel PHP framework rename.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-04 17:12:52 +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
}