qemu 0.9.0 on Linux crashes with SIGSEGV after read() on a char device returns 0, which occurs if the char device is a fifo and the writer closes the file. In this case, fd_chr_read() and stdio_read() react by removing the IO handler and freeing it. Unfortunately main_loop_wait() is unprepared to deal with this (as the comment "XXX: better handling of removal" suggests) and attempts to access the freed handler. Even if main_loop_wait() were improved, it is not correct to remove the IO handler just because read() returns 0: if the char device is a fifo, a process may well reopen the fifo for writing at a later point. The attached patch is a naive fix; feedback is welcome. --Ed