Stefan Monnier writes: > > Huh! Indeed! The condition "gpm < 0" is encountered all the time, Yes, EWOULDBLOCK. gpm==0 is eof from the server. gpm==-1 is a protocol error as well as EWOULDBLOCK, but it might be ok to quietly ignore that. It probably only happens if libgpm.so and the running daemon are incompatible versions. I get some joy from the change below. I think the add/delete descriptor calls might be right, but I'm not terrifically confident. One thing I notice not done is to turn off the gpm-mouse-mode minor mode variable when stopping like this. Maybe that's good enough. It won't stop normally, so as long as emacs doesn't abort that could be enough. (You can M-x gpm-mouse-mode twice to toggle it back on.)