fix: CWD restore, install error checks, fetch EINTR

- build.cpp: save/restore CWD on both success and failure paths
- install.cpp: check error_code after each filesystem op, abort on failure
- install.cpp: check write_installed() return value
- fetch.cpp: EINTR retry loop on both waitpid calls (exec_cmd + exec_capture)
This commit is contained in:
2026-07-30 05:31:59 -04:00
parent 6c993d2d17
commit c276465f3a
2 changed files with 12 additions and 4 deletions
+5 -2
View File
@@ -2,6 +2,7 @@
#include "kappa/paths.hpp"
#include <array>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <filesystem>
@@ -29,7 +30,8 @@ static int exec_cmd(const std::vector<std::string>& argv) {
}
if (pid < 0) { return -1; }
int status = 0;
waitpid(pid, &status, 0);
pid_t w;
do { w = waitpid(pid, &status, 0); } while (w == -1 && errno == EINTR);
return WIFEXITED(status) ? WEXITSTATUS(status) : -1;
}
@@ -61,7 +63,8 @@ static std::string exec_capture(const std::vector<std::string>& argv) {
result += buf.data();
}
close(pipefd[0]);
waitpid(pid, nullptr, 0);
pid_t w;
do { w = waitpid(pid, nullptr, 0); } while (w == -1 && errno == EINTR);
if (!result.empty() && result.back() == '\n') { result.pop_back(); }
return result;