diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-03-17 18:20:52 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-03-17 18:20:52 +0100 |
commit | 6b7b41f1ff036d97a9d82f31430c33fb58f45b6a (patch) | |
tree | 9c15a19d5be246329187a4f1bb34c00416b1739c | |
parent | d9d996c5caf7d4332f41f06aa44806fe9d33fe96 (diff) |
Better srandomdev monkeypatch
-rw-r--r-- | main.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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 |