'run a command on the jail.  This is only needed for implementing
put_file() get_file() so that we don\'t have to read the whole file
into memory.
compared to exec_command() it looses some niceties like being able to
return the process\'s exit code immediately.'

def _buffered_exec_command(self, cmd, stdin=subprocess.PIPE):

    local_cmd = [self.jexec_cmd]
    set_env = ''
    if (self._play_context.remote_user is not None):
        local_cmd += ['-U', self._play_context.remote_user]
        set_env = (('HOME=~' + self._play_context.remote_user) + '    ')
    local_cmd += [self.jail, self._play_context.executable, '-c', (set_env + cmd)]
    display.vvv(('EXEC    %s' % (local_cmd,)), host=self.jail)
    local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd]
    p = subprocess.Popen(local_cmd, shell=False, stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    return p
