executor_windows.go 945 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //go:build windows
  2. // +build windows
  3. package executor
  4. import (
  5. "context"
  6. "os"
  7. "os/exec"
  8. )
  9. func (e *Executor) Kill(execReq *InternalLogEntry) error {
  10. if execReq == nil {
  11. return nil
  12. }
  13. runExecToolHelperKillCommand(execReq.Attributes)
  14. if execReq.Process != nil {
  15. return execReq.Process.Kill()
  16. }
  17. return nil
  18. }
  19. func wrapCommandInShell(ctx context.Context, finalParsedCommand string) *exec.Cmd {
  20. winCodepage := os.Getenv("OT_WIN_FLAG_U")
  21. if winCodepage == "0" {
  22. return exec.CommandContext(ctx, "cmd", "/C", finalParsedCommand)
  23. } else {
  24. return exec.CommandContext(ctx, "cmd", "/u", "/C", finalParsedCommand)
  25. }
  26. }
  27. func wrapCommandDirect(ctx context.Context, execArgs []string) *exec.Cmd {
  28. if len(execArgs) == 0 {
  29. return nil
  30. }
  31. return exec.CommandContext(ctx, execArgs[0], execArgs[1:]...)
  32. }
  33. func wrapCommandExecTool(ctx context.Context, name string) *exec.Cmd {
  34. return exec.CommandContext(ctx, "olivetin-"+name, "exec")
  35. }