Miguel Guerra
Miguel Guerra

Reputation: 165

Using malloc to communicate between parent and child

If I ask for memory size of an int from malloc and I create 'n' child processes from one parent. Is it posible for each child to update(add one) the value inside that memory, so by the end the parent process reads the value?

Upvotes: 1

Views: 231

Answers (1)

sg7
sg7

Reputation: 6298

No, there is no common memory between child and parent. To have a communication between child and parent you could use:

Shared memory // All POSIX systems, Windows

Pipes , (Example of Named Pipes) , Pipe tutorial // All POSIX systems, Windows

FIFO files // Most operating systems

sockets // Most operating systems

For more information on other methods check the Inter-process communication

Upvotes: 5

Related Questions