one.go 312 B

12345678910111213141516171819202122232425
  1. // +build linux
  2. package one
  3. import (
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. )
  8. func PidOne() error {
  9. c := make(chan os.Signal, 2048)
  10. signal.Notify(c, syscall.SIGCHLD)
  11. for range c {
  12. for {
  13. if pid, err := syscall.Wait4(-1, nil, syscall.WNOHANG, nil); err != nil || pid <= 0 {
  14. break
  15. }
  16. }
  17. }
  18. return nil
  19. }