Comments (9)
Can you give more details why a fork should be used instead of executing separate binaries?
Due to two facts:
- because memmap crate not offering any way to create a named shared memory region (like shm_open). All it provides is a way to mmap a file or create an anonymous memory mapped region. First not being suitable for robust ipc and the second being reachable only from the creating process and it's children
- skeptic test runner not supporting orchestrating multi file/binary tests ;)
from rust-cookbook.
Any idea how such example would look like?
The canonical example would normally utilize fork to spawn a child process and communicate via mmap.
import mmap
import os
mm = mmap.mmap(-1, 13)
mm.write("Hello world!")
pid = os.fork()
if pid == 0: # In a child process
mm.seek(0)
print mm.readline()
mm.close()
But in Rust we do not have a stable fork API (the nix crate provides such functionality but it is not cross platform which defeats the purpose of "cross-platform" part in this example).
from rust-cookbook.
The canonical example would normally utilize fork to spawn a child process
Can you give more details why a fork
should be used instead of executing separate binaries?
from rust-cookbook.
I'm interested in working on this and would like to claim it. Which platforms should be supported?
from rust-cookbook.
Hi @steveej, thanks for taking an interest.
Which platforms should be supported?
Its supposed to be cross platforms so at least all of rust tier 1 platforms
Please note that at this moment the example is not well defined (as not clear how should it be implemented to be both cross platform and idiomatic) so please post the implementation idea before starting to work on it so you'll not lose time.
from rust-cookbook.
because memmap crate not offering any way to create a named shared memory region (like shm_open).
I wonder why that was left out. Maybe it should just be added so this example becomes possible.
All it provides is a way to mmap a file or create an anonymous memory mapped region.
First not being suitable for robust ipc
Would you mind to elaborate on this statement?
from rust-cookbook.
I wonder why that was left out.
Well we can always ask on their bugtracker ;) Possibly the semantics differ between windows and unix enough to make providing common and ergonomic api a pain.
Would you mind to elaborate on this statement?
On some systems trying to do ipc on standard memory mapped file would be no better than doing ipc on normal file read/write operations to the filesystem, on the other hand boost interprocess fallsback to shmem emulation via mapped fs files if there is no support for shared memory objects but this is hidden as an implementation detail and I feel that this would not be something we would like to teach our readers as a go-to solution.
It would be great to hear authors thoughts on the matter. Ping @danburkert :)
from rust-cookbook.
memmap
is, to date, just a wrapper around mmap
and the closest corresponding Windows APIs. We had a PR at one point to add shared memory support, but it never landed. I'm lukewarm on expanding the scope to include shared memory; unless it can be done in a minimally invasive way I think it would be better in a dedicated crate.
from rust-cookbook.
Thanks a lot for your thoughts! I think that it's best to just close this issue as it is not cleanly implementable with current crates ecosystem.
from rust-cookbook.
Related Issues (20)
- Indexing a map with a non-Copy structural key
- Replace lazy_static with once_cell
- Text refers to "Expand" button, actually it's "Show hidden lines"
- The header for the bitfield page is incorrect
- querying-the-web-api examples don't work due to missing user-agent-headers
- `GUI` create‘s introduce and contrast
- Use clap-derive instead of raw clap for argument parsing HOT 1
- 3.1 Decompress a tarball while removing a prefix from the paths with E0107 HOT 1
- Some documents are unavailable
- Mime crate badges show CSV's version HOT 1
- Missing (hard to find?) edit link to github
- Add recipe to building custom format-like macros
- Is this repo abandoned? HOT 5
- Bug: Sample Code Doesn't Work
- replace crossbeam's scoped threads with std's scoped threads
- Dead links in Mathematics section
- rusqlite first example does not compile HOT 2
- clap-basic.md is stale, wrong
- Clap basic got a wrong demo
- update Log Messages/Configure Logging sections 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 rust-cookbook.