integration: Robust process termination
This commit is contained in:
parent
f470d1cc06
commit
bb4ab7e333
|
@ -21,6 +21,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -203,10 +204,20 @@ func (st *serverTester) Close() {
|
||||||
st.conn.Close()
|
st.conn.Close()
|
||||||
}
|
}
|
||||||
if st.cmd != nil {
|
if st.cmd != nil {
|
||||||
st.cmd.Process.Kill()
|
done := make(chan struct{})
|
||||||
st.cmd.Wait()
|
go func() {
|
||||||
// workaround to unreliable Process.Signal()
|
st.cmd.Wait()
|
||||||
time.Sleep(150 * time.Millisecond)
|
done <- struct{}{}
|
||||||
|
}()
|
||||||
|
|
||||||
|
st.cmd.Process.Signal(syscall.SIGQUIT)
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
case <-time.After(10 * time.Second):
|
||||||
|
st.cmd.Process.Kill()
|
||||||
|
<-done
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if st.ts != nil {
|
if st.ts != nil {
|
||||||
st.ts.Close()
|
st.ts.Close()
|
||||||
|
|
Loading…
Reference in New Issue