Skip to content

Commit

Permalink
coverage: fix race of signal vs start of a process
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed Apr 4, 2019
1 parent dd498d9 commit 9464408
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions coverage/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,26 @@ func main() {
Pdeathsig: syscall.SIGTERM,
}

sig := make(chan os.Signal, 1)
sig := make(chan os.Signal, 10)
start := make(chan struct{})
go func() {
<-start
for {
p.Process.Signal(<-sig)
}
}()

signal.Notify(sig, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)

err = p.Run()
err = p.Start()
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}

close(start)

err = p.Wait()
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
Expand Down

0 comments on commit 9464408

Please sign in to comment.