Reputation: 91
I have used fork() to create 2 different processes operating on 2 different address spaces. Now, in parent process I need the value of a variable from child's address space or if the child process can modify the variable in parent's address space. Is this possible?
Upvotes: 3
Views: 245
Reputation: 233
As you have created two process using fork command Both Process will be in different address space so they will only communicate by IPC, message passing ,Piping , Shared Memory etc. otherwise one process can't access other process data as thay do have Process specific data and similarly threads also have thread specific data
Upvotes: 0
Reputation: 56479
If you mean exchanging data between these two processes you can not. You can do it by system APIs like SharedMemory, Message Passing, Pipeline, Socket, ...
Upvotes: 2
Reputation: 67829
Once you have two processes, sharing data needs interprocess communication: file, pipe or shared memory.
Upvotes: 2
Reputation: 881403
No, once you've forked, each process gets its own address space and you'll have to look into either:
Upvotes: 5