s_paus.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #include "stdio.h"
  2. #include "f2c.h"
  3. #define PAUSESIG 15
  4. #include "signal1.h"
  5. #ifdef KR_headers
  6. #define Void /* void */
  7. #define Int /* int */
  8. #else
  9. #define Void void
  10. #define Int int
  11. #undef abs
  12. #undef min
  13. #undef max
  14. #include "stdlib.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. extern int getpid(void), isatty(int), pause(void);
  22. #endif
  23. extern VOID f_exit(Void);
  24. #ifndef MSDOS
  25. static VOID
  26. waitpause(Sigarg)
  27. { Use_Sigarg;
  28. return;
  29. }
  30. #endif
  31. static VOID
  32. #ifdef KR_headers
  33. s_1paus(fin) FILE *fin;
  34. #else
  35. s_1paus(FILE *fin)
  36. #endif
  37. {
  38. fprintf(stderr,
  39. "To resume execution, type go. Other input will terminate the job.\n");
  40. fflush(stderr);
  41. if( getc(fin)!='g' || getc(fin)!='o' || getc(fin)!='\n' ) {
  42. fprintf(stderr, "STOP\n");
  43. #ifdef NO_ONEXIT
  44. f_exit();
  45. #endif
  46. exit(0);
  47. }
  48. }
  49. int
  50. #ifdef KR_headers
  51. s_paus(s, n) char *s; ftnlen n;
  52. #else
  53. s_paus(char *s, ftnlen n)
  54. #endif
  55. {
  56. fprintf(stderr, "PAUSE ");
  57. if(n > 0)
  58. fprintf(stderr, " %.*s", (int)n, s);
  59. fprintf(stderr, " statement executed\n");
  60. if( isatty(fileno(stdin)) )
  61. s_1paus(stdin);
  62. else {
  63. #ifdef MSDOS
  64. FILE *fin;
  65. fin = fopen("con", "r");
  66. if (!fin) {
  67. fprintf(stderr, "s_paus: can't open con!\n");
  68. fflush(stderr);
  69. exit(1);
  70. }
  71. s_1paus(fin);
  72. fclose(fin);
  73. #else
  74. fprintf(stderr,
  75. "To resume execution, execute a kill -%d %d command\n",
  76. PAUSESIG, getpid() );
  77. signal1(PAUSESIG, waitpause);
  78. fflush(stderr);
  79. pause();
  80. #endif
  81. }
  82. fprintf(stderr, "Execution resumes after PAUSE.\n");
  83. fflush(stderr);
  84. return 0; /* NOT REACHED */
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. }
  89. #ifdef __cplusplus
  90. }
  91. #endif