I’m working on a simple secure temporary file crate (https://github.com/Stebalien/tempfile) and need to test it on macos (and freebsd if possible). Specifically, I’m worried that the second test case might fail.
/tmp/tempfile % cargo test Compiling tempfile v0.0.1 (file:///private/tmp/tempfile) Running target/debug/tempfile-e22d6c55321fc688 running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured Running target/debug/test-08f06f97d4c25b9c running 2 tests test test_basic ... ok test test_share ... FAILED failures: ---- test_share stdout ---- thread 'test_share' panicked at 'assertion failed: `(left == right)` (left: `"abcde"`, right: `""`)', tests/test.rs:22 failures: test_share test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured thread '<main>' panicked at 'Some tests failed', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libtest/lib.rs:260
Judging by a manual test, it looks like fds ‘duplicated’ with /dev/fd share their offset value here.
That’s unfortunate. Can you tell if they just start off with the same offset or share it permanently?
They share it permanently. The relevant code is the call to
Thanks for looking into this. I ended up just dropping support for re-opening temporary files on macos.