LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-11-2004, 11:21 AM   #1
deveraux83
Member
 
Registered: Jul 2003
Location: Malaysia
Distribution: Red Hat, Slackware 9.1
Posts: 76

Rep: Reputation: 15
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!
 
Old 11-11-2004, 11:59 AM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Check out the pipe() function. Open the pipe before you fork(), then the two processes can communicate via the pipe.
 
Old 11-11-2004, 04:50 PM   #3
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
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
 
Old 11-11-2004, 05:01 PM   #4
karlan
Member
 
Registered: Aug 2003
Location: San Francisco, California
Distribution: Slackware
Posts: 158

Rep: Reputation: 30
these tutorials will make your day: http://www.ecst.csuchico.edu/~beej/guide/
 
Old 11-12-2004, 06:58 PM   #5
deveraux83
Member
 
Registered: Jul 2003
Location: Malaysia
Distribution: Red Hat, Slackware 9.1
Posts: 76

Original Poster
Rep: Reputation: 15
Thanks a bunch guys! Oh and Karlan, that site was great, thanks again!
 
Old 11-13-2004, 03:12 PM   #6
karlan
Member
 
Registered: Aug 2003
Location: San Francisco, California
Distribution: Slackware
Posts: 158

Rep: Reputation: 30
i reccomend the sockets tutorial, networking programming is such fun
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
more on fork() feetyouwell Programming 6 09-17-2004 11:18 AM
fork() vibhory2j Linux - Software 1 05-24-2004 04:11 AM
Fork again Avatar33 Programming 13 08-22-2003 01:41 PM
fork() lowlifeish Programming 3 11-04-2002 10:50 AM
Fork Ztyx Linux - General 1 08-31-2002 11:25 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration