Class: Sys::Proc::System::LinuxGnu::Prctl
- Inherits:
-
Object
- Object
- Sys::Proc::System::LinuxGnu::Prctl
- Includes:
- Concern::Helper
- Defined in:
- lib/sys/proc/system/linux_gnu/prctl.rb
Overview
Operations on a process
#include <sys/prctl.h>
int prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5);
Constant Summary collapse
- PR_SET_NAME =
Set the name of the calling threadThe attribute is likewise accessible via /proc/self/task/[tid]/comm, where tid is the name of the calling thread.
15
- PR_GET_NAME =
Return the name of the calling thread, in the buffer pointed to by (char *) arg2. The buffer should allow space for up to 16 bytes; the returned string will be null-terminated.
16
Instance Method Summary collapse
-
#call(*args) ⇒ Fixnum
prctl() is called with a first argument describing what to do (with values defined in
), and further arguments with a significance depending on the first one. -
#getprogname ⇒ String
Return the name of the calling thread.
-
#setprogname(name) ⇒ Boolean
Set the name of the calling thread.
Instance Method Details
#call(*args) ⇒ Fixnum
prctl() is called with a first argument describing what to do (with
values defined in
61 62 63 64 65 |
# File 'lib/sys/proc/system/linux_gnu/prctl.rb', line 61 def call(*args) args += ([0] * 5).slice(args.size..-1) function.call(*args) end |
#getprogname ⇒ String
Return the name of the calling thread
49 50 51 52 53 54 |
# File 'lib/sys/proc/system/linux_gnu/prctl.rb', line 49 def getprogname ptr = Fiddle::Pointer.malloc(32, Fiddle::RUBY_FREE.to_i) call(PR_GET_NAME, ptr.to_i) ptr.to_s end |
#setprogname(name) ⇒ Boolean
Set the name of the calling thread
40 41 42 43 44 |
# File 'lib/sys/proc/system/linux_gnu/prctl.rb', line 40 def setprogname(name) name = name.to_s call(PR_SET_NAME, name).zero? end |