switch from `IntoRawFd` to `Into<OwnedFd>` (take two) #123
<!-- codex-pull-request-review-summary -->
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-09-20T17:35:42.734905Z">2026-09-20T17:35:42.734905Z</relative-time> | 1103af5 | PR opened |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
</details>
<sub><sub>!P1 Badge</sub></sub> Preserve raw descriptor support in redirection APIs
For callers passing a Unix RawFd, Windows RawHandle, or another type that only implements IntoRawFd/IntoRawHandle, this new bound no longer compiles because those types do not necessarily implement Into<OwnedFd>/Into<OwnedHandle>. This breaks the existing public contract of stdin_file, stdout_file, and stderr_file for downstream users in a non-major release; retain a compatible conversion path or defer the API change to a major version.
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1103af5632
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
yeah that's the whole point
Note: This comment was written and posted by Codex on behalf of @oconnor663.
crates.io compatibility audit
Bottom line: at the caller-source level, I found no published, unyanked crate that can automatically resolve a prospective duct 1.1.3 and has an active call broken by this PR. (There is one direct dependency-floor cleanup I recommend on the branch, noted below.)
Coverage
stdin_file, stdout_file, and stderr_file. I also checked likely macro-generated spellings.xx documentation for an unrelated API, the scan found 410 actual duct call expressions across 87 published releases, all belonging to five crate families. They pass only:-
std::fs::File (pitchfork-cli), or-
os_pipe::PipeReader / PipeWriter (cargo-mobile2, tauri-cli, tessera-mobile, and verctl).cargo check on the relevant targets of the current releases of all five using the code from this PR's exact commit (1103af5632d37e028b51248b770053445bfc3680): cargo-mobile2 0.22.5, pitchfork-cli 2.27.0, tauri-cli 2.11.5, tessera-mobile 0.0.0, and verctl 0.3.1. All passed. (For pitchfork-cli's ^1.1.2 constraint, I locally labeled the same code 1.1.3.) Separate focused probes with File, PipeReader, and PipeWriter passed for both x86_64-unknown-linux-gnu and x86_64-pc-windows-gnu.This cannot say anything about private, unpublished, or git-only dependents, which might still use one of the raw-descriptor patterns below.
One structurally incompatible generic caller
shadowsocks-gtk-rs 0.4.1 has a helper whose parameters are Option<impl IntoRawFd> and forwards those generic values to stdout_file / stderr_file. That helper definition fails under the new bound, because IntoRawFd does not imply Into<OwnedFd>.
However, that crate requires duct ^0.13.5, so it cannot resolve to this duct 1.x change. It is a useful concrete warning if this is ever backported to 0.13, but it is not an upgrade break from publishing 1.1.3.
I also found click 0.6.3 passing an os_pipe::PipeReader while its published lockfile uses os_pipe 1.1.4 without the io_safety feature, so the owned-FD conversion is not enabled. Its open os_pipe = "1" requirement can re-resolve to 1.2+, and it likewise requires duct 0.13, so it is not reachable from this release; it is another backport/minimum-version edge case.
More generally, the newly rejected Unix patterns are raw RawFd/i32 values, results of as_raw_fd() or into_raw_fd(), custom types that implement only IntoRawFd, and generic forwarding APIs bounded only by IntoRawFd. That is the intended ownership tightening. On Windows, RawHandle itself was never accepted by the old IntoRawHandle bound, so it is not a newly broken case; custom/generic IntoRawHandle-only values are.
One branch follow-up
I recommend raising the direct os_pipe = "1.0.0" dependency to at least 1.2.0. The conversions this branch now uses are absent in os_pipe 1.0.x and gated by io_safety in 1.1.x; they are unconditional in 1.2+. The current shared_child -> sigchld dependency graph already forces os_pipe >=1.2.2, so this is not an observed failure today, but duct should declare the minimum its own source requires instead of relying on that transitive constraint.
This change also does not appear to raise duct's effective MSRV: std::os::fd requires Rust 1.66, while the OnceLock usage already present in duct requires Rust 1.70.
Based on the Codex audit above, I'll probably ship this as a patch release, instead of creating a v2 just for this. Of note is the fact that RawHandle never implemented IntoRawHandle on Windows. I didn't know that.
Re: os_pipe, I'll probably just remove the dependency in a followup commit. (Edit: Never mind, I do use the dup_stdout etc. functions that aren't in the standard library.)
oconnor663
Previously I made but then reverted this change, because it breaks
callers who pass in
RawFd. That's both a bug and a feature: you canget a
RawFdfrom.as_raw_fd()without having ownership of aFile.That makes this change both a bugfix and a compatibility break. That
said, Codex couldn't find any public callers that would actually break:
https://github.com/oconnor663/duct.rs/pull/123#issuecomment-5751618415