mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 07:46:21 +02:00
libstore/gc.cc: ignore ESRCH when reading /proc
If a process disappears between the time /proc/[pid]/maps is opened and the time it is read, the read() syscall will return ESRCH. This should be ignored.
This commit is contained in:
parent
de71335e4d
commit
8c567afe35
1 changed files with 13 additions and 10 deletions
|
@ -425,10 +425,14 @@ PathSet LocalStore::findRuntimeRoots()
|
|||
readProcLink((format("%1%/%2%") % fdStr % fd_ent->d_name).str(), paths);
|
||||
}
|
||||
}
|
||||
if (errno)
|
||||
if (errno) {
|
||||
if (errno == ESRCH)
|
||||
continue;
|
||||
throw SysError(format("iterating /proc/%1%/fd") % ent->d_name);
|
||||
}
|
||||
fdDir.reset();
|
||||
|
||||
try {
|
||||
auto mapLines =
|
||||
tokenizeString<std::vector<string>>(readFile((format("/proc/%1%/maps") % ent->d_name).str(), true), "\n");
|
||||
for (const auto& line : mapLines) {
|
||||
|
@ -437,13 +441,12 @@ PathSet LocalStore::findRuntimeRoots()
|
|||
paths.emplace(match[1]);
|
||||
}
|
||||
|
||||
try {
|
||||
auto envString = readFile((format("/proc/%1%/environ") % ent->d_name).str(), true);
|
||||
auto env_end = std::sregex_iterator{};
|
||||
for (auto i = std::sregex_iterator{envString.begin(), envString.end(), storePathRegex}; i != env_end; ++i)
|
||||
paths.emplace(i->str());
|
||||
} catch (SysError & e) {
|
||||
if (errno == ENOENT || errno == EACCES)
|
||||
if (errno == ENOENT || errno == EACCES || errno == ESRCH)
|
||||
continue;
|
||||
throw;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue