Skip to content

Commit

Permalink
fix proc_mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
t-horikawa committed Jan 16, 2024
1 parent 0bb4d5b commit 43af8fd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/tateyama/process/proc_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class proc_mutex {
}
}
~proc_mutex() {
close(fd_);
if (fd_ != not_opened) {
close(fd_);
}
if (create_file_) {
unlink(lock_file_.generic_string().c_str());
}
Expand Down Expand Up @@ -118,8 +120,9 @@ class proc_mutex {

private:
std::filesystem::path lock_file_;
int fd_{};
int fd_{not_opened};
const bool create_file_;
static constexpr int not_opened = -1;

[[nodiscard]] bool contents(std::string& str, bool do_check = true) {
if (do_check && check() != lock_state::locked) {
Expand Down

0 comments on commit 43af8fd

Please sign in to comment.