From 0225b8881d06773b92d9db2c7881f03ff0bdece7 Mon Sep 17 00:00:00 2001 From: tater Date: Fri, 24 Aug 2018 03:20:33 -0400 Subject: [PATCH] better random seed --- tdfiglet.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tdfiglet.c b/tdfiglet.c index 0155c02..ae7352d 100644 --- a/tdfiglet.c +++ b/tdfiglet.c @@ -24,12 +24,12 @@ #include #include #include -#include #include #include #include #include +#include #include #ifdef DEBUG @@ -153,6 +153,8 @@ main(int argc, char *argv[]) opt.random = false; char *fontfile = NULL; + struct timeval tv; + DIR *d; struct dirent *dir; SLIST_HEAD(, dirname_s) head = SLIST_HEAD_INITIALIZER(dirname_s); @@ -251,7 +253,9 @@ main(int argc, char *argv[]) } closedir(d); - srand(time(NULL)); + gettimeofday(&tv, NULL); + + srand(tv.tv_usec); r = dll ? rand() % dll : 0; dp = SLIST_FIRST(&head);