Flush out the last dregs in the terminal before quitting when
[unix-history] / usr / src / usr.bin / error / main.c
index 3c65fa3..54924f6 100644 (file)
@@ -1,4 +1,30 @@
-static char *sccsid = "@(#)main.c      1.4 (Berkeley) %G%";
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1980 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)main.c     5.3 (Berkeley) %G%";
+#endif /* not lint */
+
 #include <stdio.h>
 #include <ctype.h>
 #include <signal.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <signal.h>
@@ -14,7 +40,7 @@ int   language = INCC;
 
 char   *currentfilename = "????";
 char   *processname;
 
 char   *currentfilename = "????";
 char   *processname;
-char   *im_on;                 /* my tty name */
+char   im_on[] = "/dev/tty";   /* my tty name */
 
 boolean        query = FALSE;          /* query the operator if touch files */
 boolean        notouch = FALSE;        /* don't touch ANY files */
 
 boolean        query = FALSE;          /* query the operator if touch files */
 boolean        notouch = FALSE;        /* don't touch ANY files */
@@ -124,11 +150,13 @@ main(argc, argv)
                        exit(4);
                }
        }
                        exit(4);
                }
        }
-       im_on = "/dev/tty";
        if ( (queryfile = fopen(im_on, "r")) == NULL){
        if ( (queryfile = fopen(im_on, "r")) == NULL){
-               fprintf(stderr,"%s: Can't open \"%s\" to query the user.\n",
-                       processname, im_on);
-               exit(9);
+               if (query){
+                       fprintf(stderr,
+                               "%s: Can't open \"%s\" to query the user.\n",
+                               processname, im_on);
+                       exit(9);
+               }
        }
        if (signal(SIGINT, onintr) == SIG_IGN)
                signal(SIGINT, SIG_IGN);
        }
        if (signal(SIGINT, onintr) == SIG_IGN)
                signal(SIGINT, SIG_IGN);