forked from lix-project/lix
Artemis Tosini
c03de0df62
Previously, the garbage collector found runtime roots on Darwin by
shelling out to `lsof -n -w -F n` then parsing the result.
However, this requires an lsof binary and can be extremely slow.
The official Apple lsof returns in a reasonable amount of time,
about 250ms in my tests, but the lsof packaged in nixpkgs is quite slow,
taking about 40 seconds to run the command.
Using libproc directly is about the same speed as Apple lsof,
and allows us to reënable several tests that were disabled on Darwin.
Change-Id: Ifa0adda7984e13c15535693baba835aae79a3577
17 lines
399 B
C++
17 lines
399 B
C++
#include <string>
|
|
#include <regex>
|
|
|
|
namespace nix::regex {
|
|
std::string quoteRegexChars(const std::string & raw)
|
|
{
|
|
static auto specialRegex = std::regex(R"([.^$\\*+?()\[\]{}|])");
|
|
return std::regex_replace(raw, specialRegex, R"(\$&)");
|
|
}
|
|
|
|
std::regex storePathRegex(const std::string & storeDir)
|
|
{
|
|
return std::regex(quoteRegexChars(storeDir) + R"(/[0-9a-z]+[0-9a-zA-Z\+\-\._\?=]*)");
|
|
}
|
|
|
|
}
|