修复 某些情况下cmd异常导致进程挂掉的问题

This commit is contained in:
dengsgo 2019-01-24 14:02:56 +08:00
parent 042038a60e
commit 4e9eecd0cc

View File

@ -45,7 +45,7 @@ func (t *TaskMan) Put(cf *changedFile) {
}
func (t *TaskMan) preRun(cf *changedFile) {
if t.cmd != nil && t.cmd.Process != nil && !t.cmd.ProcessState.Exited() {
if t.cmd != nil && t.cmd.Process != nil && t.cmd.ProcessState != nil && !t.cmd.ProcessState.Exited() {
log.Println("stop old process ")
if err := t.cmd.Process.Kill(); err != nil {
log.Println(PreWarn, "stopped err, reason:", err)
@ -90,7 +90,7 @@ func (t *TaskMan) run(cf *changedFile) {
log.Println(PreWarn, "cmd wait err ", err)
break
}
if t.cmd.Process != nil && !t.cmd.ProcessState.Exited() {
if t.cmd.Process != nil && t.cmd.ProcessState != nil && !t.cmd.ProcessState.Exited() {
if err = t.cmd.Process.Kill(); err != nil {
log.Println(PreWarn, "cmd cannot kill, reason:", err)
}