IOLoop.add_handler won't accept certain file descriptors
Question: Python tornado's `IOLoop.add_handler(fd,handler,events)` says "the fd argument
may either be an integer file descriptor or a file-like object with a fileno()
method", and as of 4.0, it "Added the ability to pass file-like objects in
addition to raw file descriptors.

However, adding a file-like object (an actual file object) fails on Linux:

    
    
    >>> loop.add_handler (open ('XYZ'), handler, loop.READ)
    IOError: [Errno 1] Operation not permitted
    

Adding the file descriptor directly also fails, even though stdin, stdout,
stderr are accepted:

    
    
    >>> from tornado import ioloop
    >>> loop = ioloop.IOLoop.current ()
    >>> f = open ('XYZ')
    >>> f.fileno()
    4
    >>> def handler (fd, events): pass
    ...
    >>> loop.add_handler (0, handler, loop.READ)
    >>> loop.add_handler (1, handler, loop.READ)
    >>> loop.add_handler (2, handler, loop.READ)
    >>> loop.add_handler (4, handler, loop.READ)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 677, in add_handler
        self._impl.register(fd, events | self.ERROR)
    IOError: [Errno 1] Operation not permitted
    

[This
explanation](https://github.com/tornadoweb/tornado/issues/104#issuecomment-286142)
says that async IO doesn't work on regular files.

Is there something terribly different about the fd's 0, 1, 2, and the fd of
open('XYZ').fileno()? That would mean the documentation should confusingly
say: "Added the ability to pass file-like objects, but not actually file
objects."


Answer: FDs 0, 1, and 2 are usually (but not always!) pipes instead of regular files.
The IOLoop docs should probably say "socket-like objects" instead of "file-
like objects", or simply "objects with a fileno method".

The types of file descriptors supported by IOLoop varies by platform. On posix
platforms it supports sockets and pipes (and maybe some others like ttys), and
on windows it only supports sockets.

