Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

process: pid can be a string in process.kill() #8531

Closed
wants to merge 2 commits into from
Closed

process: pid can be a string in process.kill() #8531

wants to merge 2 commits into from

Conversation

sam-github
Copy link

Not allowing string was a change from v0.10 behaviour, commented on in
#7991. Allow them again, but still check that argument is
numberish. Also, simplify the fragile and non-portable test code
introduced in 832ec1c that required fixups 2a41535, and
ef3c4ed.

Sorry about the test awfulness I introduced, @misterdjules @tjfontaine.

Not allowing string was a change from v0.10 behaviour, commented on in
#7991. Allow them again, but still check that argument is
numberish. Also, simplify the fragile and non-portable test code
introduced in 832ec1c that required fixups 2a41535, and
ef3c4ed.
@@ -641,8 +641,8 @@
process.kill = function(pid, sig) {
var err;

if (typeof pid !== 'number' || !isFinite(pid)) {
throw new TypeError('pid must be a number');
if (pid != (pid | 0)) {

Choose a reason for hiding this comment

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

Prefer pid >>> 0. That is the only way to do uint coercion, and since you can't have a negative pid makes sense to do it this way. :)

Copy link
Author

Choose a reason for hiding this comment

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

You can send signals to negative pids (see man 2 kill), and negative numbers are tested for in the test, and supported by node/libuv.

Choose a reason for hiding this comment

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

ah, whoops. I'm thinking of fd's. sorry. :)

@trevnorris
Copy link

@sam-github one more small nit. Thanks

@sam-github
Copy link
Author

@trevnorris ping

@trevnorris
Copy link

Thanks. Merged in 743a009.

@trevnorris trevnorris closed this Nov 17, 2014
trevnorris pushed a commit that referenced this pull request Nov 17, 2014
Not allowing string was a change from v0.10 behaviour, commented on in
#7991. Allow them again, but still check that argument is
numberish. Also, simplify the fragile and non-portable test code
introduced in 832ec1c that required fixups 2a41535, and
ef3c4ed.

PR-URL: #8531
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
@sam-github
Copy link
Author

Thanks, @trevnorris

@sam-github sam-github deleted the check-process-kill-arg-type branch December 2, 2014 04:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants