LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   fork() in c++ (https://www.linuxquestions.org/questions/programming-9/fork-in-c-253655/)

deveraux83 11-11-2004 11:21 AM

fork() in c++
 
Hi all!

I'm trying to learn how to use fork() in linux as it is useful for a project I'm currently working on. My problem however is that I don't quite know how to allow the two separate processes from talking to each other, since they're memory spaces are recreated and hence are not shared. Is there anyway of allowing them to talk to each other, short of using files?

Thanks!

itsme86 11-11-2004 11:59 AM

Check out the pipe() function. Open the pipe before you fork(), then the two processes can communicate via the pipe.

perfect_circle 11-11-2004 04:50 PM

reading/ writing files, is also an option but I/O requests are slow.
I you still want to proceed with this, use fcntl to lock the files

karlan 11-11-2004 05:01 PM

these tutorials will make your day: http://www.ecst.csuchico.edu/~beej/guide/

deveraux83 11-12-2004 06:58 PM

Thanks a bunch guys! Oh and Karlan, that site was great, thanks again!

karlan 11-13-2004 03:12 PM

i reccomend the sockets tutorial, networking programming is such fun


All times are GMT -5. The time now is 05:17 AM.