def nonblocking_input(self):
        '''Context manager to set the :class:`Terminal`'s input file to read in
        a non-blocking way.

        Normally, reading from :attr:`sys.stdin` blocks, which is bad if we
        want an interactive application that can also update information on the
        screen without any input from the user! Therefore, we need to make
        :meth:`Terminal.infile.read` a non-blocking operation, which just
        returns nothing if we have no input.

        :meth:`Root.run` uses this context manager for you to make your
        application work in the correct way.
        '''
        # FIXME: do we handle restoring this during SIGTSTP?
        if hasattr(self.infile, 'fileno'):
            # Use fcntl to set stdin to non-blocking. WARNING - this is not
            # particularly portable!
            flags = fcntl.fcntl(self.infile, fcntl.F_GETFL)
            fcntl.fcntl(self.infile, fcntl.F_SETFL, flags | os.O_NONBLOCK)
            try:
                yield
            finally:
                fcntl.fcntl(self.infile, fcntl.F_SETFL, flags)
        else:
            yield