process.go 346 B

123456789101112131415161718192021222324
  1. package plugin
  2. import (
  3. "time"
  4. )
  5. // pidAlive checks whether a pid is alive.
  6. func pidAlive(pid int) bool {
  7. return _pidAlive(pid)
  8. }
  9. // pidWait blocks for a process to exit.
  10. func pidWait(pid int) error {
  11. ticker := time.NewTicker(1 * time.Second)
  12. defer ticker.Stop()
  13. for range ticker.C {
  14. if !pidAlive(pid) {
  15. break
  16. }
  17. }
  18. return nil
  19. }