Skip to content

Commit

Permalink
fix(cmd): propagate sigterm to spawned processes (#1927)
Browse files Browse the repository at this point in the history
propagate sigterm to spawned processes
  • Loading branch information
Jguer authored Feb 21, 2023
1 parent 3ef4664 commit 61f1bdf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/settings/exe/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"strings"
"syscall"

"github.com/Jguer/yay/v11/pkg/text"
)
Expand All @@ -18,12 +19,19 @@ type OSRunner struct{}

func (r *OSRunner) Show(cmd *exec.Cmd) error {
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGTERM,
}
text.Debugln("running", cmd.String())
return cmd.Run()
}

func (r *OSRunner) Capture(cmd *exec.Cmd) (stdout, stderr string, err error) {
text.Debugln("capturing", cmd.String())
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGTERM,
}

outbuf, err := cmd.Output()
stdout = strings.TrimSpace(string(outbuf))

Expand Down

0 comments on commit 61f1bdf

Please sign in to comment.