diff --git a/src/files.cpp b/src/files.cpp index 7f48893..80b0151 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -229,8 +229,16 @@ bool create_lockfile() ofstream file; file.exceptions(std::ofstream::failbit | std::ofstream::badbit); - file.open(lockfile); - file << getpid(); + try + { + file.open(lockfile); + file << getpid(); + } + catch (const std::ofstream::failure &e) + { + const auto msg{string("Could not write lockfile: ") += e.what()}; + throw std::runtime_error{msg.c_str()}; + } return true; }