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