So when a child dies parent gets SIGCHLD but if parent dies before doing wait(), the child is reparented to init. At this point in time the child is a zombie i.e. <defunct>.
What happens next?
Does init do wait() on that child? if yes, when does it do it? Any guarantees regarding time-limit?
Yes,
initwill immediately reap all children. If you make a process which ignoresSIGCHLDand accumulates many zombies you can get rid of them by killing that parent via the mechanism you describe.For reference here is the main loop of
initwhile in multi user mode.requested_transitionis set by signallinginit(e.g. the classickill -1 1to read an updatedinittab):(
collect_childhandles cases where init has some special interest in the process, such as a login shell which now needs a newgetty)