2016-07-27 18:17:44 +00:00
|
|
|
// +build !windows
|
|
|
|
|
2016-12-09 09:17:53 +00:00
|
|
|
package daemon
|
2016-07-27 18:17:44 +00:00
|
|
|
|
2016-08-23 23:50:15 +00:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"github.com/go-check/check"
|
|
|
|
)
|
|
|
|
|
|
|
|
func cleanupExecRoot(c *check.C, execRoot string) {
|
|
|
|
// Cleanup network namespaces in the exec root of this
|
|
|
|
// daemon because this exec root is specific to this
|
|
|
|
// daemon instance and has no chance of getting
|
|
|
|
// cleaned up when a new daemon is instantiated with a
|
|
|
|
// new exec root.
|
|
|
|
netnsPath := filepath.Join(execRoot, "netns")
|
|
|
|
filepath.Walk(netnsPath, func(path string, info os.FileInfo, err error) error {
|
|
|
|
if err := syscall.Unmount(path, syscall.MNT_FORCE); err != nil {
|
|
|
|
c.Logf("unmount of %s failed: %v", path, err)
|
|
|
|
}
|
|
|
|
os.Remove(path)
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
2016-07-27 18:17:44 +00:00
|
|
|
|
2016-12-09 09:17:53 +00:00
|
|
|
// SignalDaemonDump sends a signal to the daemon to write a dump file
|
|
|
|
func SignalDaemonDump(pid int) {
|
2016-07-27 18:17:44 +00:00
|
|
|
syscall.Kill(pid, syscall.SIGQUIT)
|
|
|
|
}
|
2016-07-28 15:58:06 +00:00
|
|
|
|
|
|
|
func signalDaemonReload(pid int) error {
|
|
|
|
return syscall.Kill(pid, syscall.SIGHUP)
|
|
|
|
}
|