Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 03-23-2006, 05:20 PM   #1
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:



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, 05:57 PM   #2
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, 09:02 PM   #3
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()


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

All times are GMT -5. The time now is 12:47 PM.

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