in reply to Forking problems

As anyone can see by the relevant code you posted along with your incredibly verbose and detailed question the problem lies on line 17. HTH.

P.S. See How (Not) To Ask A Question.

The cake is a lie.
The cake is a lie.
The cake is a lie.