-static void init_random_seed(void)
-{
- unsigned int seed;
- int fd, ret = para_open("/dev/urandom", O_RDONLY, 0);
-
- if (ret < 0)
- goto err;
- fd = ret;
- ret = read(fd, &seed, sizeof(seed));
- if (ret < 0) {
- ret = -ERRNO_TO_PARA_ERROR(errno);
- goto out;
- }
- if (ret != sizeof(seed)) {
- ret = -ERRNO_TO_PARA_ERROR(EIO);
- goto out;
- }
- srandom(seed);
- ret = 1;
-out:
- close(fd);
- if (ret >= 0)
- return;
-err:
- PARA_EMERG_LOG("can not seed pseudo random number generator: %s\n",
- para_strerror(-ret));
- exit(EXIT_FAILURE);
-}
-