diff --git a/src/lib9/truerand.c b/src/lib9/truerand.c new file mode 100644 index 00000000..aaf10f0a --- /dev/null +++ b/src/lib9/truerand.c @@ -0,0 +1,21 @@ +#include +#include + +ulong +truerand(void) +{ + int i, n; + uchar buf[sizeof(ulong)]; + static int randfd = -1; + + if(randfd < 0){ + randfd = open("/dev/random", OREAD); + fcntl(randfd, F_SETFD, FD_CLOEXEC); + } + if(randfd < 0) + sysfatal("can't open /dev/random: %r"); + for(i=0; i