sysctl ???

Joshua Root jmr at macports.org
Wed Apr 17 03:09:53 PDT 2013


On 2013-4-17 19:49 , Vincent Habchi wrote:
> Hi there,
> 
> is Macports overriding the standard Tcl ‘sysctl’ call?

There is no "standard Tcl ‘sysctl’ call". The sysctl proc you can call
from portfiles is defined in src/macports1.0/sysctl.c. It's just a thin
wrapper around sysctlbyname(3) to make it available from Tcl.

> I’m getting strange outputs:
> 
> Macmini > tclsh
> % catch {sysctl -n hw.machine} result
> x86_64
> 0
> %

I think tclsh runs unknown commands by passing them to sh. So this would
be equivalent to just running "sysctl -n hw.machine" in your shell. (No
idea how the interaction with Tcl procs works exactly, though.)

> but this code in Macports:
> 
>     if {![catch {sysctl hw.machine} result]} {
>         set native_arch ${result}
>         puts ${result}
>     }
> 
> reports ‘32767’
> 
> How come?

Probably because someone (cough) only implemented support for
CTLTYPE_INT and CTLTYPE_QUAD in the function...

- Josh


More information about the macports-dev mailing list