[Networkit] Catching SIGINT

Florian Weber uagws at student.kit.edu
Tue Jan 20 18:50:20 CET 2015


> Request for feedback: Is there some drawback which we have not seen so far?

Well, the current implementation has several problems:

* The only non-local variables that a signal-handler may change are
atomics or of those of the type `volatile sig_atomic_t` (section
1.10.23f of the standard). Please also note that the atomics *must* be
lock-free (otherwise you might try to lock them in the signal-handler
while they are locked by the suspended “main-execution” resulting in a
* signal-handlers should have C-linkage (18.10.10); I am quite sure that
lambdas don't qualify. (I don't think that GCC would mind but I didn't
find anything where they
* There are some platforms on which you have to reinstall a
signal-handler every time it get's invoked (aka the first thing that it
should do is another call to signal. AFAIK this doesn't affect anything
that is mainstream today, but it might be a good idea to do it nonetheless.
(This is btw. one of the reasons why it is often recommended against
signal in favor of sigaction())

* The empty exception-specification of Aux::Interrupt::Exception::what
is clearly suboptimal: If you really want that effect use noexcept. In
fact I thought that they got deprecated because they are terribly broken.

Now, for the API:

My main-problem here is `SignalHandling::isRunning`: it should either
return whether a signal has been received using it's return-value or
throw an exception in that case and return void. The way it is now is
basically a recipe for bugs.

Personally I think that both interfaces should exist but have different

This brings me to the next thing: I find the notion of running for this
quite surprising and non-intuitive.

Finally a stylistic thing: The entire SignalHandling-class only consists
of static members, which in my opinion really screams for using
a namespace instead. This would have the additional advantage of being
able to define the global state that in an anonymous namespace in the
.cpp instead of declaring it additionally in the header.

Best regards,

-------------- n?chster Teil --------------
Ein Dateianhang mit Bin?rdaten wurde abgetrennt...
Dateiname   : signature.asc
Dateityp    : application/pgp-signature
Dateigr??e  : 819 bytes
Beschreibung: OpenPGP digital signature
URL         : <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20150120/2689d787/attachment.sig>

More information about the NetworKit mailing list