Calling stop_packages from system_reboot_cleanup in

  • When I shutdown the following comes out on the console when stopping services and packages:

    pfSense is rebooting now.
     Stopping package blinkled...done.
     Stopping package pfBlocker...done.
    Syntax error: Bad fd number

    I am ignoring "Bad fd number" for now - it seems an intractable problem with popen() and pclose().
    The code in function stop_packages really intends to call rc*.sh files in the dir defined by the definition in
    $rcfileprefix = "/usr/local/etc/rc.d/";
    But it is actually calling ones it finds in "/etc" - which appears to be it's default dir at the time.
    $rcfileprefix is not getting defined globally in this context. only does a require_once inside the system_reboot_cleanup routine. That only makes a local scope definition of $rcfileprefix.
    The way that stop_packages is called from /etc/rc.stop_packages works. The require_once is in the very top, in a global context where the definition gets made globally by default.
    This global variable business is quite mixed up - has 3 times:
    One way to fix this is to add to the top of
    global $rcfileprefix;
    Then the definition straight after will always be global. Everything that uses it would have to also declare it global.
    But I suspect that it would be better to sort out the whole relationship between use of require_once in different places and use of global variables.

Log in to reply