Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve has_realtime_kernel method #260

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/realtime_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
#include <sched.h>
#include <sys/capability.h>
#include <sys/mman.h>
#include <sys/utsname.h>

#include <unistd.h>
#endif

#include <cstring>
#include <fstream>
#include <iostream>

namespace realtime_tools
{
Expand All @@ -50,6 +52,18 @@ bool has_realtime_kernel()
if (realtime_file.is_open()) {
realtime_file >> has_realtime;
}
#if !defined(_WIN32)
if (!has_realtime) {
struct utsname kernel_info;
if (uname(&kernel_info) == -1) {
std::cerr << "Error: Could not get kernel information : " << std::strerror(errno)
<< std::endl;
return false;
}
const std::string kernel_version(kernel_info.version);
return kernel_version.find("PREEMPT_RT") != std::string::npos;
}
#endif
return has_realtime;
}

Expand Down
Loading