Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Signal function (SIGINT)?

Tags:

c

signals

sigint

What does this statement below do? If anyone can explain this function I would really appreciate it.

signal(SIGINT, SIG_DFL);
like image 474
Amit Jain Avatar asked Apr 30 '13 07:04

Amit Jain


People also ask

What is signal SIGINT?

SIGINT is one of the predefined signals that's associated with the terminal interrupt character (commonly Ctrl + C ). It causes the shell to stop the current process and return to its main loop, displaying a new command prompt to the user.

What is a signal function?

In signal processing, a signal is a function that conveys information about a phenomenon. Any quantity that can vary over space or time can be used as a signal to share messages between observers. The IEEE Transactions on Signal Processing includes audio, video, speech, image, sonar, and radar as examples of signal.

How do you get a SIGINT signal?

When Ctrl+C is pressed, SIGINT signal is generated, we can catch this signal and run our defined signal handler. C standard defines following 6 signals in signal.

How do you ignore SIGINT signal?

If you want to ignore the signal specified by the first argument (i.e., pretending that the signal never happens), use SIG_IGN for the second argument. In the above two lines, SIGINT and SIGALRM are ignored. If you want the system to use the default way to handle a signal, use SIG_DFL for the second argument.


1 Answers

SIGINT is the interrupt signal (ctrl+C). Its default behaviour is to terminate the process. SIGINT signal can be dis-positioned, means one can change the default behaviour ( By calling sighandler, or setting it SIG_IGN ) Now once the action is changes and you want to set it again the default behaviour of this signal then you should write

signal(SIGINT, SIG_DFL);

It will again change the default behaviour of the signal. ( which is to terminate a process )

like image 141
Sandeep_black Avatar answered Sep 22 '22 09:09

Sandeep_black