jot random number generator broken in batch jobs
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
athena-jot (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
jot -r generates same random numbers within one second time so it's unusable in batch jobs like shell scripts.
There is code for initializing "random" seed:
s = (randomize ? time(0) : STEP_DEF);
/*... snip ....*/
srand((int) s);
Here is an example of this behavior:
rbtz@rbtz-
1309455778
9981995
rbtz@rbtz-
1309455779
2355993
rbtz@rbtz-
1309455779
2355993
rbtz@rbtz-
1309455779
2355993
rbtz@rbtz-
1309455780
3745306
rbtz@rbtz-
1309455780
3745306
As fast fix pid can be added to seed
srandom((int) s ^ (getpid()<<4));
As good fix arc4random or similar mechanism can be used.
Provided patch solving this issue.