Skip to content

Preserve shared and cyclic descriptors when remapping child standard streams #558

Closed

Description

@LunaStev

proc_spawn_exec_raw remaps stdin, stdout and stderr sequentially. _proc_dup_child_fd closes each source fd immediately after dup2. Passing the same nonstandard fd for both stdout and stderr therefore closes it after the first mapping; the second dup2 uses a closed fd and the child exits with PROC_EXIT_DUP_FAIL. Mappings that swap standard descriptors can also overwrite a source before it is used.

Combining stdout/stderr onto one pipe is a normal subprocess use case.

Code evidence:

Acceptance:

  • Plan remapping before closing descriptors, preserving sources required by later mappings and using temporary duplicates for cycles where needed.
  • Cover shared stdout/stderr, a stdin/stdout swap, identity mappings and disabled (-1) mappings.
  • Close each no-longer-needed descriptor exactly once and clean up temporary duplicates on failure.
  • Keep parent-owned descriptors and native Unix process behavior intact; Add native Windows process spawning and waiting APIs #429 handles the separate Windows spawning implementation.

Audit status: static source inspection against canonical master ea74c2dafc31da876e5561f2d176ba719f5a0458 on 2026-09-10. No compiler build, test execution, implementation change or local reproduction was performed for this report. The examples describe the source-derived behavior to verify when implementing the fix.

Activity

  1. added
    bug
    help wanted
    on Sep 10, 2026
  2. LunaStev commented on Sep 12, 2026

    @LunaStev
    MemberAuthor

    PR #606's Linux amd64 case precheck uncovered a remaining integration regression: test13.wave still imports the removed _proc_dup_child_fd helper. This is now tracked by #607. A read-only audit of all 605 manifest sources found exactly this one check failure; the other 604 sources passed.

    Failing Linux job. The precheck stops before the native case runner, so its case report is absent. The independent workflow aggregation/reporting problem is tracked by #610. The existing case should be retained and its import reconciled with the revised helper surface.

  3. added a commit that references this issue on Sep 12, 2026
    3950416
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

    bughelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions