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:
zeripath
2021-06-30 21:07:23 +01:00
repo.diff.committed_by GitHub
repo.diff.parent 365c4e9316
repo.diff.commit 302e8b6d02
repo.diff.stats_desc%!(EXTRA int=3, int=34, int=4)

repo.diff.view_file

@@ -66,7 +66,7 @@ func sessionHandler(session ssh.Session) {
args := []string{"serv", "key-" + keyID, "--config=" + setting.CustomConf}
log.Trace("SSH: Arguments: %v", args)
cmd := exec.Command(setting.AppPath, args...)
cmd := exec.CommandContext(session.Context(), setting.AppPath, args...)
cmd.Env = append(
os.Environ(),
"SSH_ORIGINAL_COMMAND="+command,