|
|
| Gcc Target Description Macros: Using and Porting the Gnu Compiler Collection Gcc (ISBN: 0595100384) |
 |
List Price: $14.95
Our Price: $14.95
Used Price:
Release Date: August, 1900
Manufacturer: iUniverse.com (Paperback)
Sales Rank: 535,117
Author: Richard M. Stallman
|
More Info
|
|
|
Catch Signal
|
2003-05-01 22:01:27
|
| |
c
|
|
|
|
|
Category: source:c:linux
|
|
Description: This program contains a signal handler so uninterruptable with Ctrl+C keys.
|
|
Platform: unix
|
|
Author: pipas
|
|
Viewed: 6206
|
|
Rating: 4.3/5 (78 votes)
|
|
|
| If you have any questions about
this piece of code or still need help, try posting your question on the forum. |
/*
* Example program by pipas@linux.pte.hu
* This program is uninterruptable with
* Ctrl+C, uses signal handler
*
* http://www.metalshell.com/
*/
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
/* The signal handler function */
void handler( int signal ) {
printf("Signal handler...\n");
psignal( signal, "Signal: ");
} /*handler*/
main() {
/* Registering the handler, catching
SIGINT signals */
signal( SIGINT, handler );
/* Do nothing */
while( 1 ) {
printf("Running...\n");
sleep(10);
} /*while*/
} /*main*/
|
|
|