Hello and welcome!
In this video session, we will discuss the programming concept of signal.
In order to use the signal system call, we have to include the signal dot h and the system call signal
takes two parameters.
The first parameter is the signal number, and the second parameter is the function pointers.
And this function pointer is nothing but the pointer to a function which takes an integer and returns
an void.
Also, whenever a signal is delivered to a process using the system call signal, the signal can.
The signal specified here can either perform a default action or can be ignored for this particular
signal.
So if we want to ignore a particular signal for a process, we have to specify a sig underscore ignore
ignore in this parameter.
In the second parameter.
And if we have to perform the default action of a given signal, then the second parameter needs to
be specified as sig dfl, which is nothing but the sig default.
Now let's have a look into the manual pages of signal for better understanding.
As specified, the manual page includes the information of the system call signal.
We need to include the header file, signal and signal in the system call, which takes two parameters.
The first parameter is the signal number for which we are handling the signal, and the second parameter
is basically a type defined to a function pointer, which takes a integer as parameter and returns void.
Also, when the signal system call fails, it returns an sig error.
Now let's see.
The system call called as kill.
This system, called kill, is used to send a signal to a particular process.
For example, this is the header file that needs to be included in order to use kill, and the system
call is is kill and it takes two parameters.
The first parameter is the process id.
That is nothing but to which process the signal needs to be sent.
And the second parameter is the signal number.
So for example, let's say we have several processes running.
And if we need to send a particular signal to a particular process then we need to use make use of this
kill system call.
And we have to specify the process ID of the particular process and send the desired signal.
We will see some examples of both this signal and kill system call for better understanding.
Let's have a look into the examples.