]>
Commit | Line | Data |
---|---|---|
31c89272 AM |
1 | Description: Catches the ctrl-c(SIGINT) signal and asks the user whether |
2 | he really wants to exit. | |
3 | ||
4 | Author: Kęstutis Biliūnas <kebil@kaunas.init.lt> | |
5 | --- | |
6 | Bug-Debian: http://bugs.debian.org/578122 | |
7 | Last-Update: 2010-07-29 | |
8 | ||
9 | --- a/fontforge/start.c | |
10 | +++ b/fontforge/start.c | |
11 | @@ -34,6 +34,8 @@ | |
12 | #ifdef __Mac | |
13 | # include <stdlib.h> /* getenv,setenv */ | |
14 | #endif | |
15 | +#include <stdio.h> | |
16 | +#include <signal.h> | |
17 | ||
18 | int32 unicode_from_adobestd[256]; | |
19 | struct lconv localeinfo; | |
20 | @@ -129,6 +131,23 @@ static void initlibrarysearchpath(void) | |
21 | #endif | |
22 | } | |
23 | ||
24 | +void sigfun(int sig) | |
25 | +{ | |
26 | + int c; | |
27 | + | |
28 | + /* re-set the signal handler again to sigfun, for next time */ | |
29 | + signal(SIGINT, sigfun); | |
30 | + printf("\nYou have pressed Ctrl-C\n" | |
31 | + "Do you really want to quit? [y/n] "); | |
32 | + | |
33 | + c = getchar(); | |
34 | + if (c == 'y' || c == 'Y') { | |
35 | + exit(0); | |
36 | + } else { | |
37 | + while(getchar()!='\n'); | |
38 | + } | |
39 | +} | |
40 | + | |
41 | void InitSimpleStuff(void) { | |
42 | initlibrarysearchpath(); | |
43 | initrand(); | |
44 | @@ -143,6 +162,8 @@ void InitSimpleStuff(void) { | |
45 | if ( getenv("FF_SCRIPT_IN_LATIN1") ) use_utf8_in_script=false; | |
46 | ||
47 | SetDefaults(); | |
48 | + | |
49 | + signal(SIGINT, sigfun); | |
50 | } | |
51 | ||
52 | void doinitFontForgeMain(void) { |