DosAcknowledgeSignalException: Difference between revisions
Appearance
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Indicates that a process wants to receive further signals. | Indicates that a process wants to receive further signals. | ||
==Syntax== | ==Syntax== | ||
DosAcknowledgeSignalException (ulSignalNum) | |||
==Parameters== | ==Parameters== | ||
; ulSignalNum (ULONG) - input : The number of the signal to be acknowledged. | ;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 | |||
; ulrc (APIRET) - returns : Return Code | |||
DosAcknowledgeSignalException returns one of the following values: | DosAcknowledgeSignalException returns one of the following values: | ||
* 0 NO_ERROR | * 0 NO_ERROR | ||
* 209 ERROR_INVALID_SIGNAL_NUMBER | * 209 ERROR_INVALID_SIGNAL_NUMBER | ||
Line 36: | Line 25: | ||
This function may be used by any thread in the process, but will only affect thread 1. | 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. | See System Exceptions for a detailed list of the system exceptions. | ||
==Example Code== | ==Example Code== | ||
This program demonstrate how to acknowledge a signal exception. | This program demonstrate how to acknowledge a signal exception. | ||
< | <code> | ||
#define INCL_DOSPROCESS /* DOS process values (for DosSleep) */ | |||
#define INCL_DOSPROCESS | #define INCL_DOSEXCEPTIONS /* DOS exception values */ | ||
#define INCL_DOSEXCEPTIONS | #define INCL_ERRORS /* DOS error values */ | ||
#define INCL_ERRORS | #include <os2.h> | ||
#include <os2.h> | #include <stdio.h> | ||
#include <stdio.h> | |||
ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD p1, | |||
ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD p1, | PEXCEPTIONREGISTRATIONRECORD p2, | ||
PCONTEXTRECORD p3, | |||
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 65: | 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 75: | 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, | |||
PCONTEXTRECORD p3, | |||
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 1; | return 1; | ||
} else { | } else { | ||
Line 101: | Line 81: | ||
} /* endif */ | } /* endif */ | ||
} | } | ||
return XCPT_CONTINUE_SEARCH; /* Exception not resolved. */ | return XCPT_CONTINUE_SEARCH; /* Exception not resolved. */ | ||
} | } | ||
</code> | |||
</ | |||
==Related Functions== | ==Related Functions== | ||
* [[ | * [[DosEnterMustComplete]] | ||
* [[ | * [[DosExitMustComplete]] | ||
* [[ | * [[DosRaiseException]] | ||
* [[ | * [[DosSendSignalException]] | ||
* [[ | * [[DosSetExceptionHandler]] | ||
* [[ | * [[DosSetSignalExceptionFocus]] | ||
* [[ | * [[DosUnsetExceptionHandler]] | ||
* [[ | * [[DosUnwindException]] | ||
[[Category: | [[Category:Dos]] |
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. */
}