home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power GUI Programming with VisualAge C++
/
powergui.iso
/
powergui
/
debug
/
sigterm
/
sigterm.cpp
< prev
Wrap
Text File
|
1996-10-29
|
822b
|
37 lines
//************************************************************
// Problem Determination - Termination Signal Handler
//
// Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
// Copyright (c) 1997 John Wiley & Sons, Inc.
// All Rights Reserved.
//************************************************************
#include <signal.h>
#include <string.h>
#include <stdio.h>
#include <new.h>
void TrapOnTerm(int signal)
{
// Cause a trap
char* psz=0;
strcpy(psz, "junk");
}
void main( )
{
signal(SIGABRT, (_SigFunc)TrapOnTerm);
// Now cause a memory overlay for a termination.
char* pszBuffer = new char[10];
strcpy(pszBuffer, "Memory overlay Memory overlay");
#ifdef __DEBUG_ALLOC__
// And run the heap check to detect it with /Tm+.
_heap_check();
#endif
}