Find the answer to your Linux question:
Results 1 to 6 of 6
hello, im doing a program where a process creates 5 processes, i need that the father process dont finishes till all the five processes finish. how to do it????????????? i ...
  1. #1
    Just Joined!
    Join Date
    Dec 2007
    Location
    Algeria
    Posts
    26

    [SOLVED] c programmation ( wait() )

    hello,
    im doing a program where a process creates 5 processes,
    i need that the father process dont finishes till all the five processes finish.
    how to do it?????????????
    i found the function wait(); but it doen't work because it is only for one of the processes.

    thanks to help me

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714

    wait

    try waitpid()

  3. #3
    Linux Newbie
    Join Date
    Mar 2008
    Location
    Hyderabad
    Posts
    109
    you get the pid of child process when you call fork. collect all pids and call waitpid for each process.

  4. #4
    Just Joined!
    Join Date
    Dec 2007
    Location
    Algeria
    Posts
    26
    thanks but i need a function to wait for all process , in my case yes i have just 5 processes , but imagine for a big number of processes

  5. #5
    Linux Newbie
    Join Date
    Mar 2008
    Location
    Hyderabad
    Posts
    109
    I don't know how memory intensive application you r going to make.
    But can give dynamic memory allocation for an array of pid a chance.
    something like
    i=0;
    while(pid[i])
    {
    waitpid(pid[i]);
    i++;
    }

  6. #6
    Just Joined!
    Join Date
    Dec 2007
    Location
    Algeria
    Posts
    26

    thanks

    thanks .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...