in reply to fork() not working as expected

From the variables chosen in your code, it seems you have fork and threads somewhat confused..... at least enough that I won't strain my brain trying to decipher your intent. Of course, if you are on MSWindows, ignore this. :-)

I'm not really a human, but I play one on earth My Petition to the Great Cosmic Conciousness