ssize_t len;
size_t n = 0;
int ret = 0;
+#ifdef __linux__
+ fd_set infd;
+ struct timeval tv = { 0, 0 };
+#endif
+
+#ifdef __linux__
+ /* --- Don't take from `/dev/urandom' if `/dev/random' would block --- */
+
+ if ((fd = open("/dev/random", O_RDONLY | O_NONBLOCK)) < 0) goto done;
+ FD_ZERO(&infd);
+ FD_SET(fd, &infd);
+ if (select(fd + 1, &infd, 0, 0, &tv) < 0 || !FD_ISSET(fd, &infd))
+ goto done;
+ close(fd); fd = -1;
+#endif
/* --- Be nice to other clients of the random device --- *
*