Re: apr and shutdown
"Mark Hahn" <[email protected]> Sat, 19 Jun 2004 21:20:46 -0700
| Newsgroups | gmane.comp.lang.prothon.devel |
|---|---|
| Message-ID | <00a901c4567d$f60d8b40$0d01a8c0@MarkVaio> |
Ben Collins wrote:
I'm posting this on prothon-dev.
> On Fri, Jun 18, 2004 at 06:40:01PM -0700, Mark Hahn wrote:
>> Right now when I click on the go-away box in the upper-right of a
>> win32 prothon console window, the Prothon app exits immediately
>> without my shutdown code running.
>>
>> Can you tell me the standard C way to intercept a console shutdown?
>> If there isn't a C standard for this is there an APR function?
>
> Hmm, I would suspect catching signals is what you want. Look at
> apr_signal.h. I think a console kill like that would be SIGTERM or
> SIGINT, or similar.
The constants for signals (APR_HAVE_SIGACTION, APR_HAVE_SIGWAIT, &
APR_HAVE_SIGSUSPEND) are disabled in my APR.
This code is documented in my visual studio and I put it in my code but it
seems to do nothing. sig_handler is never called.
void sig_handler(int signum) {
switch (signum) {
case SIGTERM:
signum = 0; // for breakpoint
}
}
signal(SIGTERM, sig_handler);
signal(SIGABRT, sig_handler);
signal(SIGFPE, sig_handler);
signal(SIGILL, sig_handler);
signal(SIGINT, sig_handler);
signal(SIGSEGV, sig_handler);
signal(SIGTERM, sig_handler);