Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
do not forward signals to docker CLI
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Oct 25, 2023
1 parent 8a400d0 commit 5a89eab
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions cli/mobycli/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"
"os"
"os/exec"
"os/signal"
"path/filepath"
"regexp"
"runtime"
Expand Down Expand Up @@ -135,35 +134,13 @@ func Exec(_ *cobra.Command) {
os.Exit(0)
}

// RunDocker runs a docker command, and forward signals to the shellout command (stops listening to signals when an event is sent to childExit)
// RunDocker runs a docker command
func RunDocker(childExit chan bool, args ...string) error {
cmd := exec.Command(comDockerCli(), args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

signals := make(chan os.Signal, 1)
signal.Notify(signals) // catch all signals
go func() {
for {
select {
case sig := <-signals:
if cmd.Process == nil {
continue // can happen if receiving signal before the process is actually started
}
// In go1.14+, the go runtime issues SIGURG as an interrupt to
// support preemptable system calls on Linux. Since we can't
// forward that along we'll check that here.
if isRuntimeSig(sig) {
continue
}
_ = cmd.Process.Signal(sig)
case <-childExit:
return
}
}
}()

return cmd.Run()
}

Expand Down

0 comments on commit 5a89eab

Please sign in to comment.