MCPcopy Create free account
hub / github.com/docker/cli / forceExitAfter3TerminationSignals

Function forceExitAfter3TerminationSignals

cmd/docker/docker.go:447–463  ·  view source on GitHub ↗

forceExitAfter3TerminationSignals waits for the first termination signal to be caught and the context to be marked as done, then registers a new signal handler for subsequent signals. It forces the process to exit after 3 SIGTERM/SIGINT signals.

(ctx context.Context, streams command.Streams)

Source from the content-addressed store, hash-verified

445// signal handler for subsequent signals. It forces the process to exit
446// after 3 SIGTERM/SIGINT signals.
447func forceExitAfter3TerminationSignals(ctx context.Context, streams command.Streams) {
448 // wait for the first signal to be caught and the context to be marked as done
449 <-ctx.Done()
450 // register a new signal handler for subsequent signals
451 sig := make(chan os.Signal, 2)
452 signal.Notify(sig, platformsignals.TerminationSignals...)
453
454 // once we have received a total of 3 signals we force exit the cli
455 for range 2 {
456 <-sig
457 }
458 _, _ = fmt.Fprint(streams.Err(), "\ngot 3 SIGTERM/SIGINTs, forcefully exiting\n")
459
460 // Restore terminal in case it was in raw mode.
461 restoreTerminal(streams)
462 os.Exit(1)
463}
464
465// restoreTerminal restores the terminal if it was in raw mode; this prevents
466// local echo from being disabled for the current terminal after forceful

Callers 1

runDockerFunction · 0.85

Calls 2

restoreTerminalFunction · 0.70
ErrMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…