Comments (3)
It may be silly but rustix
could be cleaver and just have one API:
pub fn dup<Fd: AsFd>(fd: Fd, into: Option<&OwnedFd>, flags: DupFlags) -> Result<()>
This would handle the 4 functions at once:
With the sale behavior of dup3
if the two file descriptor are equal.
from rustix.
What would be in DupFlags
? I think fnctl_dupfd_cloexec
really wants to take a RawFd
and not an Option<&OwnedFd>
for the lower bound for example.
It seems hard to avoid some...dup
lication here; I think I'd lean more towards having the API match the Linux system calls, and just ensuring the documentation makes things clear.
from rustix.
I'm leaning that way too. These functions are all superficially similar, but they have different use cases: "I want a copy of this fd with an independent lifetime" vs. "I want to overwrite this existing fd with something else". We'll eventually have different documentation for these different use cases. It's also nice if we can avoid having applications transitively depend on system calls they aren't using, where feasible.
FreeBSD also has a dup3
which follows the Linux behavior. So I'm leaning towards just renaming rustix's dup2_with
to dup3
and just documenting that. Rustix sometimes tries to present things in more intuitive ways, but in this case, there are enough variations with enough subtle behavioral differences that there's a risk we'd just make it even more confusing if we tried to simplify.
from rustix.
Related Issues (20)
- `u32` struct fields in place of file descriptors HOT 2
- Add signalfd support HOT 1
- Build failure for i686-unknown-hurd-gnu HOT 2
- Failed to build on LoongArch
- Support for HermitOS
- missing getifaddrs
- Thoughts on higher level APIs? HOT 3
- Misleading name of `ioctl::BadOpcode` HOT 1
- [Feature Request]: Cargo 3DS support HOT 1
- Mount syscall has wrong parameters
- Start work on rustix 1.0
- waitpgid discards valuable information
- Several compilation issues on uClibc targets in version 0.38.28. HOT 2
- Version 0.38.29 fails to build on Linux HOT 1
- Add ClockId::try_from
- waitpid doesn't returned pid HOT 4
- Build errors for i686-apple-darwin HOT 1
- Add support for pidfd_send_signal
- `proc_self_status` fails on second invocation HOT 1
- add io_uring_sqe64,io_uring_sqe128,io_uring_cqe16,io_uring_cqe32 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rustix.