[alsa-devel] [PATCH 2/2 v2] crec: Add primitive exception handling
Dimitris Papastamos
dp at opensource.wolfsonmicro.com
Wed Dec 11 12:15:51 CET 2013
On Tue, Dec 03, 2013 at 06:22:56PM +0000, Mark Brown wrote:
> On Tue, Dec 03, 2013 at 04:27:55PM +0000, Charles Keepax wrote:
>
> > +static void sig_handler(int signum __attribute__ ((unused)))
> > +{
> > + printf("Interrupted, saving what we have!\n");
> > +
> > + finish_record();
> > +
> > + if (file)
> > + fclose(file);
> > +
> > + _exit(EXIT_FAILURE);
> > +}
>
> You can't safely do most of this such as calling fclose() from within a
> signal handler, the set of functions that are guaranteed safe is quite
> limited - see signal(7).
A cool thing would be to use signalfd(2) to serialize the handling of the
signal and getting rid of the traditional signal handler.
>From a quick look at bionic it doesn't seem to define a syscall wrapper for that
so if one really wanted to use it, it would be through syscall(2) but that's
a bit ugly for this purpose.
Thanks,
Dimitris
More information about the Alsa-devel
mailing list