commit fea3228fece71cef7e9930065cc6c8490613f935
parent bce0902a077bb927023465a6f0b62d37c43ae9b8
Author: rsc <devnull@localhost>
Date: Thu, 11 Aug 2005 03:20:57 +0000
Accomodate OpenBSD with /dev/srandom
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/lib9/truerand.c b/src/lib9/truerand.c
@@ -10,10 +10,12 @@ truerand(void)
if(randfd < 0){
randfd = open("/dev/random", OREAD);
+ if(randfd < 0)
+ randfd = open("/dev/srandom", OREAD); /* OpenBSD */
+ if(randfd < 0)
+ sysfatal("can't open /dev/random: %r");
fcntl(randfd, F_SETFD, FD_CLOEXEC);
}
- if(randfd < 0)
- sysfatal("can't open /dev/random: %r");
for(i=0; i<sizeof(buf); i += n)
if((n = readn(randfd, buf+i, sizeof(buf)-i)) < 0)
sysfatal("can't read /dev/random: %r");