Tighten up the random seeding a little bit more. getpid() alone only

affect only lower bits of seed which would resulte in the same seed for
sequences of fast-started awk's resulting the same random sequence.

Submitted by:	ache
This commit is contained in:
David E. O'Brien 2001-11-03 02:14:10 +00:00
parent 5daeec1454
commit 9c23373c4e

View File

@ -1509,7 +1509,8 @@ do_srand(NODE *tree)
if (tree == NULL)
#ifdef __FreeBSD__
srandom((unsigned int) (save_seed = (long) time((time_t *) 0) ^ getpid()));
srandom((unsigned int) (save_seed = (long) time((time_t *) 0)
^ (getpid() << 16)));
#else
srandom((unsigned int) (save_seed = (long) time((time_t *) 0)));
#endif