Read from the standard output of the forked program.

        :param int size: how many chars should be read

        :return: the length of the read content, as an `int`

def recv(self, size):
        """
        Read from the standard output of the forked program.

        :param int size: how many chars should be read

        :return: the length of the read content, as an `int`
        """
        try:
            start = datetime.now()
            while len(self.buffer) < size:
                if self.timeout is not None:
                    elapsed = (datetime.now() - start).microseconds
                    timeout = self.timeout * 1000 * 1000  # to microseconds
                    if elapsed >= timeout:
                        raise socket.timeout()
                r, w, x = select([self.process.stdout], [], [], 0.0)
                if r and r[0] == self.process.stdout:
                    b = os.read(self.process.stdout.fileno(), 1)
                    # Store in class-level buffer for persistence across
                    # timeouts; this makes us act more like a real socket
                    # (where timeouts don't actually drop data.)
                    self.buffer.append(b)
            result = ''.join(self.buffer)
            self.buffer = []
            return result
        except socket.timeout:
            raise  # socket.timeout is a subclass of IOError
        except IOError as e:
            raise ProxyCommandFailure(' '.join(self.cmd), e.strerror)