diff --git a/src/fetch/fetch.cpp b/src/fetch/fetch.cpp index 81ebcf4..8c77040 100644 --- a/src/fetch/fetch.cpp +++ b/src/fetch/fetch.cpp @@ -2,6 +2,7 @@ #include "kappa/paths.hpp" #include +#include #include #include #include @@ -29,7 +30,8 @@ static int exec_cmd(const std::vector& 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& 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; diff --git a/src/install/install.cpp b/src/install/install.cpp index 8ea6c6c..cd6921c 100644 --- a/src/install/install.cpp +++ b/src/install/install.cpp @@ -42,21 +42,26 @@ InstallResult install(const resolve::BuildStep& step, auto src = work_dir / "destdir"; if (fs::exists(src)) { for (auto& entry : fs::recursive_directory_iterator(src, ec)) { + if (ec) { break; } auto rel = fs::relative(entry.path(), src); auto target = dest / rel; if (entry.is_directory()) { fs::create_directories(target, ec); } else { fs::create_directories(target.parent_path(), ec); - fs::rename(entry.path(), target, ec); + if (!ec) { fs::rename(entry.path(), target, ec); } } + if (ec) { break; } } } auto entries = read_installed(); entries.push_back({step.name, step.resolved.original.version, hash, step.resolved.original.provides}); - write_installed(entries); + if (!write_installed(entries)) { + result.error = "failed to write installed DB"; + return result; + } std::vector hashes; for (auto& e : entries) { hashes.push_back(e.hash); }