+int check_select_stdin(void)
+{
+ fd_set rdfs;
+ struct timeval timeout;
+ int ret;
+
+ FD_ZERO(&rdfs);
+ FD_SET(0, &rdfs);
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+
+ ret = select(1, &rdfs, NULL, NULL, &timeout);
+
+ if (ret < 0)
+ return 0; /* not selectable */
+
+ if (ret > 0 && getchar() == EOF)
+ return 0; /* EOF, eg. /dev/null */
+
+ return 1;
+}