Commit 8cb3a69a authored by Jacob Vosmaer's avatar Jacob Vosmaer

Prevent archive zombies

Episode V: The Archive Zombies Strike Back
parent 607825c5
...@@ -14,6 +14,7 @@ import ( ...@@ -14,6 +14,7 @@ import (
"os/exec" "os/exec"
"path" "path"
"path/filepath" "path/filepath"
"syscall"
"time" "time"
) )
...@@ -79,6 +80,7 @@ func handleGetArchive(w http.ResponseWriter, r *gitRequest) { ...@@ -79,6 +80,7 @@ func handleGetArchive(w http.ResponseWriter, r *gitRequest) {
stdout = archiveStdout stdout = archiveStdout
} else { } else {
compressCmd.Stdin = archiveStdout compressCmd.Stdin = archiveStdout
compressCmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
stdout, err = compressCmd.StdoutPipe() stdout, err = compressCmd.StdoutPipe()
if err != nil { if err != nil {
...@@ -91,7 +93,7 @@ func handleGetArchive(w http.ResponseWriter, r *gitRequest) { ...@@ -91,7 +93,7 @@ func handleGetArchive(w http.ResponseWriter, r *gitRequest) {
fail500(w, fmt.Errorf("handleGetArchive: start %v: %v", compressCmd.Args, err)) fail500(w, fmt.Errorf("handleGetArchive: start %v: %v", compressCmd.Args, err))
return return
} }
defer compressCmd.Wait() defer cleanUpProcessGroup(compressCmd)
archiveStdout.Close() archiveStdout.Close()
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment