12.07.2015 Views

download

download

download

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The pgrep command can also return process names in addition to the PIDs asshown here:# pgrep -l sh1719 csh1716 tcsh1715 sshd1713 sshd839 sshd768 shChapter 4Sending Signals to Running Processes—kill, killall,and pkillThe kill(1) command is used to send signals to a running process by the PIDspecified on the command line. Obviously the PID of a running process can be foundusing ps(1) command. The default signal, if nothing is specified, is TERM signal. TheTERM signal causes the process to terminate gracefully:# ps ax | grep vim95934 p1 T 0:00.08 vim# kill 95934There are cases when the software is unable to process a TERM signal, or does notterminate normally. The KILL signal can be used to implicitly kill a process and freethe allocated resources back to the system as shown here:# kill -KILL 95934The kill(1) can also be used to send any other signal to a process. A good exampleof the non-killing actions would be the HUP signal. The hang-up (HUP) signal willcause a process to reload its configuration as follows:# ps ax | grep sshd837 ?? Ss 0:00.02 /usr/sbin/sshd# kill -HUP 837The kill(1) utility takes PID in the command line. Hence you need to find out thePID for each process that you want to send a signal to ,using the ps(1) command.Instead, killall(1) takes the process name instead of PID. Using killall you cansend a signal to one or more running process:# killall httpd[ 67 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!