Advertisement
kgeorgie

Untitled

Nov 30th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.40 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "os"
  6.     "os/exec"
  7.     "time"
  8. )
  9.  
  10. func main() {
  11.     prom := exec.Command("tail", "-f /dev/null")
  12.     done := make(chan error)
  13.     go func() {
  14.         done <- prom.Run()
  15.     }()
  16.  
  17.     prom.Process.Signal(os.Interrupt)
  18.     <-done
  19.  
  20.     pid, e := os.FindProcess(prom.Process.Pid)
  21.  
  22.     fmt.Println(pid.Pid) // Here it always returns some PID as if the process hasn't stopped yet.
  23.     fmt.Println(e)
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement