Which OS are you running on? I ask because sometimes try to use fork/exec on Windows, and it doesn't do what they expect.
Assuming Linux/UNIX, then you could check the PID returned from
wait, rather than just looking for -1, and track which child processes are ending, and what their exit code is ($?).
You do not show any error handling, maybe because it is only a code fragment, but if
fork returns undef then it failed (usually because too many processes are running) and
exec should not return, so the
exit should be reporting an error ($!).
Then again, someone could be killing the parent, did you check its exit code?
Update: Opps! I did not read the title correctly, you are using Windows.
fork creates a new thread on windows, and
exec spawns a new process, so your
exit is probably closing down the main process.