home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / debug / sigterm / sigterm.cpp < prev   
Text File  |  1996-10-29  |  822b  |  37 lines

  1. //************************************************************
  2. // Problem Determination - Termination Signal Handler
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  6. // All Rights Reserved.
  7. //************************************************************
  8. #include <signal.h>
  9. #include <string.h>
  10. #include <stdio.h>
  11. #include <new.h>
  12.  
  13. void TrapOnTerm(int signal)
  14. {
  15.   // Cause a trap
  16.   char* psz=0;
  17.   strcpy(psz, "junk");
  18. }
  19.  
  20. void main( )
  21.  {
  22.    signal(SIGABRT, (_SigFunc)TrapOnTerm);
  23.  
  24.    // Now cause a memory overlay for a termination.
  25.    char* pszBuffer = new char[10];
  26.    strcpy(pszBuffer, "Memory overlay Memory overlay");
  27.  
  28. #ifdef __DEBUG_ALLOC__
  29.    // And run the heap check to detect it with /Tm+.
  30.    _heap_check();
  31. #endif
  32.  }
  33.  
  34.  
  35.  
  36.  
  37.