Class: Sys::Proc::System::Freebsd::LibC

Inherits:
Object
  • Object
show all
Includes:
Concern::Helper
Defined in:
lib/sys/proc/system/freebsd/lib_c.rb

Overview

The getprogname() and setprogname() functions manipulate the name of the current program. They are used by error-reporting routines to produce consistent output.

These functions first appeared in NetBSD 1.6, and made their way into FreeBSD 4.4.

Instance Method Summary collapse

Instance Method Details

#getprognameString

Return the name of the program.

If the name has not been set yet, it will return NULL.

#include <stdlib.h>

const char * getprogname(void);

Returns:

  • (String)


54
55
56
# File 'lib/sys/proc/system/freebsd/lib_c.rb', line 54

def getprogname
  function('getprogname', nil, Fiddle::TYPE_VOIDP).call.to_s
end

#setprogname(progname) ⇒ Boolean

Sets the name of the program to be the last component of the progname argument.

Since a pointer to the given string is kept as the program name, it should not be modified for the rest of the program's lifetime.

#include <stdlib.h>

void setprogname(const char *progname);

Returns:

  • (Boolean)


37
38
39
40
41
# File 'lib/sys/proc/system/freebsd/lib_c.rb', line 37

def setprogname(progname)
  function('setprogname', [Fiddle::TYPE_VOIDP]).call(progname.to_s)

  true
end