mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-09-22 00:02:23 +00:00
`StdioDuplex::take` dup'd stdin and stdout, redirected both to /dev/null, and only then wrapped the raw descriptors in `File`. Any of the four `?`s between the first `dup` and the wrap returned without closing what it already held — a descriptor leak on the error path. `dup_fd` now hands back an `OwnedFd`. `dup` returns a fresh descriptor nothing else holds, which is exactly that type's contract, and ownership from the moment it exists is what makes the early returns safe. `take` drops two `unsafe` blocks in the process: `File::from(OwnedFd)` is the safe conversion. Immaterial in production — `take` is called once in tty7-server's main and the `?` there exits the process — but it is unsafe-adjacent code where the correct version is also the shorter one. Exercised by the 55 `stdio_conformance` tests, which drive `tty7-server --stdio` through this constructor. 2934 pass.