Class: Sys::Proc::System::LinuxGnu::Prctl

Inherits:
Object
  • Object
show all
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

Instance Method Details

#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.

Returns:

  • (Fixnum)


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

#getprognameString

Return the name of the calling thread

Returns:

  • (String)


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

Parameters:

  • name (String)

Returns:

  • (Boolean)


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