mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-31 10:09:39 +09:00
fix(process): reap entire process group on cmd.Cancel (#39143)
Signed-off-by: Royce Remer <royceremer@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
co-authored by
wxiaoguang
parent
88974d2db9
commit
eea03676d3
+3
-5
@@ -9,7 +9,6 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -294,7 +293,7 @@ func runServ(ctx context.Context, c *cli.Command) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var command *exec.Cmd
|
||||
var command *process.Cmd
|
||||
gitBinPath := filepath.Dir(gitcmd.GitExecutable) // e.g. /usr/bin
|
||||
gitBinVerb := filepath.Join(gitBinPath, verb) // e.g. /usr/bin/git-upload-pack
|
||||
if _, err := os.Stat(gitBinVerb); err != nil {
|
||||
@@ -303,15 +302,14 @@ func runServ(ctx context.Context, c *cli.Command) error {
|
||||
verbFields := strings.SplitN(verb, "-", 2)
|
||||
if len(verbFields) == 2 {
|
||||
// use git binary with the sub-command part: "C:\...\bin\git.exe", "upload-pack", ...
|
||||
command = exec.CommandContext(ctx, gitcmd.GitExecutable, verbFields[1], results.RepoStoragePath)
|
||||
command = process.CommandContext(ctx, gitcmd.GitExecutable, verbFields[1], results.RepoStoragePath)
|
||||
}
|
||||
}
|
||||
if command == nil {
|
||||
// by default, use the verb (it has been checked above by allowedCommands)
|
||||
command = exec.CommandContext(ctx, gitBinVerb, results.RepoStoragePath)
|
||||
command = process.CommandContext(ctx, gitBinVerb, results.RepoStoragePath)
|
||||
}
|
||||
|
||||
process.SetSysProcAttribute(command)
|
||||
command.Dir = setting.RepoRootPath
|
||||
command.Stdout = os.Stdout
|
||||
command.Stdin = os.Stdin
|
||||
|
||||
Reference in New Issue
Block a user