Description: Catches the ctrl-c(SIGINT) signal and asks the user whether
 he really wants to exit.

Author: Kęstutis Biliūnas <kebil@kaunas.init.lt>
---
Bug-Debian: http://bugs.debian.org/578122
Last-Update: 2010-07-29

--- a/fontforge/start.c
+++ b/fontforge/start.c
@@ -34,6 +34,8 @@
 #ifdef __Mac
 # include <stdlib.h>		/* getenv,setenv */
 #endif
+#include <stdio.h>
+#include <signal.h>
 
 int32 unicode_from_adobestd[256];
 struct lconv localeinfo;
@@ -129,6 +131,23 @@ static void initlibrarysearchpath(void)
 #endif
 }
 
+void sigfun(int sig)
+{
+    int  c;
+
+    /* re-set the signal handler again to sigfun, for next time */
+    signal(SIGINT, sigfun); 
+    printf("\nYou have pressed Ctrl-C\n"
+           "Do you really want to quit? [y/n] ");
+
+    c = getchar();
+    if (c == 'y' || c == 'Y') {
+        exit(0);
+    } else {
+        while(getchar()!='\n');
+    }
+}
+
 void InitSimpleStuff(void) {
     initlibrarysearchpath();
     initrand();
@@ -143,6 +162,8 @@ void InitSimpleStuff(void) {
     if ( getenv("FF_SCRIPT_IN_LATIN1") ) use_utf8_in_script=false;
 
     SetDefaults();
+
+    signal(SIGINT, sigfun);
 }
 
 void doinitFontForgeMain(void) {
