76 lines
1.3 KiB
Diff
76 lines
1.3 KiB
Diff
--- edit.c
|
|
+++ edit.c
|
|
@@ -144,7 +144,7 @@
|
|
/*
|
|
* Close the current input file.
|
|
*/
|
|
- static void
|
|
+ public void
|
|
close_file()
|
|
{
|
|
struct scrpos scrpos;
|
|
--- funcs.h
|
|
+++ funcs.h
|
|
@@ -93,6 +93,7 @@
|
|
public void init_textlist ();
|
|
public char * forw_textlist ();
|
|
public char * back_textlist ();
|
|
+ public void close_file ();
|
|
public int edit ();
|
|
public int edit_ifile ();
|
|
public int edit_list ();
|
|
--- signal.c
|
|
+++ signal.c
|
|
@@ -35,6 +35,35 @@
|
|
extern int reading;
|
|
|
|
/*
|
|
+ * Terminate signal handler.
|
|
+ */
|
|
+ static RETSIGTYPE
|
|
+terminate(type)
|
|
+ int type;
|
|
+{
|
|
+ /*
|
|
+ * run $LESSCLOSE if needed
|
|
+ */
|
|
+ close_file();
|
|
+
|
|
+ /*
|
|
+ * Clean up the terminal.
|
|
+ */
|
|
+#ifdef SIGTTOU
|
|
+ LSIGNAL(SIGTTOU, SIG_IGN);
|
|
+#endif
|
|
+ clear_bot();
|
|
+ deinit();
|
|
+ flush();
|
|
+ raw_mode(0);
|
|
+#ifdef SIGTTOU
|
|
+ LSIGNAL(SIGTTOU, SIG_DFL);
|
|
+#endif
|
|
+ LSIGNAL(SIGTERM, SIG_DFL);
|
|
+ kill(getpid(), SIGTERM);
|
|
+}
|
|
+
|
|
+/*
|
|
* Interrupt signal handler.
|
|
*/
|
|
/* ARGSUSED*/
|
|
@@ -144,6 +173,7 @@
|
|
* Set signal handlers.
|
|
*/
|
|
(void) LSIGNAL(SIGINT, u_interrupt);
|
|
+ (void) LSIGNAL(SIGTERM, terminate);
|
|
#if MSDOS_COMPILER==WIN32C
|
|
SetConsoleCtrlHandler(wbreak_handler, TRUE);
|
|
#endif
|
|
@@ -166,6 +196,7 @@
|
|
* Restore signals to defaults.
|
|
*/
|
|
(void) LSIGNAL(SIGINT, SIG_DFL);
|
|
+ (void) LSIGNAL(SIGTERM, SIG_DFL);
|
|
#if MSDOS_COMPILER==WIN32C
|
|
SetConsoleCtrlHandler(wbreak_handler, FALSE);
|
|
#endif
|