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

lib: allow process kill by signal number #16944

Closed
wants to merge 3 commits into
base: master
from

Conversation

Projects
None yet
8 participants
@sam-github
Member

sam-github commented Nov 10, 2017

This brings the behaviour in line with the documentation.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)
@sam-github

This comment has been minimized.

@@ -158,8 +158,8 @@ function setupKillAndExit() {
}
// preserve null signal
if (0 === sig) {
err = process._kill(pid, 0);
if (sig == (sig | 0)) {

This comment has been minimized.

@addaleax

addaleax Nov 10, 2017

Member

Don’t you want to keep the ===?

@cjihrig

LGTM if the CI is happy. It will need restarted, as the linter failed.

@sam-github

This comment has been minimized.

Member

sam-github commented Nov 10, 2017

Linting is fixed, build and passed locally, will wait for all the platforms to pass before restarting for an all-green run.

});
assert.throws(function() { process.kill(1, 987); },
invalidSignalNumber);

This comment has been minimized.

@jasnell

jasnell Nov 12, 2017

Member

this can be simplified to just

common.expectsError(
  () => process.kill(1, 987),
  {
    code: 'EINVAL',
    type: Error,
    message: 'kill EINVAL'
  }
);

This comment has been minimized.

@sam-github

sam-github added a commit to sam-github/node that referenced this pull request Nov 12, 2017

test: pass test function to expectsError
PR-URL: nodejs#16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

sam-github added a commit to sam-github/node that referenced this pull request Nov 12, 2017

lib: allow process kill by signal number
This brings the behaviour in line with the documentation.

PR-URL: nodejs#16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
// Test that kill throws an error for invalid signal
const unknownSignal = common.expectsError({
// Test that kill throws an error for unknown signal names
common.expectsError(process.kill(1, 'test'), {

This comment has been minimized.

@jasnell

jasnell Nov 12, 2017

Member

common.expectsError( () => process.kill(1, 'test'), { ... }

That is, The first argument needs to be a function...

sam-github added some commits Nov 10, 2017

lib: allow process kill by signal number
This brings the behaviour in line with the documentation.

PR-URL: #16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
test: pass test function to expectsError
PR-URL: #16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

sam-github added a commit to sam-github/node that referenced this pull request Nov 15, 2017

test: pass test function to expectsError
PR-URL: nodejs#16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

sam-github added a commit to sam-github/node that referenced this pull request Nov 15, 2017

lib: allow process kill by signal number
This brings the behaviour in line with the documentation.

PR-URL: nodejs#16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@sam-github

This comment has been minimized.

Member

sam-github commented Nov 15, 2017

@jasnell passed locally, ci running

@addaleax

This comment has been minimized.

Member

addaleax commented Nov 18, 2017

@sam-github Was there a CI run associated with this?

CI: https://ci.nodejs.org/job/node-test-commit/14133/

@addaleax addaleax added author ready and removed author ready labels Nov 18, 2017

@addaleax

This comment has been minimized.

Member

addaleax commented Nov 18, 2017

@sam-github Looks like this doesn’t work on Windows quite yet

@bzoz

This comment has been minimized.

Contributor

bzoz commented Nov 20, 2017

On Windows libuv first tries to open the process handle (src/win/process.c:1246) before checking for correct signal. If the signum is invalid, it will raise ENOSYS (src/win/process.c:1215). For this test to work, we would need to change libuv, which I guess would be rather simple.

@sam-github

This comment has been minimized.

Member

sam-github commented Nov 20, 2017

I'll take a look, should have time this week.

@bzoz

This comment has been minimized.

Contributor

bzoz commented Nov 21, 2017

I've made a PR in libuv for this: libuv/libuv#1642

@BridgeAR BridgeAR added the blocked label Dec 10, 2017

@BridgeAR

This comment has been minimized.

Member

BridgeAR commented Dec 10, 2017

Seems like this can land with the next libuv update.

@BridgeAR

This comment has been minimized.

Member

BridgeAR commented Feb 1, 2018

@sam-github there seems to be an issue on Windows:

https://ci.nodejs.org/job/node-test-binary-windows/14617/COMPILED_BY=vs2017,RUNNER=win2016,RUN_SUBSET=0/console

not ok 314 parallel/test-process-kill-pid
  ---
  duration_ms: 0.297
  severity: fail
  stack: |-
    assert.js:72
      throw new AssertionError(obj);
      ^
    
    AssertionError [ERR_ASSERTION]: 'ESRCH' strictEqual 'EINVAL'
        at Object.innerFn (c:\workspace\node-test-binary-windows\test\common\index.js:745:12)
        at expectedException (assert.js:382:19)
        at Function.throws (assert.js:427:16)
        at Object.expectsError (c:\workspace\node-test-binary-windows\test\common\index.js:784:12)
        at Object.<anonymous> (c:\workspace\node-test-binary-windows\test\parallel\test-process-kill-pid.js:68:8)
        at Module._compile (module.js:666:30)
        at Object.Module._extensions..js (module.js:677:10)
        at Module.load (module.js:578:32)
        at tryModuleLoad (module.js:518:12)
        at Function.Module._load (module.js:510:3)

@BridgeAR BridgeAR removed the author ready label Feb 1, 2018

@bzoz

This comment has been minimized.

Contributor

bzoz commented Feb 1, 2018

There is no process with PID 1 on Windows. Change those to 0 or process.pid and it should work.

@BridgeAR

This comment has been minimized.

Member

BridgeAR commented Feb 7, 2018

@BridgeAR

This comment has been minimized.

Member

BridgeAR commented Feb 17, 2018

@bzoz

This comment has been minimized.

Contributor

bzoz commented Feb 17, 2018

CI failures on Windows are unrelated

@BridgeAR

This comment has been minimized.

Member

BridgeAR commented Feb 17, 2018

Running one more CI before landing.

https://ci.nodejs.org/job/node-test-pull-request/13242/

@BridgeAR

This comment has been minimized.

Member

BridgeAR commented Feb 17, 2018

Landed in 7ca4ca8 🎉

@BridgeAR BridgeAR closed this Feb 17, 2018

BridgeAR added a commit to BridgeAR/node that referenced this pull request Feb 17, 2018

lib: allow process kill by signal number
This brings the behaviour in line with the documentation.

PR-URL: nodejs#16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>

MylesBorins added a commit that referenced this pull request Feb 21, 2018

lib: allow process kill by signal number
This brings the behaviour in line with the documentation.

PR-URL: #16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>

@MylesBorins MylesBorins referenced this pull request Feb 21, 2018

Merged

v9.6.0 proposal #18902

MylesBorins added a commit that referenced this pull request Feb 21, 2018

lib: allow process kill by signal number
This brings the behaviour in line with the documentation.

PR-URL: #16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>

MylesBorins added a commit that referenced this pull request Feb 21, 2018

2018-02-21, Version 9.6.0 (Current)
Notable changes:

* async_hooks:
  - deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
    #18513
  - rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
    (Ali Ijaz Sheikh) #18633
* deps:
  - update node-inspect to 1.11.3 (Jan Krems)
    #18354
  - ICU 60.2 bump (Steven R. Loomis)
    #17687
  - Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
    #16889
* http:
  - add options to http.createServer() for `IncomingMessage` and
    `ServerReponse` (Peter Marton)
    #15752
* http2:
  - add http fallback options to .createServer (Peter Marton)
    #15752
* https:
  - Adds the remaining options from tls.createSecureContext() to the
    string generated by Agent#getName(). This allows https.request()
    to accept the options and generate unique sockets appropriately.
    (Jeff Principe)
    #16402
* inspector:
  - --inspect-brk for es modules (Guy Bedford)
    #18194
* lib:
  - allow process kill by signal number (Sam Roberts)
    #16944
* module:
  - enable dynamic import (Myles Borins)
    #18387
  - dynamic import is now supported (Jan Krems)
    #15713
* napi:
  - add methods to open/close callback scope (Michael Dawson)
    #18089
* src:
  - allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
    #17600
* vm:
  - add support for es modules (Gus Caplan)
    #17560

PR-URL: #18902

MylesBorins added a commit that referenced this pull request Feb 21, 2018

2018-02-21, Version 9.6.0 (Current)
Notable changes:

* async_hooks:
  - deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
    #18513
  - rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
    (Ali Ijaz Sheikh) #18633
* deps:
  - update node-inspect to 1.11.3 (Jan Krems)
    #18354
  - ICU 60.2 bump (Steven R. Loomis)
    #17687
  - Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
    #16889
* http:
  - add options to http.createServer() for `IncomingMessage` and
    `ServerReponse` (Peter Marton)
    #15752
* http2:
  - add http fallback options to .createServer (Peter Marton)
    #15752
* https:
  - Adds the remaining options from tls.createSecureContext() to the
    string generated by Agent#getName(). This allows https.request()
    to accept the options and generate unique sockets appropriately.
    (Jeff Principe)
    #16402
* inspector:
  - --inspect-brk for es modules (Guy Bedford)
    #18194
* lib:
  - allow process kill by signal number (Sam Roberts)
    #16944
* module:
  - enable dynamic import (Myles Borins)
    #18387
  - dynamic import is now supported (Jan Krems)
    #15713
* napi:
  - add methods to open/close callback scope (Michael Dawson)
    #18089
* src:
  - allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
    #17600
* vm:
  - add support for es modules (Gus Caplan)
    #17560

PR-URL: #18902

MylesBorins added a commit that referenced this pull request Feb 21, 2018

2018-02-21, Version 9.6.0 (Current)
Notable changes:

* async_hooks:
  - deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
    #18513
  - rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
    (Ali Ijaz Sheikh) #18633
* deps:
  - update node-inspect to 1.11.3 (Jan Krems)
    #18354
  - ICU 60.2 bump (Steven R. Loomis)
    #17687
  - Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
    #16889
* http:
  - add options to http.createServer() for `IncomingMessage` and
    `ServerReponse` (Peter Marton)
    #15752
* http2:
  - add http fallback options to .createServer (Peter Marton)
    #15752
* https:
  - Adds the remaining options from tls.createSecureContext() to the
    string generated by Agent#getName(). This allows https.request()
    to accept the options and generate unique sockets appropriately.
    (Jeff Principe)
    #16402
* inspector:
  - --inspect-brk for es modules (Guy Bedford)
    #18194
* lib:
  - allow process kill by signal number (Sam Roberts)
    #16944
* module:
  - enable dynamic import (Myles Borins)
    #18387
  - dynamic import is now supported (Jan Krems)
    #15713
* napi:
  - add methods to open/close callback scope (Michael Dawson)
    #18089
* src:
  - allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
    #17600
* vm:
  - add support for es modules (Gus Caplan)
    #17560

PR-URL: #18902

MylesBorins added a commit that referenced this pull request Feb 21, 2018

lib: allow process kill by signal number
This brings the behaviour in line with the documentation.

PR-URL: #16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>

MylesBorins added a commit that referenced this pull request Feb 21, 2018

2018-02-21, Version 9.6.0 (Current)
Notable changes:

* async_hooks:
  - deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
    #18513
  - rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
    (Ali Ijaz Sheikh) #18633
* deps:
  - update node-inspect to 1.11.3 (Jan Krems)
    #18354
  - ICU 60.2 bump (Steven R. Loomis)
    #17687
  - Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
    #16889
* http:
  - add options to http.createServer() for `IncomingMessage` and
    `ServerReponse` (Peter Marton)
    #15752
* http2:
  - add http fallback options to .createServer (Peter Marton)
    #15752
* https:
  - Adds the remaining options from tls.createSecureContext() to the
    string generated by Agent#getName(). This allows https.request()
    to accept the options and generate unique sockets appropriately.
    (Jeff Principe)
    #16402
* inspector:
  - --inspect-brk for es modules (Guy Bedford)
    #18194
* lib:
  - allow process kill by signal number (Sam Roberts)
    #16944
* module:
  - enable dynamic import (Myles Borins)
    #18387
  - dynamic import is now supported (Jan Krems)
    #15713
* napi:
  - add methods to open/close callback scope (Michael Dawson)
    #18089
* src:
  - allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
    #17600
* vm:
  - add support for es modules (Gus Caplan)
    #17560

PR-URL: #18902

MylesBorins added a commit that referenced this pull request Feb 21, 2018

2018-02-22, Version 9.6.0 (Current)
Notable changes:

* async_hooks:
  - deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
    #18513
  - rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
    (Ali Ijaz Sheikh) #18633
* deps:
  - update node-inspect to 1.11.3 (Jan Krems)
    #18354
  - ICU 60.2 bump (Steven R. Loomis)
    #17687
  - Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
    #16889
* http:
  - add options to http.createServer() for `IncomingMessage` and
    `ServerReponse` (Peter Marton)
    #15752
* http2:
  - add http fallback options to .createServer (Peter Marton)
    #15752
* https:
  - Adds the remaining options from tls.createSecureContext() to the
    string generated by Agent#getName(). This allows https.request()
    to accept the options and generate unique sockets appropriately.
    (Jeff Principe)
    #16402
* inspector:
  - --inspect-brk for es modules (Guy Bedford)
    #18194
* lib:
  - allow process kill by signal number (Sam Roberts)
    #16944
* module:
  - enable dynamic import (Myles Borins)
    #18387
  - dynamic import is now supported (Jan Krems)
    #15713
* napi:
  - add methods to open/close callback scope (Michael Dawson)
    #18089
* src:
  - allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
    #17600
* vm:
  - add support for es modules (Gus Caplan)
    #17560

PR-URL: #18902

MylesBorins added a commit that referenced this pull request Feb 22, 2018

2018-02-22, Version 9.6.0 (Current)
Notable changes:

* async_hooks:
  - deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
    #18513
  - rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
    (Ali Ijaz Sheikh) #18633
* deps:
  - update node-inspect to 1.11.3 (Jan Krems)
    #18354
  - ICU 60.2 bump (Steven R. Loomis)
    #17687
  - Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
    #16889
* http:
  - add options to http.createServer() for `IncomingMessage` and
    `ServerReponse` (Peter Marton)
    #15752
* http2:
  - add http fallback options to .createServer (Peter Marton)
    #15752
* https:
  - Adds the remaining options from tls.createSecureContext() to the
    string generated by Agent#getName(). This allows https.request()
    to accept the options and generate unique sockets appropriately.
    (Jeff Principe)
    #16402
* inspector:
  - --inspect-brk for es modules (Guy Bedford)
    #18194
* lib:
  - allow process kill by signal number (Sam Roberts)
    #16944
* module:
  - enable dynamic import (Myles Borins)
    #18387
  - dynamic import is now supported (Jan Krems)
    #15713
* napi:
  - add methods to open/close callback scope (Michael Dawson)
    #18089
* src:
  - allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
    #17600
* vm:
  - add support for es modules (Gus Caplan)
    #17560

PR-URL: #18902

gabrielschulhof added a commit to gabrielschulhof/node that referenced this pull request Mar 15, 2018

2018-02-22, Version 9.6.0 (Current)
Notable changes:

* async_hooks:
  - deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
    nodejs#18513
  - rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
    (Ali Ijaz Sheikh) nodejs#18633
* deps:
  - update node-inspect to 1.11.3 (Jan Krems)
    nodejs#18354
  - ICU 60.2 bump (Steven R. Loomis)
    nodejs#17687
  - Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
    nodejs#16889
* http:
  - add options to http.createServer() for `IncomingMessage` and
    `ServerReponse` (Peter Marton)
    nodejs#15752
* http2:
  - add http fallback options to .createServer (Peter Marton)
    nodejs#15752
* https:
  - Adds the remaining options from tls.createSecureContext() to the
    string generated by Agent#getName(). This allows https.request()
    to accept the options and generate unique sockets appropriately.
    (Jeff Principe)
    nodejs#16402
* inspector:
  - --inspect-brk for es modules (Guy Bedford)
    nodejs#18194
* lib:
  - allow process kill by signal number (Sam Roberts)
    nodejs#16944
* module:
  - enable dynamic import (Myles Borins)
    nodejs#18387
  - dynamic import is now supported (Jan Krems)
    nodejs#15713
* napi:
  - add methods to open/close callback scope (Michael Dawson)
    nodejs#18089
* src:
  - allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
    nodejs#17600
* vm:
  - add support for es modules (Gus Caplan)
    nodejs#17560

This applies the parts of 945eb1b that
are relevant to N-API.

PR-URL: nodejs#18902

MayaLekova added a commit to MayaLekova/node that referenced this pull request May 8, 2018

lib: allow process kill by signal number
This brings the behaviour in line with the documentation.

PR-URL: nodejs#16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>

MayaLekova added a commit to MayaLekova/node that referenced this pull request May 8, 2018

2018-02-22, Version 9.6.0 (Current)
Notable changes:

* async_hooks:
  - deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
    nodejs#18513
  - rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
    (Ali Ijaz Sheikh) nodejs#18633
* deps:
  - update node-inspect to 1.11.3 (Jan Krems)
    nodejs#18354
  - ICU 60.2 bump (Steven R. Loomis)
    nodejs#17687
  - Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
    nodejs#16889
* http:
  - add options to http.createServer() for `IncomingMessage` and
    `ServerReponse` (Peter Marton)
    nodejs#15752
* http2:
  - add http fallback options to .createServer (Peter Marton)
    nodejs#15752
* https:
  - Adds the remaining options from tls.createSecureContext() to the
    string generated by Agent#getName(). This allows https.request()
    to accept the options and generate unique sockets appropriately.
    (Jeff Principe)
    nodejs#16402
* inspector:
  - --inspect-brk for es modules (Guy Bedford)
    nodejs#18194
* lib:
  - allow process kill by signal number (Sam Roberts)
    nodejs#16944
* module:
  - enable dynamic import (Myles Borins)
    nodejs#18387
  - dynamic import is now supported (Jan Krems)
    nodejs#15713
* napi:
  - add methods to open/close callback scope (Michael Dawson)
    nodejs#18089
* src:
  - allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
    nodejs#17600
* vm:
  - add support for es modules (Gus Caplan)
    nodejs#17560

PR-URL: nodejs#18902
@MylesBorins

This comment has been minimized.

Member

MylesBorins commented Aug 7, 2018

Should this be backported to v8.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

@sam-github sam-github deleted the sam-github:kill-allow-numbers branch Oct 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment