mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:20:43 +00:00
Co-authored-by: openclaw-clawsweeper[bot] <280122609+openclaw-clawsweeper[bot]@users.noreply.github.com>
37 lines
808 B
Go
37 lines
808 B
Go
//go:build windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"os"
|
|
"os/exec"
|
|
"strconv"
|
|
)
|
|
|
|
var runWindowsTaskkill = func(pid int) error {
|
|
ctx, cancel := context.WithTimeout(context.Background(), docsI18nCommandWaitDelay())
|
|
defer cancel()
|
|
return exec.CommandContext(ctx, "taskkill.exe", "/T", "/F", "/PID", strconv.Itoa(pid)).Run()
|
|
}
|
|
|
|
func configureCodexPromptCommand(command *exec.Cmd) {
|
|
command.Cancel = func() error {
|
|
if command.Process == nil {
|
|
return os.ErrProcessDone
|
|
}
|
|
if err := runWindowsTaskkill(command.Process.Pid); err != nil {
|
|
killErr := command.Process.Kill()
|
|
if errors.Is(killErr, os.ErrProcessDone) {
|
|
return os.ErrProcessDone
|
|
}
|
|
if killErr != nil {
|
|
return errors.Join(err, killErr)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
command.WaitDelay = docsI18nCommandWaitDelay()
|
|
}
|