Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow up to #162.
The first commit gets rid of all usage of stdio in signal handlers (mostly, but not only, inside
ENABLE_DEBUG_CYSIGNALS
).The second commit replaces use of
gettimeofday()
byclock_gettime()
, the latter being safe according tosignal-safety(7)
. It's also monotonic, unlikegettimeofday()
.Other stuff that happens inside the signal handler:
cysigs_interrupt_handler()
callsPyErr_SetInterrupt()
(probably ok?).when
debug_level >= 2
the functiondo_raise_exception()
calls PyGILState_Ensure / PyErr_Occurred / PyGILState_Release, I wonder if this could deadlock for some reason; in any case I don't understand why the GIL is necessary if the return value of PyErr_Occurred() is not used, just printed.function
sigdie()
usesgetenv()
which is not safe, maybe the env variables should be read byinit_cysignals()
instead.function
print_enhanced_backtrace()
usesexecvp()
, this is probably ok although the "correct" way would be to read PATH on init and here useexecv()
with the full path tocysignals-CSI
already precomputed.the function
sig_raise_exception()
is in cython and calls lots of python stuff, I wonder if this should be called after the longjmp() instead (it probably makes no difference since I don't thinklongjmp()
will fix internal state of e.g. stdio).