[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Flushing all Buffers Before Exiting



On Tue, Mar 26, 2019 at 05:37:49PM -0000, Curt wrote:
> On 2019-03-26, <tomas@tuxteam.de> <tomas@tuxteam.de> wrote:
> >
> >
> > On Tue, Mar 26, 2019 at 11:43:24AM -0500, David Wright wrote:
> >
> > [...]
> >
> >> So these are issues beyond the scope of the OP's problem domain.
> >> OTOH, IMO, trapping a USR1 signal [...]
> >
> > In this case, an atexit handler seems the right tool. Since the
> > OP is using Perl, the END {...} block is our friend.
> 
> Is this in the ballpark?
> 
>  $SIG{INT} = \&tsktsk;
> 
>  sub tsktsk {
>     $SIG{INT} = \&tsktsk;           # See ``Writing A Signal Handler''
>     warn "\aThe long habit of living indisposeth us for dying.\n";
> }

It is -- but as I wrote, rather use

  END {
   warn "blah blah..."
  }

would be (a) simpler and (b) work also for $SIG{HUP}, and for some
uncaught die() and so on.

Cheers
-- t

Attachment: signature.asc
Description: Digital signature


Reply to: