Created
June 19, 2014 22:28
-
-
Save skolf/f70bce603d5241fc707e to your computer and use it in GitHub Desktop.
An extension to the Ruby Process module for checking if a given process is running.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # usage: Process.alive? 1 | |
| # > true | |
| module Process | |
| class << self | |
| def alive?(pid) | |
| return false if pid.nil? | |
| begin | |
| Process.kill(0, pid.to_i) | |
| status = true | |
| rescue Errno::ESRCH | |
| status = false | |
| end | |
| return status | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment