From 6b7b41f1ff036d97a9d82f31430c33fb58f45b6a Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 17 Mar 2017 18:20:52 +0100 Subject: Better srandomdev monkeypatch --- main.c | 9 +++++++-- 1 file 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 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 -- cgit v1.2.3-70-g09d2