Skip to content

Set Setpgid on child git processes #19865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 3, 2022
1 change: 1 addition & 0 deletions modules/git/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func (c *Command) Run(opts *RunOpts) error {
"GIT_NO_REPLACE_OBJECTS=1",
)

setSysProcAttribute(cmd)
cmd.Dir = opts.Dir
cmd.Stdout = opts.Stdout
cmd.Stderr = opts.Stderr
Expand Down
16 changes: 16 additions & 0 deletions modules/git/command_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

//go:build !windows

package git

import (
"os/exec"
"syscall"
)

func setSysProcAttribute(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
}
15 changes: 15 additions & 0 deletions modules/git/command_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

//go:build windows

import (
"os/exec"
)

package git

func setSysProcAttribute(cmd *exec.Cmd) {
// Do nothing
}