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

lib: allow process kill by signal number #16944

Closed
wants to merge 3 commits into from

Conversation

sam-github
Copy link
Contributor

@sam-github 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)

@nodejs-github-bot nodejs-github-bot added the process Issues and PRs related to the process subsystem. label Nov 10, 2017
@sam-github
Copy link
Contributor Author

@@ -158,8 +158,8 @@ function setupKillAndExit() {
}

// preserve null signal
if (0 === sig) {
err = process._kill(pid, 0);
if (sig == (sig | 0)) {
Copy link
Member

Choose a reason for hiding this comment

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

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

@sam-github sam-github force-pushed the kill-allow-numbers branch 2 times, most recently from f8fa77d to 823de05 Compare November 10, 2017 22:11
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

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

@sam-github
Copy link
Contributor Author

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);
Copy link
Member

Choose a reason for hiding this comment

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

this can be simplified to just

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@sam-github sam-github force-pushed the kill-allow-numbers branch 2 times, most recently from 92235a0 to bfb2503 Compare November 12, 2017 13:20
@sam-github sam-github added the semver-minor PRs that contain new features and should be released in the next minor version. label Nov 12, 2017
// 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'), {
Copy link
Member

Choose a reason for hiding this comment

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

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

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

PR-URL: nodejs#16944
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
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
Copy link
Contributor Author

@jasnell passed locally, ci running

@addaleax
Copy link
Member

@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 PRs that have at least one approval, no pending requests for changes, and a CI started. and removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Nov 18, 2017
@addaleax
Copy link
Member

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

@bzoz
Copy link
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
Copy link
Contributor Author

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

@BridgeAR
Copy link
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 PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 1, 2018
@bzoz
Copy link
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
Copy link
Member

BridgeAR commented Feb 7, 2018

Ping @sam-github

@BridgeAR
Copy link
Member

I pushed the fix that @bzoz suggested.

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

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 17, 2018
@bzoz
Copy link
Contributor

bzoz commented Feb 17, 2018

CI failures on Windows are unrelated

@BridgeAR
Copy link
Member

Running one more CI before landing.

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

@BridgeAR
Copy link
Member

Landed in 7ca4ca8 🎉

@BridgeAR BridgeAR closed this Feb 17, 2018
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Feb 17, 2018
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 pushed a commit that referenced this pull request Feb 21, 2018
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 mentioned this pull request Feb 21, 2018
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
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
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 pushed a commit that referenced this pull request Feb 21, 2018
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
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
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
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
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 pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
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
Copy link
Contributor

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 kill-allow-numbers branch October 16, 2018 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. process Issues and PRs related to the process subsystem. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants