update Subprocess::terminateOrKill(0) to immediately send SIGKILL
commitfc6282015e1930d3377a01a7e848882d1f2095a2
authorAdam Simpkins <simpkins@meta.com>
Wed, 28 Sep 2022 20:02:46 +0000 (28 13:02 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 28 Sep 2022 20:02:46 +0000 (28 13:02 -0700)
tree5bd55b1b2c3b943b522b23b5bb67c22fb807fb6d
parent23398d3adb1dc35a2e977ca506bc3f0978df7b95
update Subprocess::terminateOrKill(0) to immediately send SIGKILL

Summary:
When calling `terminateOrKill()` with `sigtermTimeout` set to 0, just send
`SIGKILL` rather than `SIGTERM` immediately followed by `SIGKILL`.

When the timeout is 0 or negative, there doesn't seem to be much point to
sending `SIGTERM` and letting the process start executing their `SIGTERM`
handler if we just plan to immediately kill the process.

Note that this does potentially change the behavior of `terminateOrKill()`
slightly: if the child process did not handle `SIGTERM` and exits immediately
upon receipt of this signal previously the return value would indicate that
the process was killed with `SIGTERM`, while now it will indicate that the
process was killed with `SIGKILL`.  However, very few call sites call
`terminateOrKill()` with a 0 timeout, and this behavior change should have
minimal impact.

Reviewed By: luciang

Differential Revision: D39839037

fbshipit-source-id: 6f6dcdeecb16a8dd034bdec3fb168e19bf580c35
third-party/folly/src/folly/Subprocess.cpp
third-party/folly/src/folly/Subprocess.h
third-party/folly/src/folly/test/SubprocessTest.cpp