Jump to content

DosAcknowledgeSignalException

From EDM2
Revision as of 17:24, 7 June 2016 by Martini (talk | contribs) (Created page with "==Description== Indicates that a process wants to receive further signals. ==Syntax== <PRE> #define INCL_DOSEXCEPTIONS #include <os2.h> ULONG ulSignalNum; /* The numbe...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Indicates that a process wants to receive further signals.

Syntax

#define INCL_DOSEXCEPTIONS
#include <os2.h>

ULONG     ulSignalNum;  /*  The number of the signal to be acknowledged. */
APIRET    ulrc;         /*  Return Code. */

ulrc = DosAcknowledgeSignalException(ulSignalNum);

Parameters

ulSignalNum (ULONG) - input
The number of the signal to be acknowledged.

Valid signals are shown in the following list:

   XCPT_SIGNAL_INTR
   XCPT_SIGNAL_KILLPROC
   XCPT_SIGNAL_BREAK 
ulrc (APIRET) - returns

Return Code

DosAcknowledgeSignalException returns one of the following values:

  • NO_ERROR
  • 209 ERROR_INVALID_SIGNAL_NUMBER

For a full list of error codes, see Errors.


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