Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2020-02-13 14:40:53 +0300
committerAnna Henningsen <anna@addaleax.net>2020-03-11 21:30:08 +0300
commitd09e1da669f5cc3229f31167a5849566b0de0400 (patch)
treea99c6436f2bed080c1493712b06d19e798c38885 /src/spawn_sync.cc
parent0b49e2f3835b0206b1623358df22f6cfc41d1a11 (diff)
src: fix spawnSync CHECK when SIGKILL fails
We might not have sufficient privileges to signal the child process so don't make assumptions about the return value of `uv_process_kill()`. Example: node -e 'child_process.spawnSync("sudo", ["ls"], { maxBuffer: 1 })' No test because: 1. The test needs to run as root (can't invoke sudo), and 2. The parent needs to drop privileges but can't, because then the child process won't have sufficient privileges. Fixes: https://github.com/nodejs/node/issues/31747 PR-URL: https://github.com/nodejs/node/pull/31768 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src/spawn_sync.cc')
-rw-r--r--src/spawn_sync.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc
index 589b77f6c1e..78e474cd825 100644
--- a/src/spawn_sync.cc
+++ b/src/spawn_sync.cc
@@ -607,8 +607,9 @@ void SyncProcessRunner::Kill() {
if (r < 0 && r != UV_ESRCH) {
SetError(r);
- r = uv_process_kill(&uv_process_, SIGKILL);
- CHECK(r >= 0 || r == UV_ESRCH);
+ // Deliberately ignore the return value, we might not have
+ // sufficient privileges to signal the child process.
+ USE(uv_process_kill(&uv_process_, SIGKILL));
}
}