Use seed_random() from randutils instead, and stop generating new seed when it does not have to happen Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- sys-utils/ipcmk.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/sys-utils/ipcmk.c b/sys-utils/ipcmk.c index a862ba1..9b943b7 100644 --- a/sys-utils/ipcmk.c +++ b/sys-utils/ipcmk.c @@ -34,30 +34,23 @@ #include "nls.h" #include "strutils.h" #include "closestream.h" - -static key_t create_key(void) -{ - struct timeval now; - gettimeofday(&now, NULL); - srandom(now.tv_usec); - return random(); -} +#include "randutils.h" static int create_shm(size_t size, int permission) { - key_t key = create_key(); + key_t key = random(); return shmget(key, size, permission | IPC_CREAT); } static int create_msg(int permission) { - key_t key = create_key(); + key_t key = random(); return msgget(key, permission | IPC_CREAT); } static int create_sem(int nsems, int permission) { - key_t key = create_key(); + key_t key = random(); return semget(key, nsems, permission | IPC_CREAT); } @@ -100,6 +93,7 @@ int main(int argc, char **argv) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); atexit(close_stdout); + seed_random(); while((opt = getopt_long(argc, argv, "hM:QS:p:Vh", longopts, NULL)) != -1) { switch(opt) { -- 1.8.1 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html