Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix kill signal on Windows #55514

Merged

Conversation

huseyinacacak-janea
Copy link
Contributor

On Windows, where POSIX signals do not exist, the signal argument will be ignored, and the process will be killed forcefully and abruptly (similar to 'SIGKILL')

As stated in the documentation of Node.js, the signal parameter of child process kill function is ignored.

However, when we execute spawn(process.execPath, ['-v']).kill('SIGHUP');, it throws an exception with the code ENOSYS. This is not consistent with the documentation.

I've looked at the implementation in libuv and have seen that only four signal types are supported to kill a process on Windows.

This PR fixes this issue by changing the signal to SIGKILL if it differs from SIGQUIT, SIGTERM, SIGKILL, and SIGINT. In addition, there is a slight change in the documentation to clarify the signal parameter.

Fixes: #42923

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run. labels Oct 24, 2024
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.40%. Comparing base (eb63cd2) to head (fbbb15e).
Report is 190 commits behind head on main.

Files with missing lines Patch % Lines
src/process_wrap.cc 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55514      +/-   ##
==========================================
- Coverage   88.40%   88.40%   -0.01%     
==========================================
  Files         653      654       +1     
  Lines      187437   187747     +310     
  Branches    36073    36126      +53     
==========================================
+ Hits       165711   165978     +267     
- Misses      14956    15006      +50     
+ Partials     6770     6763       -7     
Files with missing lines Coverage Δ
src/process_wrap.cc 84.32% <50.00%> (+0.90%) ⬆️

... and 85 files with indirect coverage changes

---- 🚨 Try these New Features:

doc/api/child_process.md Outdated Show resolved Hide resolved
test/parallel/test-child-process-kill.js Outdated Show resolved Hide resolved
Co-authored-by: Luigi Pinca <luigipinca@gmail.com>
Co-authored-by: Luigi Pinca <luigipinca@gmail.com>
@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 30, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 30, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator


// Test different types of kill signals on Windows.
if (common.isWindows) {
const process1 = spawn('cmd');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be simplified down to a for loop of test cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. Fixed it.

@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 8, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 8, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@huseyinacacak-janea
Copy link
Contributor Author

Is there anything else I can do to help this PR move forward?

@richardlau richardlau added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Nov 18, 2024
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Nov 18, 2024
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/55514
✔  Done loading data for nodejs/node/pull/55514
----------------------------------- PR info ------------------------------------
Title      src: fix kill signal on Windows (#55514)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     huseyinacacak-janea:huseyin-10409-process-kill-signal -> nodejs:main
Labels     child_process, c++, needs-ci, commit-queue-squash
Commits    4
 - src: fix kill signal on Windows
 - Update doc/api/child_process.md
 - Update test/parallel/test-child-process-kill.js
 - fixup! src: fix kill signal on Windows
Committers 2
 - Hüseyin Açacak <huseyin@janeasystems.com>
 - GitHub <noreply@github.com>
PR-URL: https://github.com/nodejs/node/pull/55514
Fixes: https://github.com/nodejs/node/issues/42923
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/55514
Fixes: https://github.com/nodejs/node/issues/42923
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last approving review:
   ⚠  - Update doc/api/child_process.md
   ⚠  - Update test/parallel/test-child-process-kill.js
   ⚠  - fixup! src: fix kill signal on Windows
   ℹ  This PR was created on Thu, 24 Oct 2024 10:31:09 GMT
   ✔  Approvals: 1
   ✔  - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/55514#pullrequestreview-2393535306
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2024-11-12T10:37:04Z: https://ci.nodejs.org/job/node-test-pull-request/63526/
- Querying data for job/node-test-pull-request/63526/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/11893278060

@StefanStojanovic StefanStojanovic added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Nov 20, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 20, 2024
@nodejs-github-bot nodejs-github-bot merged commit eb1cb36 into nodejs:main Nov 20, 2024
71 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in eb1cb36

tpoisseau pushed a commit to tpoisseau/node that referenced this pull request Nov 21, 2024
Fixes: nodejs#42923
PR-URL: nodejs#55514
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Nov 26, 2024
Fixes: nodejs#42923
PR-URL: nodejs#55514
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
aduh95 pushed a commit that referenced this pull request Nov 26, 2024
Fixes: #42923
PR-URL: #55514
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. child_process Issues and PRs related to the child_process subsystem. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

subprocess.kill should ignore signal argument on Windows
6 participants