LinuxQuestions.org
Review your favorite Linux distribution.
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 01-12-2008, 02:29 PM   #1
andyar85
LQ Newbie
 
Registered: Jan 2008
Posts: 5

Rep: Reputation: 0
process communication


Hy

I have a situation, meaning I have 2 processes going on and I want the two to communicate between each other.
the thing is in the first one I have an array like int r[100], and i want to use this variable in the second process. I thought pipe is simple but it seems I got something wrong, cause I get a lot of errors. probably is my mistake. Also I have to syncronize them with semaphores,and that's a little tricky

Anyway if someone can help me and give me a hint on how to do this I'd be very graceful
 
Old 01-12-2008, 02:43 PM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 60
There are scores of excellent IPC tutorials on the web. To name a few
http://www.ecst.csuchico.edu/~beej/guide/ipc/ Beej's Guide
http://www.tldp.org/LDP/lpg/node21.h...00000000000000 Linux Programmer's Guide
http://www.cs.cf.ac.uk/Dave/C/node27.html Some dude's course notes...
 
Old 01-13-2008, 03:48 AM   #3
andyar85
LQ Newbie
 
Registered: Jan 2008
Posts: 5

Original Poster
Rep: Reputation: 0
the thing is I have 2 separate child processes,not a child parent issue and I want to send form the first process an array that the second can use
 
Old 01-13-2008, 08:07 AM   #4
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 60
You don't need any parental relationships between processes to use the IPC mechanisms. If it's so in the examples above, it was done just to simplify explanations. Both processes should know the same key, then they can share memory, use message queues and semaphores. You just need to figure out a way for your processes to know the same key (pass it as a command-line argument or just use ftok on the same directory/file). Or, just get your shared memory and stuff in the common parent. IPC things are fork()-safe, you might say...

Last edited by Uncle_Theodore; 01-13-2008 at 08:09 AM.
 
Old 01-13-2008, 07:02 PM   #5
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,397

Rep: Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114
Please, start by reading the IPC-tutorials listed. Much will become clear.
 
  


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
inter process communication aral Programming 5 08-03-2006 01:37 PM
how to do one to many inter process communication? Thinking Programming 2 12-14-2005 03:54 AM
SSL communication establishment process mrpc_cambodia Linux - Security 0 01-02-2005 07:19 PM
Process Communication erdemilhan Programming 1 11-27-2004 04:06 PM
process communication between linux and xp naanu Linux - Networking 2 03-10-2004 12:54 PM


All times are GMT -5. The time now is 08:45 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration