Skip to content

Commit b2584a2

Browse files
committed
Set Setpgid on child git processes
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 killed. Fix go-gitea#19077 Signed-off-by: Andrew Thornton <[email protected]>
1 parent d002e3d commit b2584a2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

modules/git/command.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"os"
1414
"os/exec"
1515
"strings"
16+
"syscall"
1617
"time"
1718
"unsafe"
1819

@@ -157,6 +158,7 @@ func (c *Command) Run(opts *RunOpts) error {
157158
"GIT_NO_REPLACE_OBJECTS=1",
158159
)
159160

161+
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
160162
cmd.Dir = opts.Dir
161163
cmd.Stdout = opts.Stdout
162164
cmd.Stderr = opts.Stderr

0 commit comments

Comments
 (0)