From f1008910161a7140aea35cd535216b766df0bbc0 Mon Sep 17 00:00:00 2001 From: obrien Date: Sat, 3 Nov 2001 02:14:10 +0000 Subject: 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(-) (limited to 'contrib/awk/builtin.c') diff --git a/contrib/awk/builtin.c b/contrib/awk/builtin.c index 240dca4..dcf3ac3 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 -- cgit v1.1