LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-23-2006, 06:20 PM   #1
rastadevil
LQ Newbie
 
Registered: Feb 2006
Posts: 7

Rep: Reputation: 0
Question simple yet tricky pipe question


Hi all..
Directly, is it possible to create a random number of pipes? This question arises because everytime i or someone creates a pipe, first declares a 2 state array and then do the pipe() call like:
fd[2];

..

pipe(fd);

For me it would be great to create a random number of pipes, but since we first have to declare a prefixed number of "state arrays" like the one fd[2] above i wonder if my question is possible!?

Thank you, hope further answers help other users as well.
 
Old 03-23-2006, 06:57 PM   #2
SaintsOfTheDiamond
Member
 
Registered: Jan 2006
Location: Lexington, KY
Distribution: Arch and a little Slack
Posts: 139

Rep: Reputation: 15
I'm not sure if this is possible, but could you create a vector of two element int arrays (to use as the file handles) which you can make a random size, then just iterate through the vector creating new pipes along the way? There'd end up being quite a bit of bookkeeping overhead to access an individual file handle that way though.
 
Old 03-23-2006, 10:02 PM   #3
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
You could declare a global fd_set variable and initialize it with FD_CLR(). See select(2). Then you go on adding file descriptors with FD_SET() and test which one of them is set with FD_ISSET()
 
  


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
Tricky grep question amytys Programming 1 01-04-2006 05:16 PM
Xorg tricky question festino114 Linux - General 4 06-29-2005 03:51 PM
Tricky installation question or1onas Linux - Newbie 3 04-28-2004 05:16 PM
a tricky question archlyric Linux - Newbie 3 02-27-2004 02:06 AM
A Tricky question in Apache!! RKris Linux - Software 1 02-20-2003 09:19 AM

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

All times are GMT -5. The time now is 11:30 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration