# server: keep the shutdown snapshot final · lucenx/signaltty

[View on GitCafe](https://git.cafe/lucenx/signaltty/commit/9d6a1b82609051390cea453f06d7652e93bef62b)

Repository: [lucenx/signaltty](https://git.cafe/lucenx/signaltty)

Visibility: public

Requested revision: 9d6a1b82609051390cea453f06d7652e93bef62b

Requested commit: 9d6a1b82609051390cea453f06d7652e93bef62b

Commit: 9d6a1b82609051390cea453f06d7652e93bef62b

Tree: a8104cee66261d227100b513e5c810b059f73849

Author: Lucenx9

Committer: Simone

## Message

```
server: keep the shutdown snapshot final

The debounced flusher could rewrite snapshot.json after the shutdown save:
teardown changes (a native permission waiter clearing its decision on
disconnect, panes exiting during host shutdown) set persist_pending, and a
2 s tick before exit saved them. Restart then lost the pending decision
(the flaky native_permissions::shutdown_and_restart_cannot_restore_an_
answer_channel). A later SIGTERM after logind or server.shutdown did the
same through a second final save.

Ctx::save_final now writes the shutdown snapshot once, whichever trigger
comes first, under a write lock the flusher shares; the flusher checks the
stopping flag under that lock, so an in-flight flush cannot land after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

```

## Parents

- [fc530c76741b53730d72d6ad2584ecce4ef14983](https://git.cafe/lucenx/signaltty/commit/fc530c76741b53730d72d6ad2584ecce4ef14983?format=markdown)

[Source at this commit](https://git.cafe/lucenx/signaltty/tree/9d6a1b82609051390cea453f06d7652e93bef62b?format=markdown)
