Monday, September 08, 2008

Kill and Zero

kill is a command used to send simple messages to processes running on the system. By default, the message sent is the "termination" signal, which requests that the process exit. But kill is something of a misnomer; the signal sent may have nothing to do with process killing. The kill command is a wrapper around the kill()system call, which sends signals to processes or process groups on the system

We all know about kill command and how much we use it especially kill -9 the forceful exit of a process.
The kill command associates itself with options ranging from (0-9). But the most fascinating one is 0 the number close to India. Remember (Aryabhata is the first of the great astronomers of the classical age of India who invented "0").

The interesting part is kill -0 actually does not kill a process. The kill -0 option can be used to 
figure out whether a particular process id exists. It never sends a signal. 
This option can be used in logics where programmer wants to know how long a process exists and if any action is to be taken based on its usage.

Assuming the command is called after certain duration of sleep, the command gets executed and remains silent until it gets to know the process is terminated. And would return an output like "-bash: kill: (8141) - No such process".

Wonders of zero are unlimited !!!


No comments: