mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Detect lsof
Also, don't use lsof on Linux since it's not needed. Fixes #1328.
This commit is contained in:
parent
efa4bdbfcd
commit
749696e71c
4 changed files with 12 additions and 4 deletions
|
@ -426,22 +426,27 @@ void LocalStore::findRuntimeRoots(PathSet & roots)
|
|||
throw SysError("iterating /proc");
|
||||
}
|
||||
|
||||
#if !defined(__linux__)
|
||||
try {
|
||||
auto lsofRegex = std::regex(R"(^n(/.*)$)");
|
||||
printError("RUN LSOF %s", LSOF);
|
||||
std::regex lsofRegex(R"(^n(/.*)$)");
|
||||
auto lsofLines =
|
||||
tokenizeString<std::vector<string>>(runProgram("lsof", true, { "-n", "-w", "-F", "n" }), "\n");
|
||||
tokenizeString<std::vector<string>>(runProgram(LSOF, true, { "-n", "-w", "-F", "n" }), "\n");
|
||||
for (const auto & line : lsofLines) {
|
||||
auto match = std::smatch{};
|
||||
std::smatch match;
|
||||
if (std::regex_match(line, match, lsofRegex))
|
||||
paths.emplace(match[1]);
|
||||
}
|
||||
} catch (ExecError & e) {
|
||||
/* lsof not installed, lsof failed */
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
readFileRoots("/proc/sys/kernel/modprobe", paths);
|
||||
readFileRoots("/proc/sys/kernel/fbsplash", paths);
|
||||
readFileRoots("/proc/sys/kernel/poweroff_cmd", paths);
|
||||
#endif
|
||||
|
||||
for (auto & i : paths)
|
||||
if (isInStore(i)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue