[FFmpeg-devel] [PATCH] ffplay: Exit on ctrl-c.
yann.lepetitcorps at free.fr
yann.lepetitcorps at free.fr
Tue Jan 10 22:01:27 CET 2012
Selon Alexander Strasser <eclipse7 at gmx.net>:
> yann.lepetitcorps at free.fr wrote:
> > > Michael Niedermayer wrote:
> > > > This allows to get out of ffplay if it or SDL got stuck.
> > > > This for example happens when the audio driver is playing something
> > > > else and doesnt support mixing multiple sources.
> > >
> > > I principally like it.
> > [...]
> >
> > > > +static void sigterm_handler(int sig)
> > > > +{
> > > > + exit(123);
> > > > +}
> > >
> > > Not sure how bad this can be for ffplay on usual systems,
> > > but I think it is not safe to call exit() from a signal
> > > handling context.
> > >
> > > Maybe using _exit or _Exit would be better if it is acceptable
> > > to depend on it. I can't think of any alternate approaches right
> > > now.
> > >
> > > [...]
> >
> > The sigterm_handler() func can perhaps to be used for to store the sig
> value
> > into a global variable that is checked after into ffplay ?
> >
> > static int force_exit = 0;
> >
> > static void sigterm_handler(int sig)
> > {
> > force_exit = 123;
> > }
> >
> >
> > Somewhere into ffplay, "at the good instant"
> >
> > if( force_exit != 0 )
> > {
> > // close/delete alls necessary stuffs
> > ...
> >
> > exit(force_exit);
> > }
>
> I guess that would not fix the problem described above.
>
> Alexander
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
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;
}
}
@+
Yannoo
More information about the ffmpeg-devel
mailing list