#include #include unsigned long rng_get_seed(void) { FILE *fp=NULL; unsigned long seed; size_t nread; const size_t one=1; const char fname[]="/dev/random"; fp = fopen(fname,"r"); if(fp==NULL) { fprintf(stderr,"ERROR: Couldn't open `%s' ..exiting\n",fname); exit(EXIT_FAILURE); } nread = fread(&seed,sizeof(seed),one,fp); fclose(fp); if(nread != 1){ fprintf(stderr,"ERROR: Couldn't read %zu bytes from the `%s'..exiting\n",sizeof(seed),fname); exit(EXIT_FAILURE); } return seed; }