test_helper: kill lsof after 1 second

lsof may get stuck when gocryptfs itself is stuck.
This commit is contained in:
Jakob Unterwurzacher 2020-05-09 19:03:16 +02:00
parent 16221facb9
commit f0184804f4
1 changed files with 7 additions and 1 deletions

View File

@ -126,7 +126,13 @@ func UnmountPanic(dir string) {
cmd := exec.Command("lsof", dir)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
cmd.Start()
timer := time.AfterFunc(1*time.Second, func() {
fmt.Printf("timeout!")
cmd.Process.Kill()
})
cmd.Wait()
timer.Stop()
panic("UnmountPanic: unmount failed: " + err.Error())
}
}