简体   繁体   中英

Is there any way to change the data of a process from another one without using shared memory?

I am working on a fuse program, when a read() call in fuse is called, it will read the specific file A and save it to its buffer. In my case, I let fuse send a message to my program, and it retrieves data from remote server and save it to this file A, then fuse read this file to get the data.

I am wondering is there a way to let my program save the data right into the buffer of fuse, and avoid I/O operations. Does named pipe a good option? I mean does it store its data in the memory? Or could I change this buffer to a shared memory? I know how to create a shared memory, but do not know if I could convert it. It seems a privates one.

Thanks your guys.

Oh i think here you want to make some communication between two different process then the idea of IPC(Interprocess Communication) comes..

there are 5 ways of doing that

1 Shared memory permits processes to communicate by simply reading and writing to a specified memory location.

2 Mapped memory is similar to shared memory, except that it is associated with a file in the filesystem.

3 Pipes permit sequential communication from one process to a related process.

4 FIFOs are similar to pipes, except that unrelated processes can communicate because the pipe is given a name in the filesystem.

5 Sockets support communication between unrelated processes even on different computers.

i think here shared memory will be good option.

1> 1st declare some shared memory in your program then attache it with fuse

2> when fuse send a message then your program should get data from server 
and save it to that shared memory 

3> make some signaling methods(to avoid any race condition) so after that 
fuse can use that data 

Perhaps you could write into some mmap of /proc/1234/mem where 1234 is the pid of the target process, but I don't recommend doing that (and there are certainly permission issues). And that still becomes a weird (and Linux specific) way of sharing memory. (I am not sure it should work).

But Mr32's answer is more appropriate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM