Jump to content

DosAcknowledgeSignalException: Difference between revisions

From EDM2
Ak120 (talk | contribs)
mNo edit summary
Ak120 (talk | contribs)
 
Line 29: Line 29:
==Example Code==
==Example Code==
This program demonstrate how to acknowledge a signal exception.
This program demonstrate how to acknowledge a signal exception.
<PRE>
<code>
#define INCL_DOSPROCESS       /* DOS process values (for DosSleep) */
#define INCL_DOSPROCESS   /* DOS process values (for DosSleep) */
#define INCL_DOSEXCEPTIONS   /* DOS exception values */
#define INCL_DOSEXCEPTIONS /* DOS exception values */
#define INCL_ERRORS           /* DOS error values    */
#define INCL_ERRORS       /* DOS error values    */
#include <os2.h>
#include <os2.h>
#include <stdio.h>
#include <stdio.h>
 
ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD      p1,
ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD      p1,
                            PEXCEPTIONREGISTRATIONRECORD p2,
                              PEXCEPTIONREGISTRATIONRECORD p2,
                            PCONTEXTRECORD              p3,
                              PCONTEXTRECORD              p3,
                            PVOID                        pv );
                              PVOID                        pv );
 
int main (VOID)
int main (VOID){
{
   EXCEPTIONREGISTRATIONRECORD  RegRec  = {0};
   EXCEPTIONREGISTRATIONRECORD  RegRec  = {0};
   APIRET                      rc      = NO_ERROR;  /* Return code */
   APIRET                      rc      = NO_ERROR;  /* Return code */
 
   /* Add MyTermHandler to this thread's chain of exception handlers */
   /* Add MyTermHandler to this thread's chain of exception handlers */
   RegRec.ExceptionHandler = (ERR)MyTermHandler;
   RegRec.ExceptionHandler = (ERR)MyTermHandler;
   rc = DosSetExceptionHandler( &RegRec );
   rc = DosSetExceptionHandler( &RegRec );
Line 54: Line 52:
     return 1;
     return 1;
   }
   }
   printf("Stop this program using Ctrl-C or Ctrl-Break.\n");
   printf("Stop this program using Ctrl-C or Ctrl-Break.\n");
   rc = DosSleep(10000L);  /* Give user 10 seconds... */
   rc = DosSleep(10000L);  /* Give user 10 seconds... */
   rc = DosUnsetExceptionHandler( &RegRec );
   rc = DosUnsetExceptionHandler( &RegRec );
   if (rc != NO_ERROR) {
   if (rc != NO_ERROR) {
Line 64: Line 59:
     return 1;
     return 1;
   }
   }
   printf("Program ends.\n");
   printf("Program ends.\n");
   return NO_ERROR;
   return NO_ERROR;
}
}
 
/**********************************************************************/
/**************************************************************/
ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD      p1,
ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD      p1,
                            PEXCEPTIONREGISTRATIONRECORD p2,
                              PEXCEPTIONREGISTRATIONRECORD p2,
                            PCONTEXTRECORD              p3,
                              PCONTEXTRECORD              p3,
                            PVOID                        pv )
                              PVOID                        pv )
{
{
   APIRET  rc  = NO_ERROR;  /* Return code */
   APIRET  rc  = NO_ERROR;  /* Return code */
   printf("*** MyTermHandler entered ***\n");
   printf("*** MyTermHandler entered ***\n");
   if (p1->ExceptionNum == XCPT_SIGNAL) {
   if (p1->ExceptionNum == XCPT_SIGNAL) {
         rc = DosAcknowledgeSignalException ( XCPT_SIGNAL_BREAK );
         rc = DosAcknowledgeSignalException ( XCPT_SIGNAL_BREAK );
         if (rc != NO_ERROR) {
         if (rc != NO_ERROR) {
           printf("DosAcknowledgeSignalException error:
           printf("DosAcknowledgeSignalException error: return code = %u\n", rc);
                  return code = %u\n", rc);
           return 1;
           return 1;
         } else {
         } else {
Line 90: Line 81:
         } /* endif */
         } /* endif */
   }
   }
   return XCPT_CONTINUE_SEARCH;      /* Exception not resolved. */
   return XCPT_CONTINUE_SEARCH;      /* Exception not resolved. */
}
}
</PRE>
</code>


==Related Functions==
==Related Functions==

Latest revision as of 17:50, 1 December 2018

Indicates that a process wants to receive further signals.

Syntax

DosAcknowledgeSignalException (ulSignalNum)

Parameters

ulSignalNum (ULONG) - input
The number of the signal to be acknowledged.
Valid signals are shown in the following list:
1 - XCPT_SIGNAL_INTR
3 - XCPT_SIGNAL_KILLPROC
4 - XCPT_SIGNAL_BREAK

Returns

ulrc (APIRET) - returns
Return Code

DosAcknowledgeSignalException returns one of the following values:

  • 0 NO_ERROR
  • 209 ERROR_INVALID_SIGNAL_NUMBER

Remarks

Do not make Presentation Manager calls from exception handlers.

DosAcknowledgeSignalException is used to tell the system that the process wishes to receive further signal exceptions.

This function may be used by any thread in the process, but will only affect thread 1.

See System Exceptions for a detailed list of the system exceptions.

Example Code

This program demonstrate how to acknowledge a signal exception.

#define INCL_DOSPROCESS    /* DOS process values (for DosSleep) */
#define INCL_DOSEXCEPTIONS /* DOS exception values */
#define INCL_ERRORS        /* DOS error values     */
#include <os2.h>
#include <stdio.h>

ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD       p1,
                             PEXCEPTIONREGISTRATIONRECORD p2,
                             PCONTEXTRECORD               p3,
                             PVOID                        pv );

int main (VOID){
 EXCEPTIONREGISTRATIONRECORD  RegRec  = {0};
 APIRET                       rc      = NO_ERROR;   /* Return code */

 /* Add MyTermHandler to this thread's chain of exception handlers */
 RegRec.ExceptionHandler = (ERR)MyTermHandler;
 rc = DosSetExceptionHandler( &RegRec );
 if (rc != NO_ERROR) {
    printf("DosSetExceptionHandler error: return code = %u\n",rc);
    return 1;
 }
 printf("Stop this program using Ctrl-C or Ctrl-Break.\n");
 rc = DosSleep(10000L);   /* Give user 10 seconds... */
 rc = DosUnsetExceptionHandler( &RegRec );
 if (rc != NO_ERROR) {
    printf("DosUnsetExceptionHandler error: return code = %u\n",rc);
    return 1;
 }
 printf("Program ends.\n");
 return NO_ERROR;
}

/**************************************************************/
ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD       p1,
                             PEXCEPTIONREGISTRATIONRECORD p2,
                             PCONTEXTRECORD               p3,
                             PVOID                        pv )
{
 APIRET   rc  = NO_ERROR;   /* Return code */
 printf("*** MyTermHandler entered ***\n");
 if (p1->ExceptionNum == XCPT_SIGNAL) {
       rc = DosAcknowledgeSignalException ( XCPT_SIGNAL_BREAK );
       if (rc != NO_ERROR) {
         printf("DosAcknowledgeSignalException error: return code = %u\n", rc);
         return 1;
       } else {
         printf("DosAcknowledgeSignalException done. Program resumes.\n");
         return XCPT_CONTINUE_EXECUTION;  /* Continue execution */
       } /* endif */
 }
 return XCPT_CONTINUE_SEARCH;       /* Exception not resolved. */
}

Related Functions