Skip to content

Commit

Permalink
main: Delete the PID file upon exit
Browse files Browse the repository at this point in the history
  • Loading branch information
lhmouse committed Jan 11, 2024
1 parent bfd678c commit 1249b05
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion poseidon/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ ROCKET_NEVER_INLINE
void
do_write_pid_file()
{
cow_string pid_file_path;
static cow_string pid_file_path;
const auto conf = main_config.copy();

auto conf_value = conf.query("general", "pid_file_path");
Expand Down Expand Up @@ -531,6 +531,7 @@ do_write_pid_file()

// Downgrade the lock so the PID may be read by others.
::flock(pid_file, LOCK_SH);
::at_quick_exit(+[] { ::unlink(pid_file_path.c_str()); });
}

ROCKET_NEVER_INLINE
Expand Down

0 comments on commit 1249b05

Please sign in to comment.