mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 14:02:42 +01:00
nix-find-roots: Ignore SIGPIPEs
Prevent the daemon from crashing if the client stops receiving in the middle of the transmission. Also fix a potential off-by-a-few error
This commit is contained in:
parent
aa97c4f9f2
commit
ef644ec753
1 changed files with 11 additions and 7 deletions
|
|
@ -144,22 +144,26 @@ int main(int argc, char * * argv)
|
||||||
|
|
||||||
opts.log("accepted connection");
|
opts.log("accepted connection");
|
||||||
|
|
||||||
|
auto printToSocket = [&](std::string_view s) {
|
||||||
|
send(remoteSocket, s.data(), s.size(), MSG_NOSIGNAL);
|
||||||
|
};
|
||||||
|
|
||||||
auto traceResult = traceStaticRoots(opts, standardRoots);
|
auto traceResult = traceStaticRoots(opts, standardRoots);
|
||||||
auto runtimeRoots = getRuntimeRoots(opts);
|
auto runtimeRoots = getRuntimeRoots(opts);
|
||||||
traceResult.storeRoots.insert(runtimeRoots.begin(), runtimeRoots.end());
|
traceResult.storeRoots.insert(runtimeRoots.begin(), runtimeRoots.end());
|
||||||
for (auto & [rootInStore, externalRoots] : traceResult.storeRoots) {
|
for (auto & [rootInStore, externalRoots] : traceResult.storeRoots) {
|
||||||
for (auto & externalRoot : externalRoots) {
|
for (auto & externalRoot : externalRoots) {
|
||||||
send(remoteSocket, escape(rootInStore.string()).c_str(), rootInStore.string().size(), 0);
|
printToSocket(escape(rootInStore.string()));
|
||||||
send(remoteSocket, "\t", strlen("\t"), 0);
|
printToSocket("\t");
|
||||||
send(remoteSocket, escape(externalRoot.string()).c_str(), externalRoot.string().size(), 0);
|
printToSocket(escape(externalRoot.string()));
|
||||||
send(remoteSocket, "\n", strlen("\n"), 0);
|
printToSocket("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
send(remoteSocket, "\n", strlen("\n"), 0);
|
printToSocket("\n");
|
||||||
for (auto & deadLink : traceResult.deadLinks) {
|
for (auto & deadLink : traceResult.deadLinks) {
|
||||||
send(remoteSocket, escape(deadLink.string()).c_str(), deadLink.string().size(), 0);
|
printToSocket(escape(deadLink.string()));
|
||||||
send(remoteSocket, "\n", strlen("\n"), 0);
|
printToSocket("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
close(remoteSocket);
|
close(remoteSocket);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue