Hi, On 12/28/22 22:25, Jonny Grant wrote: > That example program looks good, thank you for taking the time to prepare that patch. > Jonny Thanks! This is my v2: It doesn't recommend libbsd's arc4random(). It also shows that arc4random is just a way to get a random seed, and prints it, but then it's as "bad" as any other run of srand(3) + rand(3). Cheers, Alex diff --git a/man3/rand.3 b/man3/rand.3 index 572471749..08ad0a822 100644 --- a/man3/rand.3 +++ b/man3/rand.3 @@ -190,6 +190,9 @@ .SH EXAMPLES pseudo-random sequence produced by .BR rand () when given a particular seed. +When the seed is +.IR \-1 , +the program uses a random seed. .PP .in +4n .\" SRC BEGIN (rand.c) @@ -211,7 +214,13 @@ .SH EXAMPLES seed = atoi(argv[1]); nloops = atoi(argv[2]); + if (seed == -1) { + seed = arc4random(); + printf("seed: %u\en", seed); + } + srand(seed); + for (unsigned int j = 0; j < nloops; j++) { r = rand(); printf("%d\en", r); --