manage namespace directory lifecycle
This commit is contained in:
parent
a5cd5d36ed
commit
bf262cba16
|
|
@ -34,6 +34,10 @@ func main() {
|
||||||
fmt.Fprintln(os.Stderr, "no namespace")
|
fmt.Fprintln(os.Stderr, "no namespace")
|
||||||
os.Exit(1)
|
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)
|
sockPath := filepath.Join(ns, serviceName)
|
||||||
runServer(sockPath)
|
runServer(sockPath)
|
||||||
|
|
@ -149,5 +153,9 @@ func runServer(sockPath string) {
|
||||||
srv.Kill()
|
srv.Kill()
|
||||||
}
|
}
|
||||||
os.Remove(sockPath)
|
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()
|
sink.Flush()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue