[FFmpeg-devel] [PATCH] ffplay: Exit on ctrl-c.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Jan 13 19:34:53 CET 2012


On Fri, Jan 13, 2012 at 12:44:14PM +0100, Alexander Strasser wrote:
> Hi Reimar,
> 
> Reimar Döffinger wrote:
> > On Wed, Jan 11, 2012 at 10:29:32PM +0100, Alexander Strasser wrote:
> > > yann.lepetitcorps at free.fr wrote:
> > > > Selon Alexander Strasser <eclipse7 at gmx.net>:
> > > > In this case, we can perhaps use something like this ?
> > > > 
> > > > 
> > > >     static void signal_handler(int sig)
> > > >     {
> > > >         switch(sig)
> > > >         [
> > > >             case SIGTERM  :
> > > >             case SIGKILL  :  exit(123); break;
> > > >             ...
> > > >             case SIGINT   :
> > > >             default       : force_exit = 0; break;
> > > >         }
> > > >     }
> > > 
> > >   I am sorry this is still messed up. I also don't think that
> > > approach will give any practical improvements while introducing
> > > more complexity. I am fine with the current solution, Micheal's
> > > initial patch, as is ffplay maintainer Marton.
> > > 
> > >   Just wanted to hear any opinions on the rather theoretical issue,
> > > so thanks for taking part in the discussion.
> > 
> > The only option I see is the approach MPlayer uses:
> > First just set a flag, but if more signals come in go over to more
> > desperate means, if necessary even a direct exit().
> > As for signal-safety: "man 7 signal" list signal-safe functions,
> > so to avoid exit while staying portable FFmpeg could e.g. send
> > a SIGKILL to itself.
> 
>   that is interesting. I see the `signal' function is in the list
> of signal-safe functions. So your idea of sending SIGKILL to itself
> could probably work out.

You're looking for the wrong function, the 'signal' function is the
(outdated) way to set a signal handler, the 'kill' function is
the one for sending a signal.
It's still in the signal-safe list though.
I forgot to check if getpid is signal-safe, if not it would need
yet a bit more mess I think.


More information about the ffmpeg-devel mailing list