aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/main.c b/main.c
index f73afe1..d9fafb4 100644
--- a/main.c
+++ b/main.c
@@ -119,9 +119,14 @@ static bool server_socket_callback(int fd){
}
#ifndef __APPLE__
-#include <sys/time.h>
void srandomdev(void){
- srandom(time(NULL));
+ FILE *f=fopen("/dev/urandom","r");
+ assert(f);
+ unsigned int seed;
+ size_t nread=fread(&seed,1,sizeof(seed),f);
+ assert(nread==sizeof(seed));
+ fclose(f);
+ srandom(seed);
}
#endif