Commit 3adbdf31 3adbdf31b646b6b6f804a5c54c19852d770ab120 by Alain Magloire

The reason the interrupt code did not work for me, is that

	by default using signal will make function calls restartable,
	at least on my default RH5.1, when read() was interrupted
	it did not return EINTR inside ml_getc().

	* mail.c (main): Use sigaction if available to set SIGPIPE.
	* mailline.c (sig_handler): Reset "lines" variable.
	Recall signal() if we did not have sigaction.
	(ml_readline_init):  Use sigaction to set SIGWINCH and SIGINT.
1 parent 907ec6bf
......@@ -188,7 +188,17 @@ main (int argc, char **argv)
}
interactive = isatty (fileno(stdin));
#ifdef HAVE_SIGACTION
{
struct sigaction act;
act.sa_handler = SIG_IGN;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
sigaction (SIGPIPE, &act, NULL);
}
#else
signal (SIGPIPE, SIG_IGN);
#endif
/* set up the default environment */
if (!getenv ("HOME"))
......
......@@ -34,10 +34,13 @@ sig_handler (int signo)
break;
#if defined (SIGWINCH)
case SIGWINCH:
util_do_command ("set screen=%d", util_getlines());
break;
#endif
}
#ifndef HAVE_SIGACTION
signal (signo, sig_handler);
#endif
}
void
......@@ -86,10 +89,23 @@ ml_readline_init ()
rl_attempted_completion_function = (CPPFunction*)ml_command_completion;
rl_getc_function = ml_getc;
#endif
#ifdef HAVE_SIGACTION
{
struct sigaction act;
act.sa_handler = sig_handler;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
sigaction (SIGINT, &act, NULL);
#if defined(SIGWINCH)
sigaction (SIGWINCH, &act, NULL);
#endif
}
#else
signal (SIGINT, sig_handler);
#if defined(SIGWINCH)
signal (SIGWINCH, sig_handler);
#endif
#endif
}
#ifdef WITH_READLINE
......
......@@ -917,12 +917,12 @@ util_error (va_alist)
#else
char *format;
va_start(ap);
format = va_arg(ap, char *);
va_start (ap);
format = va_arg (ap, char *);
#endif
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
vfprintf (stderr, format, ap);
fprintf (stderr, "\n");
va_end(ap);
}
......