'waits for the running command to finish.  this is called on all
running commands, eventually, except for ones that run in the background'

def wait(self):

    if (not self._process_completed):
        self._process_completed = True
        exit_code = self.process.wait()
        if self.process.timed_out:
            raise TimeoutException((- exit_code))
        else:
            self.handle_command_exit_code(exit_code)
            if self.process._stdin_process:
                self.process._stdin_process.command.wait()
    self.log.info('process    completed')
    return self
