LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-13-2011, 10:14 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Rep: Reputation: 51
What is the SIGQUIT signal?


Hi:

I.e., what causes it? I'll make myself more clear. I have the program lazy, a CD player, which uses two signals (I'm reading the sources): SIGINT and SIGQUIT. The manual does not say a word about, for example, using ^C to stop the program.

However, while playing a CD, I sometimes want to halt the program before the cd ends playing and press ^C. What happens is simply that the program jumps to the following track. A new ^C jumps to the next one, and so on until the last the lead-out area is reached and the program stops.

Question: Why then these two signals in the sources. Can it be a bug?

EDIT: I have just discovered a wonderful thing. ^C does what I said and, ^| stops execution. However, I do not understand. Wikipedia says SIGQUIT does a memory dump?!

Last edited by stf92; 08-13-2011 at 10:30 PM.
 
Old 08-13-2011, 10:45 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
While UNIX/Linux signals have conventional uses, a program is free to use any of them (that do not terminate it!) as the programmer chooses.
 
Old 08-14-2011, 01:06 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Original Poster
Rep: Reputation: 51
Good. So this programmer is making good use of SIGQUIT, because he uses it to quit (terminate) the program, only he does not dump the memory.

The memory dump part is obviously a remnant from the old days when computers worked off-line (non-interactively)! In the same way that ^D is really End of tape.

BTW, what is what the programer mustn't do? Terminate the program upon reception of a signal different from SIGQUIT or do something different from terminating the program upon reception of SIGQUIT?

Last edited by stf92; 08-14-2011 at 01:10 PM.
 
Old 08-14-2011, 10:23 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
As Catkin says, there is a conventional expected response for most signals, see his links.
SIGUSR1 & SIGUSR2 are 'undefined' ie designed to be used only by the specified trap code in the specific program.
In theory you can trap just about all of them and change the effect, but this can lead to confusion as you can imagine, so its rarely done.
SIGHUP is one that tends to be altered because HUP refers to the old dialup days and is rarely used for that these days.
Its frequently used to tell a prog eg apache to re-read its cfg file.
SIGKILL (signal num 9) is usually enforced by the OS no matter what; useful for killing a wedged/stuck/hung program that won't respond to the usual signals.
Note that this kills the process immediately(!) WITHOUT allowing it to shutdown cleanly eg close open files. This may well result in file corruptions; try to avoid this signal if possible.
 
1 members found this post helpful.
Old 08-14-2011, 11:52 PM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Original Poster
Rep: Reputation: 51
Thank you very much. I'm new to the world of linux programming, as you can see.
 
Old 08-15-2011, 12:08 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Late in the shutdown process, the shutdown scripts send all remaining processes the SIGTERM signal. The idea is that any processes that have not already been shut down by the shutdown scripts should shut down themselves. A few seconds later the shutdown scripts send all remaining processes the SIGKILL signal which kills them immediately. Thus, although a programmer could program to ignore SIGTERM, the sane choice is to program to clean up and exit on receipt of SIGTERM.
 
Old 08-15-2011, 12:34 AM   #7
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Original Poster
Rep: Reputation: 51
Kind of you. I had begun to learn about interprocess communication but some distract me afterwards. I think it was the famous shell scripting, that I'm always beginning from scratch, although I have plenty of books.

Now, with the first serious program in C I am writing, I feel more in my land. And am being forced to learn about things which matters me more than scripts. Cheers.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
user-define signal handler & coredump for signal 11(SIGSEGV) Alexlun Linux - Software 2 05-24-2009 07:37 AM
Sending signal SIGQUIT to a process forked by remote machine v_sharma Linux - Server 0 03-15-2009 04:57 AM
How to reinstall a signal handler after exec ( Strange behaviour in signal handling ) lali.p Programming 0 09-20-2008 01:11 PM
Why program received SIGQUIT quited but did NOT generate the core file ???? cryincold Programming 2 02-27-2008 05:26 AM
about the SIGQUIT dummyagain Programming 11 10-05-2003 03:19 AM


All times are GMT -5. The time now is 10:56 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration