summaryrefslogtreecommitdiff
path: root/src/librandom
diff options
context:
space:
mode:
Diffstat (limited to 'src/librandom')
-rw-r--r--src/librandom/random_init.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/librandom/random_init.c b/src/librandom/random_init.c
index 6a30db1..4c9fce7 100644
--- a/src/librandom/random_init.c
+++ b/src/librandom/random_init.c
@@ -34,16 +34,20 @@ int random_init ()
}
#else
-#ifdef SKALIBS_HASDEVURANDOM
-#include <skalibs/djbunix.h>
#include <skalibs/surf.h>
#include <skalibs/random.h>
#include "random-internal.h"
-int random_fd = -1 ;
SURFSchedule surf_here = SURFSCHEDULE_ZERO ;
+#ifdef SKALIBS_HASDEVURANDOM
+
+#include <errno.h>
+#include <skalibs/djbunix.h>
+
+int random_fd = -1 ;
+
int random_init ()
{
int fd ;
@@ -55,7 +59,13 @@ int random_init ()
{
fd = open_readb("/dev/urandom") ;
if (fd < 0) return 0 ;
- if (coe(fd) < 0) { fd_close(fd) ; return 0 ; }
+ if (coe(fd) < 0)
+ {
+ int e = errno ;
+ fd_close(fd) ;
+ errno = e ;
+ return 0 ;
+ }
random_fd = fd ;
}
return 1 ;
@@ -63,12 +73,6 @@ int random_init ()
#else /* default */
-#include <skalibs/surf.h>
-#include <skalibs/random.h>
-#include "random-internal.h"
-
-SURFSchedule surf_here = SURFSCHEDULE_ZERO ;
-
int random_init ()
{
char seed[160] ;