Skip to content

Improvements across process management utilities#7

Merged
rcalicdan merged 1 commit intohiblaphp:mainfrom
jeffreybulanadi:dev
May 5, 2026
Merged

Improvements across process management utilities#7
rcalicdan merged 1 commit intohiblaphp:mainfrom
jeffreybulanadi:dev

Conversation

@jeffreybulanadi
Copy link
Copy Markdown
Member

@jeffreybulanadi jeffreybulanadi commented May 5, 2026

Closes #5

Changes in this PR:

ProcessKiller

  • Build the child map once in killTreesUnixMapped() and pass it to collectDescendants() instead of rebuilding it per PID
  • Convert killTreesUnixFallback() from recursive to iterative using an explicit queue, preventing potential stack overflow on deep process trees
  • Add missing space before array literal in return statement in buildProcMaps()

SystemUtilities

  • Replace substr_count + 1 with preg_match_all('/^processor/m') for CPU count from /proc/cpuinfo, which handles edge cases around the first processor entry correctly

ExceptionHandler

  • Replace assert() type narrowing with real conditional checks so behavior is consistent regardless of assertion configuration
  • Reuse a single ReflectionObject instance across setExceptionLocation() and appendWorkerStackTrace() instead of creating two separate instances

ProcessSpawnHandler / ProcessManager

  • Add final keyword to both classes, which are already marked @internal

BackgroundProcess

  • Replace strpos() !== false checks with str_contains() in isRunning()

ProcessPool

  • Use PoolShutdownException instead of RuntimeException when rejecting tasks on a shut-down pool
  • Note the rejection type in the run() docblock

functions.php

  • Detect objects inside arrays in emit() using array_walk_recursive, so arrays containing objects are serialized correctly instead of producing empty JSON objects

phpstan.neon

  • Pin phpVersion to 8.4 so local analysis targets the same version as CI

Copy link
Copy Markdown
Member

@rcalicdan rcalicdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fantastic! Thank you for following up so quickly. The implementations here are excellent and especially the use of array_walk_recursive() to solve the emit() array serialization gap (very clean and performant), and the iterative queue refactor in ProcessKiller. You addressed all the agreed-upon points perfectly while respecting the constraints we discussed. I'm approving and merging this now. Thanks again for your contribution to the Hibla ecosystem!

@rcalicdan rcalicdan merged commit 459ed63 into hiblaphp:main May 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvements identified in codebase review

2 participants