Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-03-2004, 01:40 AM   #1
Registered: Nov 2003
Posts: 35

Rep: Reputation: 15
Possible to lock out interrupts forever?

someone please tell me what the following code does:


     signal(SIGINT, sigcatcher);
     for( ; ; ) printf("1");

     signal(SIGINT, sigcatcher);
     for( ; ; ) printf("2");

Last edited by skywalker27182; 02-03-2004 at 01:41 AM.
Old 02-03-2004, 02:41 AM   #2
Registered: Dec 2002
Location: San Luis Obispo, CA
Distribution: Fedora Core 3
Posts: 618

Rep: Reputation: 30
What it looks like you're doing is making your own signal handler for SIGINT. Instead of Linux doing what it nomally does when SIGINT is thrown, your program will run sigcather() instead. Instead of restting the signal it looks like you're telling Linux to continue using sigcather() as the handler.

Hope that helps.
Old 02-04-2004, 01:20 AM   #3
Registered: Nov 2003
Posts: 35

Original Poster
Rep: Reputation: 15
what i was thinking was whenever an interrupt comes, the kernel will pass on to another infinite loop(in sigcatcher) and if there is one more interrupt, it will go back to the first infinite loop(in main) and so on. also, i found out that SIGINT is the keyboard interrupt, so in place of SIGINT if i place a signal that kernel sends the process, SIGTERM, is it possible to lock the interrupts out?
Old 02-04-2004, 08:12 AM   #4
LQ Newbie
Registered: Feb 2004
Distribution: Red Hat
Posts: 20

Rep: Reputation: 0

Well it seems that you are using the signals in an unreliable manner. I suggest if you want to deal with signals take a look at the following functions wich are called reliable signal functions:

sigemptyset(sigset_t, *set);

struct sigaction{
void (*sa_handler);
sigset_t sa_mask;
int sa_flags;

int sigaction(int signum,struct sigaction *act,struct sigaction *oldact);
int sigprocmask(int how,sigset_t *set,sigset_t *oldset);
int sigpendign(sigset_t *set);
int sigsuspend(sigset_t *set);

Hope it would help.


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
E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable) phreakshew Linux - Newbie 17 07-12-2016 03:50 AM
Caps Lock & Scroll Lock Flashing thedug Linux - General 6 06-07-2008 10:43 PM
Caps Lock and Num Lock leds dont work! npc Linux - Hardware 2 11-08-2005 11:40 AM
Num, Scroll, Caps/Lock all Lock up Slackware Zamochit Linux - Newbie 0 10-18-2004 08:47 PM
RedHat 9.0 freezes with blinking Caps lock and Scroll lock queen-bee Linux - Software 0 07-30-2004 11:40 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:50 PM.

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