Typical linux pid range is 2^15, which is not a lot as a entropy sourcee.
This change uses full 32 bits when random is initialized.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
#include <assert.h>
#include <fcntl.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include "mtr.h"
#include "mtr-curses.h"
optind = 0;
}
+static void init_rand(void)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, 0);
+ srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
+}
extern int main(int argc, char **argv)
{
atexit(close_stdout);
/* reset the random seed */
- srand (getpid());
+ init_rand();
display_detect(&ctl, &argc, &argv);
ctl.display_mode = DisplayModeDefault;