in reply to Help with waitpid and forking ?

Hi

I was just debugging the code and I found out that it does copying of certain directories more than once. After the first fork. it does the job of the second fork again since it is in the for loop. How can I fix this problem? Is there a way that I can set up the forks before i do the coping? Any help would be great.

Replies are listed 'Best First'.
Re: Re: Help with waitpid and forking ?
by jlongino (Parson) on Sep 05, 2001 at 19:46 UTC
    I'm not too familiar with using fork(). I usually use system(). However, in Programming Perl, 2nd Edition:
    Be very careful to end the child code with an exit, or your child may inadvertently leave the conditional and start executing code intended only for the parent process.
    While this is refering to an example in the book, it sounds as though it may also apply to your situation.

    Hope this helps.

    @a=split??,'just lose the ego and get involved!';
    for(split??,'afqtw{|~'){print $a[ord($_)-97]}