Revision 9680a722

View differences:

ffmpeg.c
30 30
#include <sys/time.h>
31 31
#include <termios.h>
32 32
#include <sys/resource.h>
33
#include <signal.h>
33 34
#endif
34 35
#ifdef CONFIG_OS2
35 36
#include <sys/types.h>
......
238 239
    tcsetattr (0, TCSANOW, &oldtty);
239 240
}
240 241

  
242
static volatile sig_atomic_t received_sigterm = 0;
243

  
244
static void
245
sigterm_handler(int sig)
246
{
247
    received_sigterm = sig;
248
    term_exit();
249
}
250

  
241 251
static void term_init(void)
242 252
{
243 253
    struct termios tty;
......
256 266
    
257 267
    tcsetattr (0, TCSANOW, &tty);
258 268

  
269
    signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).  */
270
    signal(SIGQUIT, sigterm_handler); /* Quit (POSIX).  */
271
    signal(SIGTERM, sigterm_handler); /* Termination (ANSI).  */
272
    /*
273
    register a function to be called at normal program termination
274
    */
259 275
    atexit(term_exit);
260 276
#ifdef CONFIG_BEOS_NETSERVER
261 277
    fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK);
......
2838 2854
    powerpc_display_perf_report();
2839 2855
#endif /* POWERPC_TBL_PERFORMANCE_REPORT */
2840 2856

  
2857
#ifndef CONFIG_WIN32
2858
    if (received_sigterm) {
2859
        fprintf(stderr,
2860
            "Received signal %d: terminating.\n",
2861
            (int) received_sigterm);
2862
        exit (255);
2863
    }
2864
#endif
2865
    exit(0); /* not all OS-es handle main() return value */
2841 2866
    return 0;
2842 2867
}

Also available in: Unified diff