Child process signal forwarding not reliably working for consul watch
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
We cleaned this up in #2999. When `consul watch` commands are run with a handler script, the handler script is a child of the parent `consul watch` process. However, sending -KILL/-INT to the parent doesn't seem to forward it to the child reliabily. After trying this a number of times, I only saw it successfully forward it once.
Reproduction steps:
1) Bash script that traps signals:
```
#!/bin/bash
sigint()
{
echo "signal INT received"
exit 0
}
sigkill()
{
echo "signal KILL received"
exit 0
}
trap 'sigint' INT
trap 'sigkill' KILL
echo "PID is $$"
while true
do
sleep 5
done
```
2) Run consul watch:
```consul watch -type key -key test ./test.sh```
3) send INT or KILL to the consul watch pid, it doesn't cause test.sh to exit. test.sh still shows up in ps output.
Sending INT or KILL to test.sh's PID works as expected and terminates the script.
Seems like there is a narrow window in which we forward this and that races with the `consul watch` process processing the INT/KILL and stopping itself.
Contributor guide
Assessment
This issue has not been assessed yet.