mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-03 13:04:08 +02:00
Prevent zombie processes (#16314)
Unfortunately go doesn't always ensure that execd processes are completely waited for. On linux this means that zombie processes can occur. This PR ensures that these are waited for by using signal notifier in serv and passing a context elsewhere. Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
1 parent
365c4e9316
commit
302e8b6d02
3 files changed
+34
-4
No files matched your search
Vendored
+9
-1
@@ -5,6 +5,7 @@
|
||||
package external
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -15,6 +16,7 @@ import (
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/process"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
)
|
||||
@@ -96,7 +98,13 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
|
||||
args = append(args, f.Name())
|
||||
}
|
||||
|
||||
cmd := exec.Command(commands[0], args...)
|
||||
processCtx, cancel := context.WithCancel(ctx.Ctx)
|
||||
defer cancel()
|
||||
|
||||
pid := process.GetManager().Add(fmt.Sprintf("Render [%s] for %s", commands[0], ctx.URLPrefix), cancel)
|
||||
defer process.GetManager().Remove(pid)
|
||||
|
||||
cmd := exec.CommandContext(processCtx, commands[0], args...)
|
||||
cmd.Env = append(
|
||||
os.Environ(),
|
||||
"GITEA_PREFIX_SRC="+ctx.URLPrefix,
|
||||
|
||||
Reference in new issue
Block a user