Add the lttng::eventfd class
[lttng-tools.git] / src / common / random.cpp
index b282d67d0157386c26e8343709865bf66145d817..dfab9538c0cab31cd4f556547a9f4e7b261d7fe3 100644 (file)
@@ -5,6 +5,7 @@
  *
  */
 
+#include <common/error.hpp>
 #include <common/file-descriptor.hpp>
 #include <common/format.hpp>
 #include <common/hashtable/utils.hpp>
@@ -138,11 +139,11 @@ lttng::random::seed_t produce_random_seed_from_urandom()
        }() };
 
        lttng::random::seed_t seed;
-       const auto read_ret = lttng_read(urandom.fd(), &seed, sizeof(seed));
-       if (read_ret != sizeof(seed)) {
-               LTTNG_THROW_POSIX(fmt::format("Failed to read from `/dev/urandom`: size={}",
-                                             sizeof(seed)),
-                                 errno);
+       try {
+               urandom.read(&seed, sizeof(seed));
+       } catch (const std::exception& e) {
+               LTTNG_THROW_RANDOM_PRODUCTION_ERROR(fmt::format(
+                       "Failed to read from `/dev/urandom`: size={}: {}", sizeof(seed), e.what()));
        }
 
        return seed;
This page took 0.024362 seconds and 4 git commands to generate.