Skip to content

Stdlib: proc_get_status() — must expose command argv array and running/exitcode fields (ext/standard/exec.c) #9311

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

proc_get_status() after proc_open() with an argv array command must report metadata matching Zend: command as the invoked path, pid > 0, running boolean, exitcode while running, etc. This compiler returns partial/inconsistent hashes compared to php-src; callers relying on command/exitcode break.

Workers need a focused parity slice on the VM VmProcess path before JIT lowering (#8889).

php-src reference

Repro

cat > /tmp/repro_proc_get_status.php <<'PHP'
<?php
$desc = [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']];
$proc = proc_open(['/bin/echo', 'hi'], $desc, $pipes);
$st = proc_get_status($proc);
var_dump($st['command'] ?? null, $st['running'] ?? null, isset($st['pid']));
proc_close($proc);
PHP
./script/docker-exec.sh -- bash -lc 'php /tmp/repro_proc_get_status.php; php bin/vm.php /tmp/repro_proc_get_status.php'

Audit all keys Zend returns (command, pid, running, exitcode, signaled, stopped, termsig, stopsig) and file sub-issues for any remaining drift.

Scope (PHP-in-PHP)

Layer Path
VM ext/standard/VmProcess.php, proc_get_status.php
Process handles ensure array-command proc_open stores argv for status
JIT defer — VM parity first
Tests test/compliance/cases/stdlib/proc_get_status_argv.phpt

Done when (php-src-strict)

  • Repro array keys/values match Zend immediately after proc_open
  • After child exits, running false and exitcode populated
  • String-command form still works
  • No VM warnings on well-formed $pipes out-param

Related

Activity

  1. added
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 17, 2026
  2. PurHur commented on Jun 19, 2026

    @PurHur
    OwnerAuthor

    Implementation-ready expansion — verified running drift (2026-06-19)

    Docker probe with argv-array proc_open:

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    cat > /tmp/repro_proc_get_status.php <<'"'"'PHP'"'"'
    <?php
    $desc = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => ["pipe", "w"]];
    $proc = proc_open(["/bin/echo", "hi"], $desc, $pipes);
    $st = proc_get_status($proc);
    var_export($st["command"] ?? "MISSING");
    echo "\n";
    var_export($st["running"] ?? "MISSING");
    echo "\n";
    proc_close($proc);
    PHP
    php8.2 /tmp/repro_proc_get_status.php
    php bin/vm.php /tmp/repro_proc_get_status.php
    '
    Field Zend PHP 8.2+ (child still alive) VM today
    command '/bin/echo' '/bin/echo' ✓
    running true false ❌
    pid key present yes yes

    Root cause likely in ext/standard/VmProcess.php / proc_get_status.php: process handle metadata not marking child as running immediately after spawn, or premature reap.

    Done when (expanded)

    • running === true while child has not exited (repro above)
    • After proc_close, a fresh proc_get_status is invalid/warns per Zend (or final status fetch shows running=false, exitcode=0)
    • String-command proc_open('echo hi', …) same shape
    • test/compliance/cases/stdlib/proc_get_status_argv.phpt committed
    • ./script/ci-fast.sh --filter proc_get_status green

    Scope reminder

    PHP-in-PHP: fix in ext/standard/VmProcess.php — no new runtime/*.c process tables. JIT defer (#9408).

  3. PurHur commented on Jul 3, 2026

    @PurHur
    OwnerAuthor

    Merged via PR #15527.

    Fix: VmProcessProcOpenNative::openArgv() stores argv[0] as proc_get_status()['command'] (was implode(' ', $argv)).

    Verification (2026-07-03):

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    php bin/vm.php test/repro/maintainer_gap_proc_get_status_argv.php
    php bin/vm.php test/compliance/cases/stdlib/proc_get_status_argv.phpt'

    Both print ok / cmd-ok + running + has-pid. Issue repro now matches Zend (command='/bin/echo', running=true).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions