diff options
author | grog <grog@FreeBSD.org> | 2005-07-23 01:46:50 +0000 |
---|---|---|
committer | grog <grog@FreeBSD.org> | 2005-07-23 01:46:50 +0000 |
commit | 6d42881fd88e32a58d93a3a6279e0c6dc970a631 (patch) | |
tree | cc355de20264bd1b846d5685d154f8cd7b7fb475 /games/fortune | |
parent | 35eb3b831279bd7f83f6cd0d573034b7fb572535 (diff) | |
download | FreeBSD-src-6d42881fd88e32a58d93a3a6279e0c6dc970a631.zip FreeBSD-src-6d42881fd88e32a58d93a3a6279e0c6dc970a631.tar.gz |
Use a random number to seed the random number generator. Goodby, Rush
Limbaugh.
This should have already worked properly if random(4) has been
initialized correctly, but it seems that this is frequently not the
case. Instead, use the microsecond part of the current time as the
seed.
Diffstat (limited to 'games/fortune')
-rw-r--r-- | games/fortune/fortune/fortune.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/games/fortune/fortune/fortune.c b/games/fortune/fortune/fortune.c index a7a8f45..60e6cbc 100644 --- a/games/fortune/fortune/fortune.c +++ b/games/fortune/fortune/fortune.c @@ -174,6 +174,7 @@ char *av[]; #ifdef OK_TO_WRITE_DISK int fd; #endif /* OK_TO_WRITE_DISK */ + struct timeval now; (void) setlocale(LC_ALL, ""); @@ -183,7 +184,8 @@ char *av[]; exit(find_matches() != 0); init_prob(); - srandomdev(); + gettimeofday(&now, NULL); + srandom(now.tv_usec); do { get_fort(); } while ((Short_only && fortlen() > SLEN) || |