On Mon, Aug 11, 2014 at 05:04:20PM +0100, Gary Benson wrote: > + case 's': > + seed = atoi (optarg); > + break; > + > + case 't': > + timeout = atoi (optarg); > + break; > + > + case 'm': > + maxcount = atoi (optarg); > + break; > + } > + } > + while (optchr != -1); > + > + if (seed == -1) > + seed = time (NULL); > + srand (seed); > + printf ("%s: seed = %d\n", program_name, seed);
That will still make it non-reproduceable if time returns -1 (well, as you cast time_t to int, that can be e.g. on 64-bit arches any time which has 0xffffffff in the low 32 bits). So perhaps do if (seed == -1) { seed = time (NULL); if (seed == -1) seed = 0; } or something similar? > + if (timeout != -1) > + { > + signal (SIGALRM, alarm_handler); > + alarm (timeout); > + } Not sure how much portable signal/alarm is. So probably should be guarded by the existence of signal.h, SIGALRM being defined etc. Jakub