04-26-2008
It is not a two step procedure. Let's say that process 500 has a child with a pid of 501. When process 500 calls exit(), the kernel will search the process table for any process with ppid of 500. It will find the pid 501 has a ppid of 500. So it is changed from 500 to 1. init does not know this happened nor does it care. However, at some point in the future, process 501 may also call exit(). If this happens, the kernel will notice that init is the parent. Since init has installed a handler for SIGCHLD, that signal will be delivered to init. However, process 501 will become a zombie for a brief period. init will process the signal and will wait for for the child which lays the zombie to rest. Suppose that process 501 has exited some time ago and process 500 couldn't be bothered to issue a wait(). Now 501 is a zombie. Most kernels will destroy 501 when 500 exits. Signals do not queue in every version of unix and, even if they do, the queue depth is not infinite. So if 50 processes, all currently children of init, suddenly decide to exit, init may not reliably get 50 SIGCHLD signals. To handle lost signals init will loop when it gets a SIGCGLD and wait for all zombies, not just one. init also will wake up every few minutes via a timer and loop waiting for any zombies.
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have written a daemon and want to make sure that it starts up again after the machine is re-started so I can quit manually doing it. Problem is I'm having difficulty understanding what to do with the init.d
Any help would be appreciated! (1 Reply)
Discussion started by: BC_Kevin
1 Replies
2. UNIX for Advanced & Expert Users
Hi Expert,
I have encountered some problem with my SUN system. Everytime when i issue command #init 6 OR #init 0 it just logout and prompt for login again instead of rebooting the server when run init 6 and system shutdown when run init 0..
I can only reboot the system using reboot ... Was... (6 Replies)
Discussion started by: sc2005
6 Replies
3. Solaris
root@test09 # ls -al /sbin/init
-r-xr-xr-x 1 root sys 550000 Jun 29 2002 /sbin/init
root@test09 # ls -al /usr/sbin/init
-r-xr-xr-x 1 root sys 37100 Jun 29 2002 /usr/sbin/init (2 Replies)
Discussion started by: userking
2 Replies
4. Linux
Dear all,
I typed in init 1 on my redhat box as root and according to wikipedia (http://en.wikipedia.org/wiki/Runlevel):
1 Single-User Mode Does not configure network interfaces, start daemons, or allow non-root logins
So now I can't connect back to it. How do I change the init back to 3?... (8 Replies)
Discussion started by: z1dane
8 Replies
5. Red Hat
What is the difference between 'init s' and 'init 1'.
I know that both will work to change the current run level to single user mode.
Is there any difference in those two commands? (5 Replies)
Discussion started by: praveen_b744
5 Replies
6. Solaris
Hi,
Can somebody please tell me the difference between the files in /etc/rc2.d and those in /etc/init.d? I am asking because on one system, I got a sysedge file S99.sysedge under /etc/rc2.d and it has a soft link to the /etc/init.d/sysedge.
It would be my understanding that the one under... (6 Replies)
Discussion started by: Pouchie1
6 Replies
7. UNIX for Advanced & Expert Users
Hi,
I am experiencing a weird thing on my SUNFIRE machine with Solaris 9 OS.
When I do init 0 to shutdown the machine to go to ok prompt, what it did was shutdown and reboot like an init 6 command do. I did check the corresponding rc scripts that were involved with init 0 and compared with rc... (2 Replies)
Discussion started by: Yenthanh
2 Replies
8. Solaris
i did my research in finding the answer but couldn't find right one. Please give your inputs. (6 Replies)
Discussion started by: ranumala
6 Replies
9. Red Hat
I encountered a problem on one of our database servers.
OS: CentOS 5.5 final
Kernel: 2.6.18-238.5.1.el5.028stab085.2 (OpenVZ kernel)
We wrote some DB-Start/Stop-scripts ("/db2/admin/scripts_dba/start_services.ksh" and ".../stop_services.ksh") to start the database instances. (Database... (1 Reply)
Discussion started by: bakunin
1 Replies
LEARN ABOUT OPENDARWIN
preap
preap(1) User Commands preap(1)
NAME
preap - force a defunct process to be reaped by its parent
SYNOPSIS
preap [-F] pid...
DESCRIPTION
A defunct (or zombie) process is one whose exit status has yet to be reaped by its parent. The exit status is reaped via the wait(3C),
waitid(2), or waitpid(3C) system call. In the normal course of system operation, zombies may occur, but are typically short-lived. This may
happen if a parent exits without having reaped the exit status of some or all of its children. In that case, those children are reparented
to PID 1. See init(1M), which periodically reaps such processes.
An irresponsible parent process may not exit for a very long time and thus leave zombies on the system. Since the operating system destroys
nearly all components of a process before it becomes defunct, such defunct processes do not normally impact system operation. However, they
do consume a small amount of system memory.
preap forces the parent of the process specified by pid to waitid(3C) for pid, if pid represents a defunct process.
preap will attempt to prevent the administrator from unwisely reaping a child process which might soon be reaped by the parent, if:
o The process is a child of init(1M).
o The parent process is stopped and might wait on the child when it is again allowed to run.
o The process has been defunct for less than one minute.
OPTIONS
The following option is supported:
-F Forces the parent to reap the child, overriding safety checks.
OPERANDS
The following operand is supported:
pid Process ID list.
EXIT STATUS
The following exit values are returned by preap, which prints the exit status of each target process reaped:
0 Successfully operation.
non-zero Failure, such as no such process, permission denied, or invalid option.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWesu (32-bit) |
+-----------------------------+-----------------------------+
| |SUNWesxu (64-bit) |
+-----------------------------+-----------------------------+
SEE ALSO
proc(1), init(1M), waitid(2), wait(3C), waitpid(3C), proc(4), attributes(5)
WARNINGS
preap should be applied sparingly and only in situations in which the administrator or developer has confirmed that defunct processes will
not be reaped by the parent process. Otherwise, applying preap may damage the parent process in unpredictable ways.
SunOS 5.10 26 Mar 2001 preap(1)