problems with select ( ) function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sonbol
    New Member
    • Sep 2007
    • 1

    problems with select ( ) function

    Hi,

    I am new to linux programming. I am using c to develop a program that aims to create many children in order to communicate with their parents through pipes

    I need the parent to wait for all the children to finish processing and write to their parent using the appropriate pipe for each children. I know that I may use the select function for this purpose and I have read a lot about it but I don't know how to use it in my program

    code skeleton can be like this

    int main(int argc,char *argv[])
    {
    fd_set rfds;
    int i;
    int fd[2];
    FD_ZERO(&rfds);

    for(i=0;i<atoi( argv[1]);i++)
    {
    pipe(fd);
    if(!fork())
    //child process and write to the parent then exit
    else
    //i want the select function to be here
    }
    return 0;
    }
Working...