Skip to content

Commit 025f658

Browse files
bnoordhuisMylesBorins
authored andcommitted
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: #31747 PR-URL: #31768 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]>
1 parent 079bb31 commit 025f658

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/spawn_sync.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,9 @@ void SyncProcessRunner::Kill() {
607607
if (r < 0 && r != UV_ESRCH) {
608608
SetError(r);
609609

610-
r = uv_process_kill(&uv_process_, SIGKILL);
611-
CHECK(r >= 0 || r == UV_ESRCH);
610+
// Deliberately ignore the return value, we might not have
611+
// sufficient privileges to signal the child process.
612+
USE(uv_process_kill(&uv_process_, SIGKILL));
612613
}
613614
}
614615

0 commit comments

Comments
 (0)