manage namespace directory lifecycle

This commit is contained in:
Ollie Agent 2026-08-18 13:31:52 +02:00
parent a5cd5d36ed
commit bf262cba16
1 changed files with 8 additions and 0 deletions

View File

@ -34,6 +34,10 @@ func main() {
fmt.Fprintln(os.Stderr, "no namespace")
os.Exit(1)
}
if err := os.MkdirAll(ns, 0700); err != nil {
fmt.Fprintf(os.Stderr, "create namespace: %v\n", err)
os.Exit(1)
}
sockPath := filepath.Join(ns, serviceName)
runServer(sockPath)
@ -149,5 +153,9 @@ func runServer(sockPath string) {
srv.Kill()
}
os.Remove(sockPath)
// Remove only an empty namespace directory. A plumber or another Plan 9
// service may own other entries here; os.Remove never removes non-empty
// directories, so those entries are left untouched.
_ = os.Remove(filepath.Dir(sockPath))
sink.Flush()
}