Bell 32V development
[unix-history] / usr / src / cmd / learn / learn.c
CommitLineData
bbddffb1
TL
1#include "stdio.h"
2#include "lrndef"
3#include "lrnref"
4#include "signal.h"
5
6main(argc,argv)
7char *argv[];
8{
9 extern hangup(), intrpt();
10 extern char * getlogin();
11 char *malloc();
12
13 speed = 0;
14 more = 1;
15 pwline = getlogin();
16 setbuf(stdout, malloc(BUFSIZ));
17 selsub(argc, argv);
18 signal(SIGHUP, hangup);
19 signal(SIGINT, intrpt);
20 while (more) {
21 selunit();
22 dounit();
23 whatnow();
24 }
25 wrapup(0);
26}
27
28hangup()
29{
30 wrapup(1);
31}
32
33intrpt()
34{
35 char response[20], *p;
36
37 signal(SIGINT, hangup);
38 write(2, "\nInterrupt.\nWant to go on? ", 28);
39 p = response;
40 *p = 'n';
41 while (read(0, p, 1) == 1 && *p != '\n')
42 p++;
43 if (response[0] != 'y')
44 wrapup(1);
45 ungetc('\n', stdin);
46 signal(SIGINT, intrpt);
47}