Failure.c 719 B

123456789101112131415161718192021222324252627282930
  1. /* This Hello World simply print out "Hello World" */
  2. #include "pal.h"
  3. #include "pal_debug.h"
  4. #include "pal_error.h"
  5. int handled = 0;
  6. void FailureHandler(PAL_PTR event, PAL_NUM arg, PAL_CONTEXT* context) {
  7. pal_printf("Failure notified: %s\n", pal_strerror((unsigned long)arg));
  8. handled = 1;
  9. DkExceptionReturn(event);
  10. }
  11. int main(int argc, char** argv, char** envp) {
  12. pal_printf("Enter Main Thread\n");
  13. DkSetExceptionHandler(FailureHandler, PAL_EVENT_FAILURE);
  14. PAL_HANDLE out = DkStreamOpen("foo:unknown", PAL_ACCESS_WRONLY, 0, 0, 0);
  15. if (!out && !handled) {
  16. pal_printf("DkStreamOpen failed\n");
  17. return -1;
  18. }
  19. pal_printf("Leave Main Thread\n");
  20. return 0;
  21. }