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.

120 lines
2.2 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include "psxmsg.h"
  4. #include <unistd.h>
  5. #include <signal.h>
  6. #include <errno.h>
  7. #include <sys/wait.h>
  8. #include <stdio.h>
  9. #include "tsttmp.h" // defines DbgPrint as printf
  10. extern int errno;
  11. void
  12. __cdecl
  13. catcher(
  14. IN int sig
  15. );
  16. int caught_sig;
  17. int
  18. __cdecl
  19. main(int argc, char *argv[])
  20. {
  21. pid_t pid,cpid;
  22. ULONG status;
  23. LARGE_INTEGER DelayTime;
  24. #ifdef longtest
  25. LONG i;
  26. struct sigaction act, oact;
  27. ULONG begin,end;
  28. #endif
  29. pid = getpid();
  30. DbgPrint("Posix Process... Pid = %lx\n\n",pid);
  31. DelayTime.HighPart = -1;
  32. DelayTime.LowPart = -500000;
  33. DbgPrint("Delay\n");
  34. NtDelayExecution(FALSE,&DelayTime);
  35. DbgPrint("Delay Done\n");
  36. cpid = wait(&status);
  37. DbgPrint("hellol: wait for %lx satisfied... status %lx errno %lx\n",
  38. cpid,
  39. status,
  40. errno
  41. );
  42. DbgPrint("hellol: waiting again. Should get ECHILD\n");
  43. cpid = wait(&status);
  44. DbgPrint("hellol: wait for %lx satisfied... status %lx errno %lx\n",
  45. cpid,
  46. status,
  47. errno
  48. );
  49. return 0;
  50. #ifdef longtest
  51. //
  52. // try to catch SIGKILL
  53. //
  54. act.sa_handler = catcher;
  55. sigfillset(&act.sa_mask);
  56. act.sa_flags = 0;
  57. if (sigaction(SIGUSR1, &act ,&oact) ) {
  58. DbgPrint("main: fail sigaction errno %lx\n",errno);
  59. _exit(-1);
  60. }
  61. DbgPrint("hellol: killing self\n");
  62. caught_sig = 0;
  63. i = kill(pid,SIGUSR1);
  64. if ( !caught_sig ) {
  65. DbgPrint("Error kill returned before signal handler executed\n");
  66. }
  67. DbgPrint("back from kill %lx\n",i);
  68. DbgPrint("hellol: killing looper\n");
  69. i = kill(0x00010001,SIGUSR1);
  70. DbgPrint("back from kill %lx\n",i);
  71. for(i=0;i<7;i++) {
  72. begin = rnuminstr();
  73. __NullPosixApi();
  74. end = rnuminstr();
  75. DbgPrint("Call Time bg %lx end %lx totals 0x%lx %ld \n",begin, end, end - begin,end - begin);
  76. }
  77. DbgPrint("hellol: killing looper again. Should be paused\n");
  78. i = kill(0x00010001,SIGUSR1);
  79. DbgPrint("back from kill %lx\n",i);
  80. DbgPrint("Exiting...\n");
  81. _exit(1);
  82. #endif
  83. }
  84. void
  85. __cdecl
  86. catcher(
  87. IN int sig
  88. )
  89. {
  90. DbgPrint("In Catcher, signal == %lx\n",sig);
  91. caught_sig = 1;
  92. }