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 b1eb351
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 77 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
30 changes: 0 additions & 30 deletions cli/mobycli/exec_unix.go

This file was deleted.

23 changes: 0 additions & 23 deletions cli/mobycli/exec_windows.go

This file was deleted.

0 comments on commit b1eb351

Please sign in to comment.