Remove sandbox instance when oz-init exits

networking
brl 10 years ago
parent 3e42e0d31f
commit 14581f8612

@ -52,11 +52,14 @@ func initialize() *daemonState {
func (d *daemonState) handleChildExit(pid int, wstatus syscall.WaitStatus) { func (d *daemonState) handleChildExit(pid int, wstatus syscall.WaitStatus) {
d.Debug("Child process pid=%d exited with status %d", pid, wstatus.ExitStatus()) d.Debug("Child process pid=%d exited with status %d", pid, wstatus.ExitStatus())
for _,sbox := range d.sandboxes { for _,sbox := range d.sandboxes {
if sbox.init.Process.Pid == pid { if sbox.init.Process.Pid == pid {
sbox.fs.Cleanup() sbox.remove()
return
} }
} }
d.Notice("No sandbox found with oz-init pid = %d", pid)
} }
func runServer(args ...interface{}) error { func runServer(args ...interface{}) error {

@ -84,6 +84,18 @@ func (d *daemonState) launch(p *oz.Profile) (*Sandbox, error) {
return sbox,nil return sbox,nil
} }
func (sbox *Sandbox) remove() {
sboxes := []*Sandbox{}
for _,sb := range sbox.daemon.sandboxes {
if sb == sbox {
sb.fs.Cleanup()
} else {
sboxes = append(sboxes, sb)
}
}
sbox.daemon.sandboxes = sboxes
}
func (sbox *Sandbox) logMessages() { func (sbox *Sandbox) logMessages() {
scanner := bufio.NewScanner(sbox.stderr) scanner := bufio.NewScanner(sbox.stderr)
for scanner.Scan() { for scanner.Scan() {

Loading…
Cancel
Save