Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael) Upstream-commit: ae423a036e6f884572491b1ff5ef8a626b1592aa Component: engine
25 lines
459 B
Go
25 lines
459 B
Go
package nsinit
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
)
|
|
|
|
type StateWriter interface {
|
|
WritePid(pid int) error
|
|
DeletePid() error
|
|
}
|
|
|
|
type DefaultStateWriter struct {
|
|
}
|
|
|
|
// writePidFile writes the namespaced processes pid to .nspid in the rootfs for the container
|
|
func (*DefaultStateWriter) WritePid(pid int) error {
|
|
return ioutil.WriteFile(".nspid", []byte(fmt.Sprint(pid)), 0655)
|
|
}
|
|
|
|
func (*DefaultStateWriter) DeletePid() error {
|
|
return os.Remove(".nspid")
|
|
}
|