LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-16-2007, 02:43 AM   #1
saikasavar
LQ Newbie
 
Registered: Jan 2006
Location: india - andhra pradesh
Posts: 4

Rep: Reputation: 0
how does ctrl+c works with SIGINT in redhat linux


#include<stdio.h>
#include<signal.h>
void abc();
main()
{
printf("Press ctrl+c for teminating\n");
signal(SIGINT,abc);
signal(SIGINT,abc);
signal(SIGINT,abc);
for(;;
}
void abc()
{
printf(" U have pressed ctrl+c\n");
}
iam unable understand the program
how this ctrl+c works with SIGINT and DEL works with SIGINT in linux to terminate the program.
 
Old 07-16-2007, 04:09 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Your little program will trap the SIGINT signal and so you can't quit by pressing CTRL-C. If you don't handle the signal then bash will and will terminate the program.

Compile and run the program. Press ctrl-c. It will print "U have pressed ctrl+c" instead of terminating.
Next open another terminal (xterm or konsole) and enter in "killall -SIGINT ctc". It will print the same message. You used killall to send a signal to the process named "ctc". You can quit the program by entering "killall -SIGQUIT ctc" in the second terminal.

Normally you would use the signal to do something else, like closing files and releasing memory. Maybe you have child processes that you will send SIGQUIT to.

Be sure to read the "man 2 signals" manpage as well as the "info bash" section 3.7.6 Signals.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SIGINT problem brentos Linux - General 1 12-17-2008 10:43 PM
SIGINT handling santhosh.bachu Linux - General 1 07-18-2006 01:18 AM
ctrl+alt+F? no longer works seanr Linux - Software 6 10-04-2005 05:31 PM
Network adapter works in RedHat Linux but fail in XP pro mrpc_cambodia Linux - Hardware 1 07-01-2004 04:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration