Find the answer to your Linux question:
Results 1 to 4 of 4
Hello! I'm writing a program which should use fork() and exec() to create many child processes, possibly more than 1000. I've run the program once and no processes were created ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    21

    Creating more than 1000 processes from a single parent process

    Hello!
    I'm writing a program which should use fork() and exec() to create many child processes, possibly more than 1000. I've run the program once and no processes were created after the first 300 or 400 processes had been created. I didn't check the error in fork() and exec(), so I don't know what happeded. Is it that the maximum number of processes that one user can create has been exceeded? If so, I'm considering recycling pid. Is this feasible? And how to do this? Or if what I think is wrong, how can I create more than 1000 processes from a single parent process?

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    I didn't check the error in fork() and exec()
    That's a bug.
    the maximum number of processes that one user can create has been exceeded
    That limit is a feature, to prevent fork bombs, whether intended or not.
    I'm considering recycling pid. Is this feasible? And how to do this?
    Do this at the command line:
    Code:
    man waitpid
    how can I create more than 1000 processes from a single parent process?
    If you want them all to be running at the same time, you can't. If you don't, waitpid() will do the trick for you.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Just Joined!
    Join Date
    Feb 2008
    Posts
    21
    Oh, I forgot to mention that they don't run at the same time. There's a master process to assure that these 1000 processes are run in good order and 8 processes are run at the same time. So I would like to recycle the pids that have already finished. I read man page for waitpid(), but it simply says how to wait a process to finish and get the exit state. I still can't figure out how to recycle a pid, so can you give a more detailed explanation?

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    So I would like to recycle the pids that have already finished. I read man page for waitpid(), but it simply says how to wait a process to finish and get the exit state.
    waitpid() recycles the pid. The only reason a zombie process hangs around is so you can use wait() or waitpid() to get the exit status.

    Details may be found in the wikipedia article about zombie processes.
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

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