From: Jeroen van der Heijden Date: Wed, 13 Apr 2022 11:14:41 +0000 (+0200) Subject: Catch read() err X-Git-Tag: archive/raspbian/2.0.48-1+rpi1^2~6^2^2~10 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0fe948f32a99c520614469905fde0befd30460ae;p=siridb-server.git Catch read() err --- diff --git a/main.c b/main.c index 80f19075..cd69a00f 100644 --- a/main.c +++ b/main.c @@ -32,20 +32,6 @@ int main(int argc, char * argv[]) /* set local to LC_ALL and C to force a period over comma for float */ (void) setlocale(LC_ALL, "C"); - /* initialize random */ - seed = 0; - fd = open("/dev/urandom", O_RDONLY); - - if ( fd == -1 ) { - log_info("Could not open /dev/urandom"); - return 1; - } - - read(fd, &seed, sizeof(int)); - close(fd); - - srand(seed); - /* set threadpool size to 8 (default=4) */ putenv("UV_THREADPOOL_SIZE=8"); @@ -59,6 +45,18 @@ int main(int argc, char * argv[]) /* setup logger, this must be done before logging the first line */ siri_setup_logger(); + /* initialize random */ + seed = 0; + fd = open("/dev/urandom", O_RDONLY); + if (fd == -1 || read(fd, &seed, sizeof(int)) == -1) + { + log_error("Could not open /dev/urandom"); + return 1; + } + + (void) close(fd); + srand(seed); + /* initialize points dictionary */ siridb_points_init();