summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-03-29 21:38:27 +0100
committerCarl Hetherington <cth@carlh.net>2025-03-29 21:38:27 +0100
commita9ac2b561da76ed44e54b48f7683630af00e0c07 (patch)
tree0dab85e966be9aeac92fe02da97af50001ebcda7 /src/lib
parent034d7176177043dc4cb4518ae6a946efe401b809 (diff)
Fix crash when Grok is enabled but no gpu_lister is available.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/grok/util.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/lib/grok/util.cc b/src/lib/grok/util.cc
index 3cbc55678..51b9c1037 100644
--- a/src/lib/grok/util.cc
+++ b/src/lib/grok/util.cc
@@ -21,6 +21,7 @@
#include "util.h"
#include "../config.h"
+#include "../dcpomatic_log.h"
#include <boost/process.hpp>
#include <future>
@@ -37,17 +38,23 @@ get_gpu_names()
auto binary = Config::instance()->grok().binary_location / "gpu_lister";
bp::ipstream stream;
- bp::child child(binary, bp::std_out > stream);
- string line;
- vector<string> gpu_names;
- while (child.running() && std::getline(stream, line) && !line.empty()) {
- gpu_names.push_back(line);
- }
+ try {
+ bp::child child(binary, bp::std_out > stream);
+
+ string line;
+ vector<string> gpu_names;
+ while (child.running() && std::getline(stream, line) && !line.empty()) {
+ gpu_names.push_back(line);
+ }
- child.wait();
+ child.wait();
- return gpu_names;
+ return gpu_names;
+ } catch (std::exception& e) {
+ LOG_ERROR("Could not fetch GPU names: %1", e.what());
+ return {};
+ }
}