// killProcessOnCancel waits for a cancel request. // If a cancel request is received, this method kills the underlying // process of the command. This will unblock the command.Wait() call. // If the task completed successfully this method returns with no action. func killProcessOnCancel(log log.T, command *exec.Cmd, cancelFlag task.CancelFlag) { cancelFlag.Wait() if cancelFlag.Canceled() { log.Debug("Process cancelled. Attempting to stop process.") // task has been asked to cancel, kill process if err := killProcess(command.Process); err != nil { log.Error(err) return } log.Debug("Process stopped successfully.") } }