Skip to content

Commit

Permalink
Lock KillAll.
Browse files Browse the repository at this point in the history
Signed-off-by: Lantao Liu <lantaol@google.com>
  • Loading branch information
Random-Liu committed Nov 20, 2018
1 parent 943f15f commit 4cb837a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion linux/proc/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (p *Init) setExited(status int) {
}

func (p *Init) delete(context context.Context) error {
p.KillAll(context)
p.killAll(context)
p.wg.Wait()
err := p.runtime.Delete(context, p.id, nil)
// ignore errors if a runtime has already deleted the process
Expand Down Expand Up @@ -346,6 +346,12 @@ func (p *Init) kill(context context.Context, signal uint32, all bool) error {

// KillAll processes belonging to the init process
func (p *Init) KillAll(context context.Context) error {
p.mu.Lock()
defer p.mu.Unlock()
return p.killAll(context)
}

func (p *Init) killAll(context context.Context) error {
err := p.runtime.Kill(context, p.id, int(syscall.SIGKILL), &runc.KillOpts{
All: true,
})
Expand Down

0 comments on commit 4cb837a

Please sign in to comment.