Created
December 30, 2015 13:28
-
-
Save sideshowcoder/8057955257e645b7058a to your computer and use it in GitHub Desktop.
Setting the ruby process name
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
| class ProcessCtrl | |
| module LibC | |
| PR_SET_NAME = 15 | |
| extend FFI::Library | |
| ffi_lib "c" | |
| attach_function :prctl, [:int, :pointer, :long, :long, :long], :int | |
| end | |
| class << self | |
| def set_process_name(name) | |
| # The process name is max 16 characters, so get the first 16, and if it is | |
| # less pad with spaces to avoid formatting wierdness | |
| process_name = "%-16.16s" % name | |
| LibC.prctl(LibC::PR_SET_NAME, process_name, 0, 0, 0) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment