Thomas VincentandTheWitness 90da94b94f fix(process): unify subprocess ownership and child lifecycle safety (#614)
## Summary

- make subprocess-registry detach atomic so exactly one closer owns each
entry
- make cancellation cleanup release only the detached node it owns
- replace `vfork`/`execve` child setup with `posix_spawn` and explicit
file actions
- mark every pipe and stdio-collision duplicate close-on-exec
- restore the child's default SIGPIPE disposition while preserving the
parent's handling
- bound TERM/KILL reaping and park unreaped children in a fixed-capacity
sweep list
- harden PHP script-server slot ownership, startup, restart, signal,
descriptor, and cleanup paths
- retire and restart failed or oversized reads so stale response tails
cannot poison later data sources
- revalidate every command retry and cap recovery handshakes at two
seconds

This folds the child-process lifecycle portion of #597 into the narrower
ownership PR. It does not absorb unrelated poll-host, SQL, SNMP, ICMP,
or build-infrastructure work.

## Review-driven corrections

- close-on-exec is explicitly restored after `dup()` in both read and
write stdio-collision branches
- the source invariant check now uses portable POSIX character classes
- direct tests cover duplicate flags, both collision branches, failure
after pipe creation, abandoned-child sweeping, and capacity overflow
- collision cleanup preserves current-child redirects even when an older
registry entry occupies fd 0 or 1
- script children receive SIGTERM before SIGKILL and unreaped PHP
children transfer to the bounded sweep registry
- the Docker integration suite now starts a real PHP script server,
verifies its startup protocol and database result, and checks that
shutdown leaves no zombie PHP process

## Validation

- Ubuntu 24.04 container with GCC and GNU ld: `make check`, 6/6 targets
passed with no skips, including `test_php_runtime`
- real PHP script-server Docker integration: 6/6 checks passed; exact
value `42` reached `poller_output` and no zombie remained
- macOS Homebrew dependency build passed
- macOS `make check`: 5/5 available binaries passed; GNU `--wrap`
runtime suite is Linux-only
- PHP fixture syntax checked through mise PHP 8.3
- actionlint, shellcheck, and `git diff --check` passed

Closes #610.

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Co-authored-by: TheWitness <thewitness@cacti.net>
2026-09-22 17:24:04 -04:00
2017-01-02 20:09:12 -05:00
2026-02-15 22:39:58 -05:00

Spine: a poller for Cacti

Spine is a high speed poller replacement for cmd.php. It is almost 100% compatible with the legacy cmd.php processor and provides much more flexibility, speed and concurrency than cmd.php.

Make sure that you have the proper development environment to compile Spine. This includes compilers, header files and things such as libtool. If you have questions please consult the forums and/or online documentation.


Unix Installation

These instructions assume the default install location for spine of /usr/local/spine. If you choose to use another prefix, make sure you update the commands as required for that new path.

To compile and install Spine using MySQL versions 5.5 or higher please do the following:

./bootstrap
./configure
make
make install
chown root:root /usr/local/spine/bin/spine
chmod u+s /usr/local/spine/bin/spine

To compile and install Spine using MySQL versions previous to 5.5 please do the following:

./bootstrap
./configure --with-reentrant
make
make install
chown root:root /usr/local/spine/bin/spine
chmod +s /usr/local/spine/bin/spine

Windows Installation

CYGWIN Prerequisite

  1. Download Cygwin for Window from https://www.cygwin.com/

  2. Install Cygwin by executing the downloaded setup program

  3. Select Install from Internet

  4. Select Root Directory: C:\cygwin

  5. Select a mirror which is close to your location

  6. Once on the package selection section make sure to select the following (TIP: use the search!):

    • autoconf
    • automake
    • dos2unix
    • gcc-core
    • gzip
    • help2man
    • inetutils-src
    • libmysqlclient
    • libmariadb-devel
    • libssl-devel
    • libtool
    • m4
    • make
    • net-snmp-devel
    • openssl-devel
    • wget
  7. Wait for installation to complete, coffee time!

  8. Move the cygwin setup to the C:\cygwin\ folder for future usage.

Compile Spine

  1. Open Cygwin shell prompt (C:\Cygwin\cygwin.bat) and brace yourself to use unix commands on Windows.

  2. Download the Spine source to the current directory:

    http://www.cacti.net/spine_download.php

  3. Extract Spine into C:\Cygwin\usr\src<spineversion>:

    tar xzvf cacti-spine-*.tar.gz

  4. Change into the Spine directory:

    cd /usr/src/cacti-spine-*

  5. Run bootstrap to prepare Spine for compilation:

    ./bootstrap

  6. Follow the instruction which bootstrap outputs.

  7. Update the spine.conf file for your installation of Cacti. You can optionally move it to a better location if you choose to do so, make sure to copy the spine.conf as well.

  8. Ensure that Spine runs well by running with /usr/local/spine/spine -R -S -V 3

  9. Update Cacti Paths Setting to point to the Spine binary and update the Poller Type to Spine. For the spine binary on Windows x64, and using default locations, that would be C:\cygwin64\usr\local\spine\bin\spine.exe

  10. If all is good Spine will be run from the poller in place of cmd.php.

Known Issues

  1. On Windows, Microsoft does not support a TCP Socket send timeout. Therefore, if you are using TCP ping on Windows, spine will not perform a second or subsequent retries to connect and the host will be assumed down on the first failure.

    If this is a problem it is suggested to use another Availability/Reachability method, or moving to Linux/UNIX.

  2. Spine takes quite a few MySQL connections. The number of connections is calculated as follows: (1 for main poller + 1 per each thread + 1 per each script server)

    Therefore, if you have 4 processes, with 10 threads each, and 5 script servers each your spine will take approximately:

    total connections = 4 * ( 1 + 10 + 5 ) = 64

  3. On older MySQL versions, different libraries had to be used to make MySQL thread safe. MySQL versions 5.0 and 5.1 require this flag. If you are using these version of MySQL, you must use the --with-reentrant configure flag.


Copyright (c) 2004-2026 - The Cacti Group, Inc.

S
Description
No description provided
Readme LGPL-2.1
6.8 MiB
0 Stars 1 Watchers 0 Forks
Languages
C 73.5%
Makefile 16.2%
Shell 8.3%
M4 1.7%
Roff 0.1%