EmbLogic's Blog

How to Send a signal -Using Kill command

Send a signal by Kill command
=======================
- To send a signal to a process other than current task.
- It has prototype :-
int kill(pid_t pid, int signo);
- It is included using header :-
#include<signal.h>
- The system data type pid_t is defined in header :-
#include<sys/types.h>
- signo is the signal number of signal to be send.
- pid is the PID of the process to which signal is to be send.
- pid can take value:-
* 0 –> To send signo signal to every process in invoking process’ process group
* -1 –>To send signo signal to every process for which invoking process has permission to send a signal, except itself and init
* n(<-1) –> All process in process group
* n(>0)  –> process with PID n is signalled.
- This take an optional signal name or number and the PID to send the signal.

- For eg. To send ‘hangup’ signal to shell running on PID 1001, we use command :-
kill(1001,HUP);
- killall is used to send signal to all the processes running.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>