xref: /original-bsd/usr.bin/learn/learn/wrapup.c (revision 92d3de31)
1 #ifndef lint
2 static char sccsid[] = "@(#)wrapup.c	4.2	(Berkeley)	04/25/83";
3 #endif not lint
4 
5 #include "signal.h"
6 #include "stdio.h"
7 #include "lrnref.h"
8 
9 wrapup(n)
10 int n;
11 {
12 /* this routine does not use 'system' because it wants interrupts turned off */
13 
14 	signal(SIGINT, SIG_IGN);
15 	chdir("..");
16 	if (fork() == 0) {
17 		signal(SIGHUP, SIG_IGN);
18 #if vax
19 		if (fork() == 0) {
20 			close(1);
21 			open("/dev/tty", 1);
22 			execl("/bin/stty", "stty", "new", 0);
23 		}
24 #endif
25 		execl("/bin/rm", "rm", "-rf", dir, 0);
26 		execl("/usr/bin/rm", "rm", "-rf", dir, 0);
27 		perror("bin/rm");
28 		fprintf(stderr, "Wrapup:  can't find 'rm' command.\n");
29 		exit(0);
30 	}
31 	if (!n && todo)
32 		printf("To take up where you left off type \"learn %s %s\".\n", sname, todo);
33 	printf("Bye.\n");	/* not only does this reassure user but it
34 				stalls for time while deleting directory */
35 	fflush(stdout);
36 	wait(0);
37 	exit(n);
38 }
39