From a54f50a65ae52164a7fd0b497142bbf7147c3713 Mon Sep 17 00:00:00 2001 From: Venelin Date: Wed, 1 Jan 2025 18:32:13 +0200 Subject: [PATCH] error check --- src/cppipe.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cppipe.cpp b/src/cppipe.cpp index 8412387..f3c28bf 100644 --- a/src/cppipe.cpp +++ b/src/cppipe.cpp @@ -216,6 +216,12 @@ MappedFile mapfile_for_writing(const fs::path& file) res.len = lseek(fd, 0, SEEK_END); res.data = (char*)mmap(nullptr, res.len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if(res.data == (void*)-1) + { + cerr << "ERROR: Couldn't map " << file << " for writing\n"; + exit(1); + } + close(fd); return res; }