Merge pull request #811 from miaoyq/replace-two-Unlock-with-defer-Unlock

User 'defer Unlock' to replace two 'Unlock's
This commit is contained in:
Phil Estes 2017-05-08 14:04:33 -04:00 committed by GitHub
commit 3e485e4623

View File

@ -70,13 +70,12 @@ func (m *Monitor) Start(c *exec.Cmd) error {
ExitCh: make(chan int, 1), ExitCh: make(chan int, 1),
} }
m.Lock() m.Lock()
defer m.Unlock()
// start the process // start the process
if err := rc.c.Start(); err != nil { if err := rc.c.Start(); err != nil {
m.Unlock()
return err return err
} }
m.cmds[rc.c.Process.Pid] = rc m.cmds[rc.c.Process.Pid] = rc
m.Unlock()
return nil return nil
} }