Files
thc1006 fcde1028b9 fix(store): write the boot session marker atomically
os.WriteFile truncates the boot session marker in place before rewriting it. A
concurrent staleBootSession can read it empty in that window, decide it does not
match the current boot ID, and have WritePIDFile delete PID files that belong to
the running boot.

Write the marker through a new fsutil.WriteFileAtomic helper that writes a
temporary file in the same directory and renames it into place, so a reader
always sees a complete marker. writePIDFileAtomically now uses the same helper
instead of its own temp-and-rename.

The temp name is a short fixed prefix, not the destination basename, so a long
custom PID path cannot overflow the filesystem name limit. os.CreateTemp creates
it 0600, so the marker and PID files are now 0600 masked by the umask rather than
the previous 0644, and a rewrite no longer preserves an existing file's mode.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
2026-10-19 12:01:59 +08:00
..