move watchdog_pid out of shm, take 2.

This way should work better.
move function to avoid need for prototype
move exit related stuff out of the watchdog function.
If the 'main' process crashes during regeneration, avoid hanging the watchdog