what does kill exactly do?
I have a parent process which is creating 100 (as an example) child processes one after another. At the end of any child's job, I kill the child with kill(pid_of_child, SIGKILL) and I cannot see that in ps output. But if something goes wrong with the parent process and I exit from the parent process with exit(1) (at this point only 1 child is there - I can check tht in ps), at that point I see a lot of <defunct> processes whose ppid is pid of parent process.
How is that possible? did kill not kill the child processes entirely?
killdoesn't kill anything. It sends signals to the target process.SIGKILLis just a signal. Now, the standard action forSIGKILL-- the only action, actually, sinceSIGKILLcan't be handled or ignored by a process -- is to exit, that's true.The "<defunct>" process is a child that hasn't been reaped, meaning that the parent hasn't called
wait()to retrieve the exit status of the child. Until the parent callswait(), the defunct (or "zombie") process will hang around.