in reply to fork question

Starts right from the fork, that's why you often see...
if(fork()) { #parent } else { #child }
fork returns 0 in the child, the pid of the child to the parent, and goes from there
                - Ant

Replies are listed 'Best First'.
Re: Re: fork question
by gennari (Novice) on Apr 17, 2001 at 03:29 UTC
    With just the if (fork) this or that, it's really clear. What I have is

    print LOG "Files and statuses" bunch of logic to figure out command if (fork()) { update a hash } else { go do the command exit }

    And my raft of print statements shows that the print command is getting issued multiple times. Can't figure out how it's getting called. I can't seem to find any examples that have a bunch of stuff above the fork to see if I'm missing anything.

      I don't know if it would make a difference, but your print LOG line has no ; at the end of the line

      Here's what might be happening... you don't print a \n and unless you have autoflush on maybe the parent and child are both flushing to the log...
                      - Ant

        The real code isn't missing a ; I was just (sloppily :->) giving an example.

        There are no print statements in the child code (between else and exit), so somehow the child is running parent code it shouldn't even be able to see, or the parent is spawning parents, or....