diff options
author | Roumen Petrov <ffmpeg@roumenpetrov.info> | 2003-04-10 18:21:06 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-04-10 18:21:06 +0000 |
commit | 9680a722822241c18ca1049e55bef0feb69eb6fe (patch) | |
tree | bed4aa047d5bc2ccf4f69009c33d6cbc7744302d /ffmpeg.c | |
parent | b5e34cb1c1d7ef260731c916e79ce19cf4792a6e (diff) | |
download | ffmpeg-9680a722822241c18ca1049e55bef0feb69eb6fe.tar.gz |
restore old tty in ffmpeg patch by (Roumen Petrov <ffmpeg at roumenpetrov dot info>)
Originally committed as revision 1750 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffmpeg.c')
-rw-r--r-- | ffmpeg.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -30,6 +30,7 @@ #include <sys/time.h> #include <termios.h> #include <sys/resource.h> +#include <signal.h> #endif #ifdef CONFIG_OS2 #include <sys/types.h> @@ -238,6 +239,15 @@ static void term_exit(void) tcsetattr (0, TCSANOW, &oldtty); } +static volatile sig_atomic_t received_sigterm = 0; + +static void +sigterm_handler(int sig) +{ + received_sigterm = sig; + term_exit(); +} + static void term_init(void) { struct termios tty; @@ -256,6 +266,12 @@ static void term_init(void) tcsetattr (0, TCSANOW, &tty); + signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */ + signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */ + signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */ + /* + register a function to be called at normal program termination + */ atexit(term_exit); #ifdef CONFIG_BEOS_NETSERVER fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK); @@ -2838,5 +2854,14 @@ int main(int argc, char **argv) powerpc_display_perf_report(); #endif /* POWERPC_TBL_PERFORMANCE_REPORT */ +#ifndef CONFIG_WIN32 + if (received_sigterm) { + fprintf(stderr, + "Received signal %d: terminating.\n", + (int) received_sigterm); + exit (255); + } +#endif + exit(0); /* not all OS-es handle main() return value */ return 0; } |