In a UNIX system, what happens to child processes when their parent processes exit (while the child process still has a thread of execution). i.e. (not sure how UNIX system call names vary amongst different *nixs): exec(some child process from main) and don't call wait(pid) and have an exit statement right after. Then for the child process have some large amount of code to execute (so regardless of the scheduling algorithm there should be a context switch back to main with some code still left for the child). Since the main process isn't going to wait for the child process it should exit immediately, however the child process still has some code to execute; does the child process simply terminate on the spot or will the kernel allow the child process to finish whatever it was doing and if so then who is now the parent process of this child?
> what happens to child processes when their parent processes exit
It just carries on doing whatever it was doing, until it arrives at its normal exit condition, crashes due to some bug, or is killed by some external event.
> and if so then who is now the parent process of this child?
I think the init process becomes the new parent.
You can test this by calling getppid() from within your child process, after the demise of the original parent.