lock.go: fix race condition

Fix a race condition between startChild() and killChild() that could
lead to an orphaned managed process.

Fixes #1155
This commit is contained in:
Michael S. Fischer 2015-08-05 09:06:51 -07:00
parent 813e223906
commit 9e0e9e389d
1 changed files with 3 additions and 2 deletions

View File

@ -268,13 +268,14 @@ func (c *LockCommand) startChild(script string, doneCh chan struct{}) error {
cmd.Stderr = os.Stderr
// Start the child process
c.childLock.Lock()
if err := cmd.Start(); err != nil {
c.Ui.Error(fmt.Sprintf("Error starting handler: %s", err))
c.childLock.Unlock()
return err
}
// Setup the child info
c.childLock.Lock()
c.child = cmd.Process
c.childLock.Unlock()