--- gpm-1.20.1/src/gpm.c.deadsocket 2007-01-22 12:53:19.000000000 +0100 +++ gpm-1.20.1/src/gpm.c 2007-01-22 12:49:54.000000000 +0100 @@ -544,7 +544,7 @@ * we can safely use micelist */ close(micelist->dev.fd); - wait_text_console(); + wait_text_console(ctlfd); /* reopen, reinit (the function is only used if we have one mouse device) */ if ((micelist->dev.fd = open(micelist->device, O_RDWR)) < 0) gpm_report(GPM_PR_OOPS, GPM_MESS_OPEN, micelist->device); --- gpm-1.20.1/src/console.c.deadsocket 2007-01-22 00:50:25.000000000 +0100 +++ gpm-1.20.1/src/console.c 2007-01-22 13:08:18.000000000 +0100 @@ -101,7 +101,7 @@ } /*-------------------------------------------------------------------*/ -void wait_text_console(void) +void wait_text_console(int ctlfd) { struct timeval now; int usecs; @@ -113,7 +113,21 @@ usecs -= 1000000; usecs += 1000000 - now.tv_usec; - usleep(usecs); + now.tv_sec = 0; + now.tv_usec = usecs; + + /* check for pending connections and reject them */ + fd_set fds; + FD_ZERO(&fds); + FD_SET(ctlfd, &fds); + + select(ctlfd + 1, &fds, 0, 0, &now); + + if (FD_ISSET(ctlfd, &fds) && !is_text_console()) { + int fd = accept(ctlfd, 0, 0); + if (fd >= 0) + close(fd); + } } while (!is_text_console()); } --- gpm-1.20.1/src/headers/console.h.deadsocket 2007-01-22 12:53:27.000000000 +0100 +++ gpm-1.20.1/src/headers/console.h 2007-01-22 12:51:49.000000000 +0100 @@ -33,7 +33,7 @@ char *get_console_name(); char *compose_vc_name(int vc); int is_text_console(void); -void wait_text_console(void); +void wait_text_console(int ctlfd); void refresh_console_size(void); int is_console_owner(int vc, uid_t uid); int get_console_state(unsigned char *shift_state);