mirror of
https://github.com/Jguer/yay.git
synced 2024-11-07 01:27:21 +01:00
fix(cmd): propagate sigterm to spawned processes (#1927)
propagate sigterm to spawned processes
This commit is contained in:
parent
3ef4664d99
commit
61f1bdf291
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/Jguer/yay/v11/pkg/text"
|
"github.com/Jguer/yay/v11/pkg/text"
|
||||||
)
|
)
|
||||||
@ -18,12 +19,19 @@ type OSRunner struct{}
|
|||||||
|
|
||||||
func (r *OSRunner) Show(cmd *exec.Cmd) error {
|
func (r *OSRunner) Show(cmd *exec.Cmd) error {
|
||||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||||
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||||
|
Pdeathsig: syscall.SIGTERM,
|
||||||
|
}
|
||||||
text.Debugln("running", cmd.String())
|
text.Debugln("running", cmd.String())
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OSRunner) Capture(cmd *exec.Cmd) (stdout, stderr string, err error) {
|
func (r *OSRunner) Capture(cmd *exec.Cmd) (stdout, stderr string, err error) {
|
||||||
text.Debugln("capturing", cmd.String())
|
text.Debugln("capturing", cmd.String())
|
||||||
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||||
|
Pdeathsig: syscall.SIGTERM,
|
||||||
|
}
|
||||||
|
|
||||||
outbuf, err := cmd.Output()
|
outbuf, err := cmd.Output()
|
||||||
stdout = strings.TrimSpace(string(outbuf))
|
stdout = strings.TrimSpace(string(outbuf))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user