Pausing a tetris game currently causes a segfault due to a a null pointer dereference.
Fix this by checking that s is non-NULL before accessing its members. A number of comments and an error message still refer to select() instead of poll(). Correct this as well. Index: input.c =================================================================== RCS file: /cvs/src/games/tetris/input.c,v retrieving revision 1.13 diff -u -p -r1.13 input.c --- input.c 3 Nov 2014 22:14:54 -0000 1.13 +++ input.c 5 Nov 2014 19:39:30 -0000 @@ -64,12 +64,12 @@ } /* - * Do a `read wait': select for reading from stdin, with timeout *tvp. + * Do a `read wait': poll for reading from stdin, with timeout *tvp. * On return, modify *tvp to reflect the amount of time spent waiting. * It will be positive only if input appeared before the time ran out; * otherwise it will be zero or perhaps negative. * - * If tvp is nil, wait forever, but return if select is interrupted. + * If tvp is nil, wait forever, but return if poll is interrupted. * * Return 0 => no input, 1 => can read() from stdin */ @@ -90,14 +90,15 @@ rwait(struct timeval *tvp) again: pfd[0].fd = STDIN_FILENO; pfd[0].events = POLLIN; - switch (poll(pfd, 1, s->tv_sec * 1000 + s->tv_usec / 1000)) { + switch (poll(pfd, 1, s ? s->tv_sec * 1000 + s->tv_usec / 1000 : + INFTIM)) { case -1: if (tvp == 0) return (-1); if (errno == EINTR) goto again; - stop("select failed, help"); + stop("poll failed, help"); /* NOTREACHED */ case 0: /* timed out */ @@ -115,7 +116,7 @@ again: } /* - * `sleep' for the current turn time (using select). + * `sleep' for the current turn time (using poll). * Eat any input that might be available. */ void