The Art of Debugging with GDB and DDD by Matloff Norman & Peter Jay Salzman

The Art of Debugging with GDB and DDD by Matloff Norman & Peter Jay Salzman

Author:Matloff, Norman & Peter Jay Salzman [Matloff, Norman]
Language: eng
Format: mobi
Tags: COMPUTERS / Programming Languages / C
Publisher: No Starch Press
Published: 2009-08-19T16:00:00+00:00


void my_sigint_handler( int signum )

{

printf("I received signal %d (that's 'SIGINT' to you).\n", signum);

puts("Tee Hee! That tickles!\n");

}

int main(void)

{

char choicestr[20];

int choice;

while ( 1 )

{

puts("1. Ignore control-C");

puts("2. Custom handle control-C");

puts("3. Use the default handler control-C");

puts("4. Raise a SIGSEGV on myself.");

printf("Enter your choice: ");

fgets(choicestr, 20, stdin);

sscanf(choicestr, "%d", &choice);

if ( choice == 1 )

signal(SIGINT, SIG_IGN); // Ignore control-C

else if ( choice == 2 )

signal(SIGINT, my_sigint_handler);

else if ( choice == 3 )

signal(SIGINT, SIG_DFL);

else if ( choice == 4 )

raise(SIGSEGV);

else

puts("Whatever you say, guv'nor.\n\n");

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.