Skip to content

bug: libobs/util: with ENABLE_RUST_LIBOBS=ON, os_process_pipe_create drops the inherited standard stream on POSIX #485

Closed

Description

@chriscoveries

Summary

With ENABLE_RUST_LIBOBS=ON, os_process_pipe_create and os_process_pipe_create2 replace the child's unpiped standard stream with /dev/null. The C implementation leaves it as the parent's own descriptor. A helper started in read mode that reads stdin, or in write mode that prints to stdout, behaves differently depending on the build flag. Severity: low to medium. It only affects children that use the unpiped stream, but it is a silent behaviour change from the C reference.

Steps / trigger

On macOS or Linux, with the parent's stdin and stdout redirected to files or pipes:

  1. os_process_pipe_create("cat", "r") and read from the pipe. Stdin is not piped in read mode, so cat should read the parent's stdin.
  2. os_process_pipe_create("echo OUT", "w") and close the pipe. Stdout is not piped in write mode, so OUT should reach the parent's stdout.

OFF delivers the data in both cases. ON delivers nothing: the child sees EOF on stdin, and its stdout is discarded. os_process_pipe_create2 behaves the same way.

Cause

Line numbers are against current master.

  • C reference, libobs/util/pipe-posix.c:76-88: in read mode only stdout is redirected, in write mode only stdin. The other stream is untouched, so posix_spawn lets the child inherit it. Stderr is always piped (:90-94).
  • rust/obs-util/src/platform/unix/pipe.rs:37 and :39: the Rust spawn sets Stdio::null() for the unpiped stream (stdin in read mode, stdout in write mode). The comment at :41 only mentions stderr.

Proposed fix

In spawn, pipe only the stream the mode needs (stdout in read mode, stdin in write mode) and leave the other at Command's default, which inherits the parent's descriptor. Stderr stays piped in both modes. C needs no change. The regression test is a POSIX cmocka test with four cases (create and create2, read and write mode) that passes today with OFF and fails with ON, then passes with both after the fix.

I'd like to work on this; a fix with a regression test is ready.

Activity

  1. zackees commented on Oct 13, 2026

    @zackees
    Member

    @chriscoveries go ahead: please open the PR with the RED test commit first, then the fix (one PR per issue, targeting master). Marking it claimed for you so nobody duplicates it.

  2. added
    claimed
    on Oct 13, 2026
  3. chriscoveries commented on Oct 14, 2026

    @chriscoveries
    ContributorAuthor

    Releasing this one. We're backed up on CI and won't get it landed soon, so anyone who wants it is welcome to take it.

    If it helps, our RED test and fix are on the fork branch fix/pipe-stdio-inherit-parity. They passed review on our side but haven't been through CI, so reuse them or start fresh, whichever you prefer.

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

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions