def open_browser(self, url):
        """
        Open the given url using the default webbrowser. The preferred browser
        can specified with the $BROWSER environment variable. If not specified,
        python webbrowser will try to determine the default to use based on
        your system.

        For browsers requiring an X display, we open a new subprocess and
        redirect stdout/stderr to devnull. This is a workaround to stop
        BackgroundBrowsers (e.g. xdg-open, any BROWSER command ending in "&"),
        from spewing warning messages to the console. See
        http://bugs.python.org/issue22277 for a better description of the
        problem.

        For console browsers (e.g. w3m), RTV will suspend and display the
        browser window within the same terminal. This mode is triggered either
        when

        1. $BROWSER is set to a known console browser, or
        2. $DISPLAY is undefined, indicating that the terminal is running
           headless

        There may be other cases where console browsers are opened (xdg-open?)
        but are not detected here. These cases are still unhandled and will
        probably be broken if we incorrectly assume that self.display=True.
        """

        if self.display:
            with self.loader('Opening page in a new window'):

                def open_url_silent(url):
                    # This used to be done using subprocess.Popen().
                    # It was switched to multiprocessing.Process so that we
                    # can re-use the webbrowser instance that has been patched
                    # by RTV. It's also safer because it doesn't inject
                    # python code through the command line.

                    # Suppress stdout/stderr from the browser, see
                    # https://stackoverflow.com/questions/2323080. We can't
                    # depend on replacing sys.stdout & sys.stderr because
                    # webbrowser uses Popen().
                    stdout, stderr = os.dup(1), os.dup(2)
                    null = os.open(os.devnull, os.O_RDWR)
                    try:
                        os.dup2(null, 1)
                        os.dup2(null, 2)
                        if self.config['force_new_browser_window']:
                            webbrowser.open_new(url)
                        else:
                            webbrowser.open_new_tab(url)
                    finally:
                        try:
                            os.close(null)
                        except OSError:
                            pass
                        os.dup2(stdout, 1)
                        os.dup2(stderr, 2)

                p = Process(target=open_url_silent, args=(url,))
                p.start()
                # Give the browser 7 seconds to open a new tab. Because the
                # display is set, calling webbrowser should be non-blocking.
                # If it blocks or returns an error, something went wrong.
                try:
                    p.join(7)
                    if p.is_alive():
                        raise exceptions.BrowserError(
                            'Timeout waiting for browser to open')
                finally:
                    # This will be hit on the browser timeout, but also if the
                    # user presses the ESC key. We always want to kill the
                    # webbrowser process if it hasn't opened the tab and
                    # terminated by now.
                    try:
                        p.terminate()
                    except OSError:
                        pass
        else:
            with self.suspend():
                if self.config['force_new_browser_window']:
                    webbrowser.open_new(url)
                else:
                    webbrowser.open_new_tab(url)
Open the given url using the default webbrowser. The preferred browser
        can specified with the $BROWSER environment variable. If not specified,
        python webbrowser will try to determine the default to use based on
        your system.

        For browsers requiring an X display, we open a new subprocess and
        redirect stdout/stderr to devnull. This is a workaround to stop
        BackgroundBrowsers (e.g. xdg-open, any BROWSER command ending in "&"),
        from spewing warning messages to the console. See
        http://bugs.python.org/issue22277 for a better description of the
        problem.

        For console browsers (e.g. w3m), RTV will suspend and display the
        browser window within the same terminal. This mode is triggered either
        when

        1. $BROWSER is set to a known console browser, or
        2. $DISPLAY is undefined, indicating that the terminal is running
           headless

        There may be other cases where console browsers are opened (xdg-open?)
        but are not detected here. These cases are still unhandled and will
        probably be broken if we incorrectly assume that self.display=True.