Reputation: 43558
I m developing an application in which I launch a fork to execute a child process.
In the child process I want to create a linked list with many nodes and each node should created with malloc()
and then copy the linked list to the parent. because the linked list is created only in the child and it does not exist in the parent.
How to do it ?
Upvotes: 0
Views: 541
Reputation: 321
Ed is right, shared memory is the answer. On non-Windows just do man shmget or here's a good reference: http://www.cs.cf.ac.uk/Dave/C/node27.html
Upvotes: 1
Reputation: 400029
You must use some inter-process communications method, like shared memory, pipes, files on disk, sockets, and so on. Since processes are typically isolated from each other, you can't just pass the pointers around.
Upvotes: 2