From 9c23373c4ea67b3bb761155920cf18ddeed3cada Mon Sep 17 00:00:00 2001 From: "David E. O'Brien" Date: Sat, 3 Nov 2001 02:14:10 +0000 Subject: [PATCH] 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 --- contrib/awk/builtin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/awk/builtin.c b/contrib/awk/builtin.c index 240dca4be56e..dcf3ac3e4d24 100644 --- a/contrib/awk/builtin.c +++ b/contrib/awk/builtin.c @@ -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