mirror of
https://github.com/taigrr/systemctl.git
synced 2026-04-02 02:28:50 -07:00
refactor: use unused constants instead of removing them
- Export unitTypes as UnitTypes and add HasValidUnitSuffix helper - Use killed const (exit code 130) in execute() to detect SIGINT - Update go.mod to go 1.26
This commit is contained in:
7
util.go
7
util.go
@@ -11,6 +11,9 @@ import (
|
||||
|
||||
var systemctl string
|
||||
|
||||
// killed is the exit code returned when a process is terminated by SIGINT.
|
||||
const killed = 130
|
||||
|
||||
func init() {
|
||||
path, _ := exec.LookPath("systemctl")
|
||||
systemctl = path
|
||||
@@ -37,6 +40,10 @@ func execute(ctx context.Context, args []string) (string, string, int, error) {
|
||||
warnings = stderr.String()
|
||||
code = cmd.ProcessState.ExitCode()
|
||||
|
||||
if code == killed {
|
||||
return output, warnings, code, ErrExecTimeout
|
||||
}
|
||||
|
||||
customErr := filterErr(warnings)
|
||||
if customErr != nil {
|
||||
err = customErr
|
||||
|
||||
Reference in New Issue
Block a user