Abstract out diff implementations for importing
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
118ca3ae64
commit
1271ddcd61
5 changed files with 184 additions and 94 deletions
24
libcontainer/nsinit/state.go
Normal file
24
libcontainer/nsinit/state.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
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")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue