diff options
author | rsc <devnull@localhost> | 2005-08-11 03:20:57 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-08-11 03:20:57 +0000 |
commit | fea3228fece71cef7e9930065cc6c8490613f935 (patch) | |
tree | 426edce67d788ed9415c17a1a57153ed8dbd4331 /src/lib9 | |
parent | bce0902a077bb927023465a6f0b62d37c43ae9b8 (diff) | |
download | plan9port-fea3228fece71cef7e9930065cc6c8490613f935.tar.gz plan9port-fea3228fece71cef7e9930065cc6c8490613f935.tar.bz2 plan9port-fea3228fece71cef7e9930065cc6c8490613f935.zip |
Accomodate OpenBSD with /dev/srandom
Diffstat (limited to 'src/lib9')
-rw-r--r-- | src/lib9/truerand.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib9/truerand.c b/src/lib9/truerand.c index aaf10f0a..04462e27 100644 --- 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"); |