Skip to content

comby: kill child processes on context timeout

Warren Gifford requested to merge rvt/clean-child-process-cleanup into master

Created by: rvantonder

This is a cleaner follow up to #7177. See #7177 for details, but in summary:

CommandContext is used to kill comby when it takes too long, but only kills the parent comby process, and all child processes are oprhaned.

Setting cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} and then killing the PID is the right thing to do to kill child processes. But doing so doesn't work with CommandContext.

The solution takes care of manually removing child processes when ctx.Done is reached:


Tested manually, since it's hard to check that child processes are properly receiving sigkill. I used this script that reports child proc status in a tight loop:

#!/bin/bash

while [ : ]; do
    ps -aef | grep comby
    sleep .1
done

and then ran a search command

repo:^github\.com/sourcegraph/sourcegraph$  "func Test" count:10000 lang:go timeout:500ms

multiple times. Before this PR, the orphaned child procs are (briefly) visible, and with the change, they are not.

Merge request reports

Loading