File less-429-terminate.patch of Package hello_world

Index: edit.c
===================================================================
--- edit.c.orig	2009-03-30 21:45:51.000000000 +0200
+++ edit.c	2009-06-03 15:20:08.000000000 +0200
@@ -152,7 +152,7 @@ back_textlist(tlist, prev)
 /*
  * Close the current input file.
  */
-	static void
+	public void
 close_file()
 {
 	struct scrpos scrpos;
Index: funcs.h
===================================================================
--- funcs.h.orig	2009-06-03 15:17:47.000000000 +0200
+++ funcs.h	2009-06-03 15:20:08.000000000 +0200
@@ -97,6 +97,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 ();
Index: signal.c
===================================================================
--- signal.c.orig	2009-03-30 22:35:36.000000000 +0200
+++ signal.c	2009-06-03 15:20:08.000000000 +0200
@@ -37,6 +37,35 @@ extern int quit_on_intr;
 extern long jump_sline_fraction;
 
 /*
+ * 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*/
@@ -147,6 +176,7 @@ init_signals(on)
 		 * Set signal handlers.
 		 */
 		(void) LSIGNAL(SIGINT, u_interrupt);
+		(void) LSIGNAL(SIGTERM, terminate);
 #if MSDOS_COMPILER==WIN32C
 		SetConsoleCtrlHandler(wbreak_handler, TRUE);
 #endif
@@ -168,6 +198,7 @@ init_signals(on)
 		 * Restore signals to defaults.
 		 */
 		(void) LSIGNAL(SIGINT, SIG_DFL);
+		(void) LSIGNAL(SIGTERM, SIG_DFL);
 #if MSDOS_COMPILER==WIN32C
 		SetConsoleCtrlHandler(wbreak_handler, FALSE);
 #endif