Ticket #1463: ffmpeg-sigbreak.diff

File ffmpeg-sigbreak.diff, 1.7 KB (added by joewreschnig, 7 years ago)

Patch against ~2012.06.18 git branch

  • configure

    diff --git a/configure b/configure
    index 0cdf7a4..2790ab1 100755
    a b HAVE_LIST=" 
    12441244    sched_getaffinity
    12451245    sdl
    12461246    sdl_video_size
     1247    SetConsoleCtrlHandler
    12471248    setmode
    12481249    setrlimit
    12491250    sndio_h
    check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi 
    31533154check_func_headers windows.h GetProcessAffinityMask
    31543155check_func_headers windows.h GetProcessTimes
    31553156check_func_headers windows.h MapViewOfFile
     3157check_func_headers windows.h SetConsoleCtrlHandler
    31563158check_func_headers windows.h VirtualAlloc
    31573159check_func_headers glob.h glob
    31583160
  • ffmpeg.c

    diff --git a/ffmpeg.c b/ffmpeg.c
    index 4d37424..b4258e1 100644
    a b  
     1
    12/*
    23 * Copyright (c) 2000-2003 Fabrice Bellard
    34 *
     
    7273#include <windows.h>
    7374#include <psapi.h>
    7475#endif
     76#ifdef HAVE_SETCONSOLECTRLHANDLER
     77#include <windows.h>
     78#endif
    7579
    7680#if HAVE_SYS_SELECT_H
    7781#include <sys/select.h>
    static void sigterm_handler(int sig) 
    12401244        exit(123);
    12411245}
    12421246
     1247#ifdef HAVE_SETCONSOLECTRLHANDLER
     1248static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
     1249{
     1250    switch (fdwCtrlType)
     1251    {
     1252    case CTRL_C_EVENT:
     1253    case CTRL_BREAK_EVENT:
     1254        sigterm_handler(SIGINT);
     1255        return TRUE;
     1256
     1257    case CTRL_CLOSE_EVENT:
     1258        sigterm_handler(SIGTERM);
     1259        return TRUE;
     1260
     1261    default:
     1262        return FALSE;
     1263    }
     1264}
     1265#endif
     1266
    12431267static void term_init(void)
    12441268{
    12451269#if HAVE_TERMIOS_H
    static void term_init(void) 
    12751299#ifdef SIGXCPU
    12761300    signal(SIGXCPU, sigterm_handler);
    12771301#endif
     1302
     1303#ifdef HAVE_SETCONSOLECTRLHANDLER
     1304    SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE);
     1305#endif
    12781306}
    12791307
    12801308/* read a key without blocking */