Floobits / flootty

A collaborative terminal.
Apache License 2.0
175 stars 25 forks source link

OSError: [Errno 5] Input/output error on exit #16

Closed CristianCantoro closed 10 years ago

CristianCantoro commented 10 years ago

Hi,

I just created my accout @Floobits and I was testing the terminal sharing.

Here's what I got (output from terminal was broken, I am pasting as it was):

cristian@cristian-F5N:~$ flootty --create --url="https://floobits.com/r/CristianCantoro/Osmose/"
Connecting to floobits.com:3448.
Connected!
Successfully joined https://floobits.com/r/CristianCantoro/Osmose/
PS1="\[\e[32m\]CristianCantoro::Osmose::_\[\033[0m\] $PS1"
cristian@cristian-F5N:~$ PS1="\[\e[32m\]CristianCantoro::Osmose::_\[\033[0m\] $PS1"
CristianCantoro::Osmose::_ cristian@cristian-F5N:~$ exit
logout
Traceback (most recent call last):
                                    File "/usr/local/bin/flootty", line 9, in <module>
                                                                                          load_entry_point('Flootty==0.22', 'console_scripts', 'flootty')()
                                                                                                                                                             File "/usr/local/lib/python2.7/dist-packages/flootty/flootty.py", line 292, in main
                                                                                     f.select()
                                                                                                 File "/usr/local/lib/python2.7/dist-packages/flootty/flootty.py", line 410, in select
                           handler(fd)
                                        File "/usr/local/lib/python2.7/dist-packages/flootty/flootty.py", line 713, in stdout_write
                                                                                                                                       data = self.extra_data + os.read(fd, FD_READ_BYTES)
                           OSError: [Errno 5] Input/output error
                                                                ciao.
cristian@cristian-F5N:~$

I tried to test it with another Workspace (that I picked from Code Roulette), but I got the same issue. File "/usr/local/lib/python2.7/dist-packages/flootty/flootty.py", line 410, in select handler(fd) File "/usr/local/lib/python2.7/dist-packages/flootty/flootty.py", line 713, in stdout_write data = self.extra_data + os.read(fd, FD_READ_BYTES) OSError: [Errno 5] Input/output error ciao.

Finally I tried to create a clean virtualenv, with still no luck.

cristian@cristian-F5N:~$ mkvirtualenv floobits
New python executable in floobits/bin/python
Installing setuptools.............done.
Installing pip................done.
(floobits)cristian@cristian-F5N:~$ pip install flootty
Downloading/unpacking flootty
  Downloading Flootty-0.22.tar.gz
  Running setup.py egg_info for package flootty

Installing collected packages: flootty
  Running setup.py install for flootty

    Installing flootty script to /home/cristian/.virtualenvs/floobits/bin
Successfully installed flootty
Cleaning up...
(floobits)cristian@cristian-F5N:~$ flootty --create --url="https://floobits.com/r/CristianCantoro/Osmose/"
Connecting to floobits.com:3448.
Connected!
Successfully joined https://floobits.com/r/CristianCantoro/Osmose/
PS1="\[\e[32m\]CristianCantoro::Osmose::_\[\033[0m\] $PS1"
cristian@cristian-F5N:~$ PS1="\[\e[32m\]CristianCantoro::Osmose::_\[\033[0m\] $PS1"
CristianCantoro::Osmose::_ cristian@cristian-F5N:~$ exit
logout
Traceback (most recent call last):
                                    File "/home/cristian/.virtualenvs/floobits/bin/flootty", line 9, in <module>
                                                                                                                    load_entry_point('Flootty==0.22', 'console_scripts', 'flootty')()
                        File "/home/cristian/.virtualenvs/floobits/local/lib/python2.7/site-packages/flootty/flootty.py", line 292, in main
                                                                                                                                               f.select()
                                                                                                                                                           File "/home/cristian/.virtualenvs/floobits/local/lib/python2.7/site-packages/flootty/flootty.py", line 410, in select
                                                                                                                     handler(fd)
                                                                                                                                  File "/home/cristian/.virtualenvs/floobits/local/lib/python2.7/site-packages/flootty/flootty.py", line 713, in stdout_write
                                                                                                  data = self.extra_data + os.read(fd, FD_READ_BYTES)
                                                                                                                                                     OSError: [Errno 5] Input/output error
                           ciao.
(floobits)cristian@cristian-F5N:~$ 

My feeling is that it is trying to read from a file descriptor (the stdout attached to the child, if I am not wrong) while the child process is dead.

When I launch the program in fact I get cristian@cristian-F5N:~/Scrivania/floobit-test/flootty$ ps aux [...] cristian 11824 2.6 0.2 64580 10356 pts/3 S+ 03:23 0:00 /home/cristian/.virtualenvs/flootty-dev/bin/python /home/cristian/.virtualenvs/flootty-dev/bin/flootty --create myterm --url=https://floobits.com/r/CristianCantoro/Osmose/ cristian 11825 3.1 0.2 32648 7912 pts/4 Ss+ 03:23 0:00 /bin/bash --login

Calling pdb with some try ... except placed around the os.read(...) call mentioned above, I get:

cristian@cristian-F5N:~/Scrivania/floobit-test/flootty$ ps aux
[...]
cristian 11824  1.3  0.2  71608 11156 pts/3    S+   03:23   0:00 /home/cristian/.virtualenvs/flootty-dev/bin/python /home/cristian/.virtualenvs/flootty-dev/bin/flootty --create myterm --url=https://floobits.com/r/CristianCantoro/Osmose/
cristian 11825  2.2  0.0      0     0 ?        Zs   03:23   0:00 [bash] <defunct>

so the child process is defunct.

Another test is to see if I can open the file from the file descriptor, again setting some flags and calling pdb:

(flootty-dev)cristian@cristian-F5N:~/Scrivania/floobit-test/flootty-cc$ flootty --create myterm --url="https://floobits.com/r/CristianCantoro/Osmose/"
Connecting to floobits.com:3448.
Connected!
Successfully joined https://floobits.com/r/CristianCantoro/Osmose/
> /home/cristian/.virtualenvs/flootty-dev/local/lib/python2.7/site-packages/Flootty-0.22-py2.7.egg/flootty/flootty.py(720)stdout_write()
    -> self.PDBFLAG = False
[the terminal output is broken so this was not really easy...]
(Pdb) fd
(Pdb) myfile = os.fdopen(fd)
(Pdb) <open file '<fdopen>', mode 'r' at 0x7f35ce4af9c0>
(Pdb) fcntl.fcntl(myfile,0)
(Pdb) 6

And after closing the file I get instead:

CristianCantoro::Osmose::myterm cristian@cristian-F5N:~/Scrivania/floobit-test/flootty-cc$ exit
logout
> /home/cristian/.virtualenvs/flootty-dev/local/lib/python2.7/site-packages/Flootty-0.22-py2.7.egg/flootty/flootty.py(728)stdout_write()    
    -> self.extra_data = b''
(Pdb) fd
(Pdb) 5
(Pdb) myfile = os.fdopen(fd)
(Pdb) *** OSError: [Errno 9] Bad file descriptor

I tried to fix this, I am creating a pull request. (and here it is: https://github.com/Floobits/flootty/pull/17)

p.s.: floobits is awesome ;-)

kans commented 10 years ago

fixed in the pr