BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / learn / learn / wrapup.c
index d08a0c0..a965f96 100644 (file)
@@ -1,30 +1,47 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)wrapup.c   4.1     (Berkeley)      %G%";
+static char sccsid[] = "@(#)wrapup.c   4.4     (Berkeley)      5/10/89";
 #endif not lint
 
 #endif not lint
 
-#include "signal.h"
-#include "stdio.h"
+#include <sys/signal.h>
+#include <stdio.h>
 #include "lrnref.h"
 #include "lrnref.h"
+#include "pathnames.h"
+
+extern char learnrc[];
 
 wrapup(n)
 int n;
 {
 
 wrapup(n)
 int n;
 {
-       /* this routine does not use 'system' because it wants
-        interrupts turned off */
-       int retval, pid, pidw;
+       FILE *fp;
+/* this routine does not use 'system' because it wants interrupts turned off */
 
        signal(SIGINT, SIG_IGN);
        chdir("..");
 
        signal(SIGINT, SIG_IGN);
        chdir("..");
-       if ( (pid=fork()) ==0) {
+       if (fork() == 0) {
                signal(SIGHUP, SIG_IGN);
                signal(SIGHUP, SIG_IGN);
-               execl("/bin/rm", "rm", "-r", dir, 0);
-               execl("/usr/bin/rm", "rm", "-r", dir, 0);
-               fprintf(stderr, "Can't find 'rm' command.\n");
+#if BSD4_2
+               if (fork() == 0) {
+                       close(1);
+                       open(_PATH_TTY, 1);
+                       execl(_PATH_STTY, "stty", "new", 0);
+               }
+#endif
+               execl(_PATH_RM, "rm", "-rf", dir, 0);
+               perror(_PATH_RM);
+               fprintf(stderr, "Wrapup:  can't find 'rm' command.\n");
                exit(0);
        }
                exit(0);
        }
-       printf("Bye.\n"); /* not only does this reassure user but 
-                       it stalls for time while deleting directory */
+       if (n == -1)
+               unlink(learnrc);
+       else if (!n && todo) {
+               if ((fp=fopen(learnrc, "w")) == NULL)
+                       exit(0);
+               fprintf(fp, "%s %s %d\n", sname, todo, speed);
+               fclose(fp);
+       }
+       printf("Bye.\n");       /* not only does this reassure user but it
+                               stalls for time while deleting directory */
        fflush(stdout);
        fflush(stdout);
-       /* printf("Wantd %d got %d val %d\n",pid, pidw, retval); */
+       wait(0);
        exit(n);
 }
        exit(n);
 }