File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -364,14 +364,8 @@ func (c *Container) start(process *Process) (retErr error) {
364364func (c * Container ) Signal (s os.Signal ) error {
365365 c .m .Lock ()
366366 defer c .m .Unlock ()
367- status , err := c .currentStatus ()
368- if err != nil {
369- return err
370- }
371367 // To avoid a PID reuse attack, don't kill non-running container.
372- switch status {
373- case Running , Created , Paused :
374- default :
368+ if ! c .hasInit () {
375369 return ErrNotRunning
376370 }
377371
@@ -382,6 +376,7 @@ func (c *Container) Signal(s os.Signal) error {
382376 //
383377 // OTOH, if PID namespace is shared, we should kill all pids to avoid
384378 // leftover processes.
379+ var err error
385380 if s == unix .SIGKILL && ! c .config .Namespaces .IsPrivate (configs .NEWPID ) {
386381 err = signalAllProcesses (c .cgroupManager , unix .SIGKILL )
387382 } else {
@@ -390,11 +385,13 @@ func (c *Container) Signal(s os.Signal) error {
390385 if err != nil {
391386 return fmt .Errorf ("unable to signal init: %w" , err )
392387 }
393- if status == Paused && s == unix .SIGKILL {
388+ if s == unix .SIGKILL {
394389 // For cgroup v1, killing a process in a frozen cgroup
395390 // does nothing until it's thawed. Only thaw the cgroup
396391 // for SIGKILL.
397- _ = c .cgroupManager .Freeze (configs .Thawed )
392+ if paused , _ := c .isPaused (); paused {
393+ _ = c .cgroupManager .Freeze (configs .Thawed )
394+ }
398395 }
399396 return nil
400397}
You can’t perform that action at this time.
0 commit comments