cp: Support copying FIFOs with -r #3032
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request handles the GNU test
cp/special-f
, which usescp -R fifo e
to copy a FIFO.I noticed that this test was not only failing, but taking about 4 minutes to fail, which is an appreciable amount of the total test suite time. If I understand this correctly, uutils ignored the
-r
flag and tried to copy the contents of the (empty) FIFO instead of the FIFO itself; it kept waiting for something to read until eventually timing out.Since Rust doesn't natively support copying FIFOs (see issue #1710), I implemented this by creating a new FIFO with the destination name. There's definitely room to improve on this (e.g. copying file permissions), but I experimented a bit and it doesn't seem like GNU's copies are much more than new instances, so I don't think this is too bad.
I'm still pretty new to this project and Rust in general, so let me know if there's a better way to go about this. I'm happy to either revise this PR or close it and create an issue if you'd prefer to solve this another way 🙂