Skip to content

Commit 727baad

Browse files
authored
Merge pull request #7 from aryan9600/remove-process-groups
Add support for Windows by removing the usage of process groups
2 parents c056745 + c18eb31 commit 727baad

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

http.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"os/exec"
1010
"path"
1111
"strings"
12-
"syscall"
1312
)
1413

1514
type service struct {
@@ -145,7 +144,7 @@ func (s *Server) getInfoRefs(_ string, w http.ResponseWriter, r *Request) {
145144
fail500(w, context, err)
146145
return
147146
}
148-
defer cleanUpProcessGroup(cmd)
147+
defer cleanUpProcess(cmd)
149148

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

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

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

249247
r, _ := cmd.StdoutPipe()

utils.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"os/exec"
99
"regexp"
1010
"strings"
11-
"syscall"
1211
)
1312

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

29-
func cleanUpProcessGroup(cmd *exec.Cmd) {
28+
func cleanUpProcess(cmd *exec.Cmd) {
3029
if cmd == nil {
3130
return
3231
}
3332

3433
process := cmd.Process
3534
if process != nil && process.Pid > 0 {
36-
syscall.Kill(-process.Pid, syscall.SIGTERM)
35+
process.Kill()
3736
}
3837

3938
go cmd.Wait()

0 commit comments

Comments
 (0)