Understanding Processes
Process attributes
- Kernel orderly assigns a unique no. to every process that it creates (known as PID)
- PPID is the PID of the parent from which the process was cloned. Cloning is generally the result of fork.
- UID is the user identification number.(mostly same as EUID of parent) this one is there for identifying the owner of the process.
- EUID is effective user id number of the process. Mostly same as UID of the process except in the case of setuid processes.
- similar is the case with GID and EGUID.
- “nice value” or “niceness” tells how nice the process is planning to be to other users of the system. High nice value means low priority. Range of values (-20 to +19)
Signals
- Signals are process level interrupt requests. About 30 diff kinds are defined. Each process may or may not define Signal handlers in its code. When a signal is recieved, one of the two things can happen:
- If the recieving process has designated a handler routine for that particular sgnal, that handler is called with information about the context in which the signal was delivered
- Otherwise, the kernel takes some default action for that Signal
Specifying a handler is similar to “catching” a signal. A process can request kernel to ignore or request blockage of certain signals. But with one exception:
The signals named KILL and STOP cannot be blocked / caught / ignored.(You see now how you are able to kill processes).
Kill command is used to send signals to process.(any signal defined on your architecture..not just kill )
syntax: kill - signal-no PID
Following is the list of must know signals(brief
along with there signal-no:
- TSTP - generated by terminal driver when you type CTRL+z - request to stop- may be ignored (thats why sometimes CTRL+z doesnt work
- INT (Interrupt) - generated by terminal driver when you type CTRL+c - request to stop -process can choose to ignore it/block it.
- KILL (signal-no 9) - terminates the process at OS level, process never actually gets this signal - process has no control over this(poor soul)
- TERM (signal-no 15) - Termination request - Again the process has control over it.
- HUP (signal-no 1) - HangUp - General behavior of this Signal is to clean up(kill) all child process, re-read configuration files and make adjustments accordingly(of course if process is capable of doing this)– though a process can handle this in its own non-conventional way.
If you dont know the PID of the process you want to kill you will normally use ps to find out the PID. There is one alternative though, and that is killall killall will do the lookup for you given just the “command name”
/proc
Each time a new process is created, an entry in /proc is created. The name of the directory entry corresponds to the process identification number (PID) of the created process. These directories store information about the running processes. more
to be continued….