Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
Mercy Corps

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents

· Introduction to Operating Systems
· Linux Basics
· Working with the System
· Shells and Utilities
· Editing Files
· Basic Administration
· The Operating System
· The X Windowing System
· The Computer Itself
· Networking
· System Monitoring
· Solving Problems
· Security
· Installing and Upgrading
· Linux and Windows

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Surveys

Features
HOWTOs
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 272 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  
Linux Knowledge Base and Tutorial: Forums



Linux Tutorial :: View topic - passing a pointer variable through pipes
 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

passing a pointer variable through pipes

 
Post new topic   Reply to topic    Linux Tutorial Forum Index -> Applications
View previous topic :: View next topic  
Author Message
gattusunil
Newbie


Joined: Dec 20, 2006
Posts: 7

PostPosted: Thu Jan 04, 2007 2:00 pm    Post subject: passing a pointer variable through pipes Reply with quote

Hi !!
i have pointer to array variable. now i need to pass this variable from parent with write function in parent process using pipe file descriptors (output) and same thing in child process i have to read it through the pipe file descriptors
is there any solution for this. its urgent for me
Back to top
View user's profile Send private message
koen
Beginner


Joined: Sep 12, 2005
Posts: 224
Location: Belgium

PostPosted: Fri Jan 05, 2007 2:53 pm    Post subject: Reply with quote

is that a C program you're talking about ?
Back to top
View user's profile Send private message
gattusunil
Newbie


Joined: Dec 20, 2006
Posts: 7

PostPosted: Mon Jan 08, 2007 4:27 am    Post subject: Re: passing a pointer variable through pipes Reply with quote

[quote="gattusunil"]Hi !!
i have pointer to array variable. now i need to pass this variable from parent with write function in parent process using pipe file descriptors (output) and same thing in child process i have to read it through the pipe file descriptors
is there any solution for this. its urgent for me[/quote]


yaa that is a c program in linux. if u want some more clarificaiton i can pass the c code
Back to top
View user's profile Send private message
koen
Beginner


Joined: Sep 12, 2005
Posts: 224
Location: Belgium

PostPosted: Mon Jan 08, 2007 7:32 pm    Post subject: Reply with quote

I suppose what you'd do is to create a pipe, let one process open for writing and write to it, let the other open for reading and read from it - much like you'd do with file.
The child process would need a pointer to store the array address (I guess), which would make the array available to the child process - i suppose that's the purpose of the exercise.

Here's a web page that gives some info.
http://www.unixwiz.net/techtips/remap-pipe-fds.html
they explain about using two pipes because pipes work in 1 direction only, so you need 2 to have two-way communication, but you'r homework doesn't seem to require that.
In any case, the code samples there might get you somewhere.

here's a man page for the pipe() system call
http://www.mkssoftware.com/docs/man3/pipe.3.asp

and here is a sample program that seems to pass a string from one process to another - and strings are arrays, right ?
http://www.gmonline.demon.co.uk/cscene/CS4/CS4-06.html


Other than that, I don't know any C (some notions of C++ on which i've based these assumptions) so I'm not going to be able to help you much more than this.

Have fun.
Back to top
View user's profile Send private message
jimmo
Administrator


Joined: Jul 27, 2002
Posts: 309
Location: Coburg, Germany

PostPosted: Tue Jan 09, 2007 8:12 am    Post subject: Reply with quote

My suggestion is that you look into shared memory. This is an addition region of memory and you would probably have the parent create the shared memory segment and then have the child write to it. The parent could then read out of this segment. From what I see, your goal is to pass the data and not the pointer. It's been a very long time since I worked with shared memory, but that seems easier to me than dealing with pipes. Shared memory is designed exactly for cases where you need to pass data back and forth between processes.

regards,

jimmo
Back to top
View user's profile Send private message
gattusunil
Newbie


Joined: Dec 20, 2006
Posts: 7

PostPosted: Wed Jan 10, 2007 11:36 am    Post subject: Re: passing a pointer variable through pipes Reply with quote

-----------------------------------
Hi Thanks for giving the info. i think i have some way now to tackle the problem
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Linux Tutorial Forum Index -> Applications All times are GMT
Page 1 of 1

 

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001-2007 phpBB Group
  




Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
You can help in many different ways.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.14 Seconds