Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2ca9f4b

Browse filesBrowse files
huseyinacacak-janearuyadorno
authored andcommitted
src: fix kill signal on Windows
Fixes: #42923 PR-URL: #55514 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
1 parent 3ba9b57 commit 2ca9f4b
Copy full SHA for 2ca9f4b

File tree

Expand file treeCollapse file tree

3 files changed

+27
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+27
-2
lines changed
Open diff view settings
Collapse file

‎doc/api/child_process.md‎

Copy file name to clipboardExpand all lines: doc/api/child_process.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1700,8 +1700,8 @@ may not actually terminate the process.
17001700
See kill(2) for reference.
17011701
17021702
On Windows, where POSIX signals do not exist, the `signal` argument will be
1703-
ignored, and the process will be killed forcefully and abruptly (similar to
1704-
`'SIGKILL'`).
1703+
ignored except for `'SIGKILL'`, `'SIGTERM'`, `'SIGINT'` and `'SIGQUIT'`, and the
1704+
process will always be killed forcefully and abruptly (similar to `'SIGKILL'`).
17051705
See [Signal Events][] for more details.
17061706
17071707
On Linux, child processes of child processes will not be terminated
Collapse file

‎src/process_wrap.cc‎

Copy file name to clipboardExpand all lines: src/process_wrap.cc
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ class ProcessWrap : public HandleWrap {
314314
ProcessWrap* wrap;
315315
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This());
316316
int signal = args[0]->Int32Value(env->context()).FromJust();
317+
#ifdef _WIN32
318+
if (signal != SIGKILL && signal != SIGTERM && signal != SIGINT &&
319+
signal != SIGQUIT) {
320+
signal = SIGKILL;
321+
}
322+
#endif
317323
int err = uv_process_kill(&wrap->process_, signal);
318324
args.GetReturnValue().Set(err);
319325
}
Collapse file

‎test/parallel/test-child-process-kill.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-kill.js
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,22 @@ assert.strictEqual(cat.signalCode, null);
3939
assert.strictEqual(cat.killed, false);
4040
cat.kill();
4141
assert.strictEqual(cat.killed, true);
42+
43+
// Test different types of kill signals on Windows.
44+
if (common.isWindows) {
45+
for (const sendSignal of ['SIGTERM', 'SIGKILL', 'SIGQUIT', 'SIGINT']) {
46+
const process = spawn('cmd');
47+
process.on('exit', (code, signal) => {
48+
assert.strictEqual(code, null);
49+
assert.strictEqual(signal, sendSignal);
50+
});
51+
process.kill(sendSignal);
52+
}
53+
54+
const process = spawn('cmd');
55+
process.on('exit', (code, signal) => {
56+
assert.strictEqual(code, null);
57+
assert.strictEqual(signal, 'SIGKILL');
58+
});
59+
process.kill('SIGHUP');
60+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.