- if (have_tty_parameters &&
-#ifdef TERMIO
- ioctl(0, TCSETA, &saved_tty_parameters) < 0
-#endif
-#ifdef TERMIOS
- tcsetattr(0, TCSANOW, &saved_tty_parameters) < 0
-#endif
- ) {
- syslog(LOG_ERR, "Can't restore terminal parameters: %m");
- exit(1);
+ echo_stderr(-1);
+ if (report_file != (char *) 0 && report_fp != (FILE *) NULL)
+ {
+/*
+ * Allow the last of the report string to be gathered before we terminate.
+ */
+ if (report_gathering) {
+ int c, rep_len;
+
+ rep_len = strlen(report_buffer);
+ while (rep_len + 1 <= sizeof(report_buffer)) {
+ alarm(1);
+ c = get_char();
+ alarm(0);
+ if (c < 0 || iscntrl(c))
+ break;
+ report_buffer[rep_len] = c;
+ ++rep_len;
+ }
+ report_buffer[rep_len] = 0;
+ fprintf (report_fp, "chat: %s\n", report_buffer);
+ }
+ if (verbose)
+ {
+ fprintf (report_fp, "Closing \"%s\".\n", report_file);
+ }
+ fclose (report_fp);
+ report_fp = (FILE *) NULL;
+ }
+
+#if defined(get_term_param)
+ if (have_tty_parameters)
+ {
+ if (set_term_param (&saved_tty_parameters) < 0)
+ {
+ syslog(LOG_ERR, "Can't restore terminal parameters: %m");
+ exit(1);
+ }