[FFmpeg-devel] [PATCH] Support Ctrl+Break in ffmpeg.exe on Windows as if it was Ctrl+C

James Almer jamrial at gmail.com
Thu Jun 25 08:05:45 CEST 2015


On 24/06/15 7:19 AM, Roger Pack wrote:
> +#ifdef HAVE_SETCONSOLECTRLHANDLER
> +static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
> +{
> +    av_log(NULL, AV_LOG_DEBUG, "\nReceived windows signal %d\n", fdwCtrlType);
> +
> +    switch (fdwCtrlType)
> +    {
> +    case CTRL_C_EVENT:
> +    case CTRL_BREAK_EVENT:
> +        sigterm_handler(SIGINT);
> +        return TRUE;
> +
> +    case CTRL_CLOSE_EVENT:
> +    case CTRL_LOGOFF_EVENT:
> +    case CTRL_SHUTDOWN_EVENT:
> +        sigterm_handler(SIGTERM);
> +        return TRUE;
> +
> +    default:
> +        av_log(NULL, AV_LOG_ERROR, "Received unknown windows signal %d\n", fdwCtrlType);
> +        return FALSE;
> +    }
> +}
> +#endif
> +
>  void term_init(void)
>  {
>  #if HAVE_TERMIOS_H
> @@ -358,6 +386,9 @@ void term_init(void)
>  #ifdef SIGXCPU
>      signal(SIGXCPU, sigterm_handler);
>  #endif
> +#ifdef HAVE_SETCONSOLECTRLHANDLER
> +    SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE);
> +#endif

Why ffmpeg only? Can't this be in cmdutils.c to also work with the other tools?


More information about the ffmpeg-devel mailing list