From 7ab641b35062982f00d87c0066efe2aac57f960f Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Tue, 14 Apr 2026 19:50:27 +0200 Subject: [PATCH] 9p: call Close() on all sessions during shutdown Co-Authored-By: Claude Sonnet 4.6 --- internal/p9/server.go | 13 +++++++++++++ main.go | 1 + 2 files changed, 14 insertions(+) diff --git a/internal/p9/server.go b/internal/p9/server.go index f26954f..59a1f23 100644 --- a/internal/p9/server.go +++ b/internal/p9/server.go @@ -1377,6 +1377,19 @@ func (s *Server) createSession(args []string) error { return nil } +// Shutdown kills all active sessions, triggering Close() on each core. +func (s *Server) Shutdown() { + s.mu.Lock() + ids := make([]string, 0, len(s.sessions)) + for id := range s.sessions { + ids = append(ids, id) + } + s.mu.Unlock() + for _, id := range ids { + s.killSession(id) + } +} + func (s *Server) killSession(id string) { s.mu.Lock() sess := s.sessions[id] diff --git a/main.go b/main.go index 9a61ec8..d41f7d8 100644 --- a/main.go +++ b/main.go @@ -160,6 +160,7 @@ func runServer(sockPath, pidPath string) { <-sigChan fmt.Println("shutting down") + srv.Shutdown() if fuseCmd != nil { exec.Command("fusermount", "-u", mnt).Run() //nolint:errcheck fuseCmd.Wait() //nolint:errcheck