fix infinite loop in text mode select() when built with gtk support this has been exposed by glib >= 2.31 (emacs #9754, mga #3259)