mirror of
https://github.com/0intro/conterm
synced 2024-11-25 23:19:36 +03:00
18 lines
306 B
C
18 lines
306 B
C
#include <u.h>
|
|
#include <libc.h>
|
|
|
|
ulong
|
|
truerand(void)
|
|
{
|
|
ulong x;
|
|
static int randfd = -1;
|
|
|
|
if(randfd < 0)
|
|
randfd = open("/dev/random", OREAD|OCEXEC);
|
|
if(randfd < 0)
|
|
sysfatal("can't open /dev/random");
|
|
if(read(randfd, &x, sizeof(x)) != sizeof(x))
|
|
sysfatal("can't read /dev/random");
|
|
return x;
|
|
}
|