summaryrefslogtreecommitdiffstats
path: root/contrib/libf2c/libF77/s_paus.c
blob: 79691366e6fdcb803499c4d91724629934c2e780 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdio.h>
#include "f2c.h"
#define PAUSESIG 15

#include "signal1.h"
#undef abs
#undef min
#undef max
#include <stdlib.h>
extern int getpid (void), isatty (int), pause (void);

extern void f_exit (void);

static void
waitpause (Sigarg)
{
  Use_Sigarg;
  return;
}

static void
s_1paus (FILE * fin)
{
  fprintf (stderr,
	   "To resume execution, type go.  Other input will terminate the job.\n");
  fflush (stderr);
  if (getc (fin) != 'g' || getc (fin) != 'o' || getc (fin) != '\n')
    {
      fprintf (stderr, "STOP\n");
#ifdef NO_ONEXIT
      f_exit ();
#endif
      exit (0);
    }
}

int
s_paus (char *s, ftnlen n)
{
  fprintf (stderr, "PAUSE ");
  if (n > 0)
    fprintf (stderr, " %.*s", (int) n, s);
  fprintf (stderr, " statement executed\n");
  if (isatty (fileno (stdin)))
    s_1paus (stdin);
  else
    {
#if (defined (MSDOS) && !defined (GO32)) || defined (_WIN32)
      FILE *fin;
      fin = fopen ("con", "r");
      if (!fin)
	{
	  fprintf (stderr, "s_paus: can't open con!\n");
	  fflush (stderr);
	  exit (1);
	}
      s_1paus (fin);
      fclose (fin);
#else
      fprintf (stderr,
	       "To resume execution, execute a   kill -%d %d   command\n",
	       PAUSESIG, getpid ());
      signal1 (PAUSESIG, waitpause);
      fflush (stderr);
      pause ();
#endif
    }
  fprintf (stderr, "Execution resumes after PAUSE.\n");
  fflush (stderr);
  return 0;			/* NOT REACHED */
}
OpenPOWER on IntegriCloud