Project

General

Profile

Actions

Feature #9842

closed

system configuration variables (sysconf(), confstr(), pathconf() and fpathconf())

Added by akr (Akira Tanaka) almost 10 years ago. Updated almost 10 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:62600]

Description

How about providing methods to obtain system configuration variables?

POSIX defines sysconf(), confstr(), pathconf() and fpathconf().
I implemented following methods in ext/etc.

  • Etc.sysconf(name)
  • Etc.confstr(name)
  • IO.pathconf(name)
  • IO#pathconf(name)

POSIX defines some names.
Various operating sysmtems define additional names.

They can be used as follows:

Etc.sysconf(Etc::SC_ARG_MAX) #=> 2097152
Etc.sysconf(Etc::SC_NPROCESSORS_ONLN) #=> 4
Etc.confstr(Etc::CS_PATH) #=> "/bin:/usr/bin"
Etc.confstr(Etc::CS_GNU_LIBC_VERSION) #=> "glibc 2.18"
IO.pathconf("/", Etc::PC_NAME_MAX) #=> 255
open("/") {|f| p f.pathconf(Etc::PC_TIMESTAMP_RESOLUTION) } #=> 1

I implemented them in ext/etc because I interpreted "etc" as
system configuration.

Any idea?


Files

sysconf-confstr-pathconf.patch (13 KB) sysconf-confstr-pathconf.patch akr (Akira Tanaka), 05/15/2014 11:43 AM
sysconf-confstr-fpathconf.patch (12.1 KB) sysconf-confstr-fpathconf.patch akr (Akira Tanaka), 05/16/2014 01:22 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0