From: Florian Lindner <mailinglists@xgm.de>
To: linux-c-programming@vger.kernel.org
Subject: Correct handling of signal
Date: Thu, 20 Aug 2015 10:14:22 +0200 [thread overview]
Message-ID: <mr428v$ct2$1@ger.gmane.org> (raw)
Hello,
I'm developing a scientific application that can be used standalone as well
as a library.
We use connection files to exchange information about socket based
connection. Upon an unclean exit these connection linger around, causing
trouble on the next startup.
I implemented a signal handler to clean up on unclean exit:
signal(SIGSEGV, precice::utils::terminationSignalHandler);
signal(SIGABRT, precice::utils::terminationSignalHandler);
signal(SIGTERM, precice::utils::terminationSignalHandler);
signal(SIGINT, precice::utils::terminationSignalHandler);
void terminationSignalHandler(int signal) {
// use boost filesystem to clean up
}
Since I'm a rather high level programmer I haven't had much contact with
signals, some questions:
1) Can I assume the application to be in a condition to actually do
something when these signals are called? I have doubts especially about
SIGSEGV regarding corruption of internal data structures.
2) Can multiple signal handler be installed for one signal? Or do subsequent
invocations of signal(...) overwrite the handler for the resp. signal? If we
are used as a library and host application has installed own signal handler,
how can we omit overwriting them?
3) If there are multiple handler for one signal, can we remove our handler
from the chain and re-emit the signal? Or should be just use std::exit or
std::abort?
4) Is this the right way to go for the problem described? Any comments
welcome!
Best Regards,
Florian
reply other threads:[~2015-08-20 8:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='mr428v$ct2$1@ger.gmane.org' \
--to=mailinglists@xgm.de \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).