Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"os/exec"
"path"
"strings"
"syscall"
)

type service struct {
Expand Down Expand Up @@ -145,7 +144,7 @@ func (s *Server) getInfoRefs(_ string, w http.ResponseWriter, r *Request) {
fail500(w, context, err)
return
}
defer cleanUpProcessGroup(cmd)
defer cleanUpProcess(cmd)

w.Header().Add("Content-Type", fmt.Sprintf("application/x-%s-advertisement", rpc))
w.Header().Add("Cache-Control", "no-cache")
Expand Down Expand Up @@ -197,7 +196,7 @@ func (s *Server) postRPC(rpc string, w http.ResponseWriter, r *Request) {
fail500(w, context, err)
return
}
defer cleanUpProcessGroup(cmd)
defer cleanUpProcess(cmd)

if _, err := io.Copy(stdin, body); err != nil {
fail500(w, context, err)
Expand Down Expand Up @@ -243,7 +242,6 @@ func repoExists(p string) bool {

func gitCommand(name string, args ...string) (*exec.Cmd, io.Reader) {
cmd := exec.Command(name, args...)
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
cmd.Env = os.Environ()

r, _ := cmd.StdoutPipe()
Expand Down
5 changes: 2 additions & 3 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os/exec"
"regexp"
"strings"
"syscall"
)

var reSlashDedup = regexp.MustCompile(`\/{2,}`)
Expand All @@ -26,14 +25,14 @@ func logInfo(context string, message string) {
log.Printf("%s: %s\n", context, message)
}

func cleanUpProcessGroup(cmd *exec.Cmd) {
func cleanUpProcess(cmd *exec.Cmd) {
if cmd == nil {
return
}

process := cmd.Process
if process != nil && process.Pid > 0 {
syscall.Kill(-process.Pid, syscall.SIGTERM)
process.Kill()
}

go cmd.Wait()
Expand Down