1
0

phone_record_other.go 718 B

12345678910111213141516171819202122232425262728
  1. //go:build !windows
  2. // phone_record_other.go — 非 Windows 下 scrcpy 录屏的进程控制(占位)。
  3. // scrcpy 在 Unix 下接收 SIGINT 优雅结束;这里用 Kill 兜底。
  4. package main
  5. import (
  6. "os"
  7. "os/exec"
  8. )
  9. // prepareRecordProcess 在非 Windows 平台无额外进程组设置(scrcpy 前台运行)。
  10. func prepareRecordProcess(cmd *exec.Cmd) {
  11. // Unix 下不需要隐藏窗口/进程组,保持默认
  12. _ = cmd
  13. }
  14. // stopRecordProcess 在非 Windows 平台发送 SIGINT(scrcpy 收到后保存录制退出)。
  15. func stopRecordProcess(pid int) error {
  16. if pid <= 0 {
  17. return os.ErrInvalid
  18. }
  19. p, err := os.FindProcess(pid)
  20. if err != nil {
  21. return err
  22. }
  23. return p.Signal(os.Interrupt)
  24. }