Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.6 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include "psxmsg.h"
  4. #include <unistd.h>
  5. #include <signal.h>
  6. #include <stdio.h>
  7. #include <errno.h>
  8. #include "tsttmp.h" // defines DbgPrint as printf
  9. extern int errno;
  10. void
  11. __cdecl
  12. catcher(
  13. IN int sig
  14. );
  15. int caught_sig;
  16. int
  17. __cdecl
  18. main(int argc, char *argv[])
  19. {
  20. LONG i;
  21. int e;
  22. struct sigaction act, oact;
  23. sigset_t eset,fset;
  24. pid_t pid;
  25. LARGE_INTEGER DelayTime;
  26. pid = getpid();
  27. DbgPrint("Looper Posix Process... Pid = %lx\n\n",pid);
  28. DbgPrint("Looper Delay\n");
  29. DelayTime.HighPart = -1;
  30. DelayTime.LowPart = -100000;
  31. NtDelayExecution(FALSE,&DelayTime);
  32. DbgPrint("Looper Delay Done\n");
  33. _exit(8);
  34. sigemptyset(&eset);
  35. sigfillset(&fset);
  36. sigdelset(&fset,SIGHUP);
  37. act.sa_handler = catcher;
  38. sigfillset(&act.sa_mask);
  39. act.sa_flags = 0;
  40. if (sigaction(SIGUSR1, &act ,&oact) ) {
  41. DbgPrint("main: fail sigaction errno %lx\n",errno);
  42. _exit(-1);
  43. }
  44. for(i=1;i<0x100000;i++){
  45. if ( (i & 0xfff) == 0 ) DbgPrint("Looper: i == %lx\n",i);
  46. if ( (i & 0x7fff) == 0) {
  47. DbgPrint("Looper: calling sigprocmask i == %lx\n",i);
  48. sigprocmask(SIG_SETMASK,&fset,NULL);
  49. DbgPrint("Looper: calling sigsuspend i == %lx\n",i);
  50. e = sigsuspend(&eset);
  51. DbgPrint("Looper: returned from sigsuspend %lx errno %lx i %lx\n",e,errno,i);
  52. }
  53. }
  54. DbgPrint("Looper: Exiting...\n");
  55. return 1;
  56. }
  57. void
  58. __cdecl
  59. catcher(
  60. IN int sig
  61. )
  62. {
  63. DbgPrint("Looper: In Catcher, signal == %lx\n",sig);
  64. caught_sig = 1;
  65. }