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

Process.new(-1).exists? returns true in Linux #4197

Closed
joaodiogocosta opened this issue Mar 27, 2017 · 2 comments
Closed

Process.new(-1).exists? returns true in Linux #4197

joaodiogocosta opened this issue Mar 27, 2017 · 2 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Milestone

Comments

@joaodiogocosta
Copy link
Contributor

While trying to initialize a variable that represents a pid to something I thought was safe (an Integer that could never be a valid pid), I ended up killing my VM by doing:

pid = -1 # Invalid pid
Process.new(pid).exists? # returns true
Process.new(pid).kill # kills all processes in my Linux VM

Then I found that kill -9 -1 also kills my Linux VM. Possibly related Stack Overflow thread.

Even if Process.new(-1).kill is intended behaviour, should Process.new(-1).exists? return true?

@mverzilli mverzilli added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib labels Mar 28, 2017
@asterite
Copy link
Member

The initialize method of Process is defined as protected, but that's the default visibility status, so that new becomes public. It's probably a bug in the compiler. I will mark it as private. You shouldn't be able to instantiate a process by pid like that.

@asterite asterite added this to the Next milestone Mar 30, 2017
@zatherz
Copy link
Contributor

zatherz commented Mar 30, 2017

Just to provide more context on why this had the effect that it had - PID -1 is a special case. Trying to kill it results in everything except the kill process itself and init being killed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Projects
None yet
Development

No branches or pull requests

4 participants