Accomodate OpenBSD with /dev/srandom
This commit is contained in:
parent
bce0902a07
commit
fea3228fec
1 changed files with 4 additions and 2 deletions
|
|
@ -10,10 +10,12 @@ truerand(void)
|
|||
|
||||
if(randfd < 0){
|
||||
randfd = open("/dev/random", OREAD);
|
||||
fcntl(randfd, F_SETFD, FD_CLOEXEC);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue