3 * Copyright 2004, Clemens Fruhwirth <clemens@endorphin.org>
14 static int randomfd
= -1;
18 randomfd
= open("/dev/urandom", O_RDONLY
);
22 /* This method leaks a file descriptor that can be obtained by calling
24 int getRandom(char *buf
, size_t len
)
26 if(openRandom() == -1) {
32 r
= read(randomfd
,buf
,len
);
33 if (-1 == r
&& errno
!= -EINTR
) {
34 perror("read: "); return -EINVAL
;