aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-06-03 15:36:18 +0100
committerGitHub <noreply@github.com>2022-06-03 15:36:18 +0100
commit1d04e8641d4abab6ce978bc2dc5523c2ddb2f628 (patch)
tree742564159535d13dd060074187be79616da2bb3f /modules/git
parent085924b1b370310c989fa5e75bb33323746382b0 (diff)
downloadgitea-1d04e8641d4abab6ce978bc2dc5523c2ddb2f628.tar.gz
gitea-1d04e8641d4abab6ce978bc2dc5523c2ddb2f628.zip
Set Setpgid on child git processes (#19865)
When Gitea is running as PID 1 git will occassionally orphan child processes leading to (defunct) processes. This PR simply sets Setpgid to true on these child processes meaning that these defunct processes will also be correctly reaped. Fix #19077 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/blame.go1
-rw-r--r--modules/git/command.go1
2 files changed, 2 insertions, 0 deletions
diff --git a/modules/git/blame.go b/modules/git/blame.go
index 40e3d4e885..1653ecbf85 100644
--- a/modules/git/blame.go
+++ b/modules/git/blame.go
@@ -124,6 +124,7 @@ func createBlameReader(ctx context.Context, dir string, command ...string) (*Bla
cmd := exec.CommandContext(ctx, command[0], command[1:]...)
cmd.Dir = dir
cmd.Stderr = os.Stderr
+ process.SetSysProcAttribute(cmd)
stdout, err := cmd.StdoutPipe()
if err != nil {
diff --git a/modules/git/command.go b/modules/git/command.go
index 3dd12e421e..f6344dbfd1 100644
--- a/modules/git/command.go
+++ b/modules/git/command.go
@@ -157,6 +157,7 @@ func (c *Command) Run(opts *RunOpts) error {
"GIT_NO_REPLACE_OBJECTS=1",
)
+ process.SetSysProcAttribute(cmd)
cmd.Dir = opts.Dir
cmd.Stdout = opts.Stdout
cmd.Stderr = opts.Stderr