c++ - Why dlclose() must not be called from a signal handler? -
i have written user-space application in c
interacts low-level linux kernel driver using plugin library plugin.so
. open dll using dlopen()
. have signal handler calls dlclose()
when sigint
received. after code review, got feedback comments dlclose()
must not called signal handler. if yes, why so?
first of all, because dlclose()
not listed in posix list of functions safe called in signal handler.
the reason lot of functions not listed there may things allocating memory etc. need things have race status signal handler. 1 illustration hold lock, when signal arrives in thread holds lock belonging malloc/dlclose or whatever, , phone call function, lock locked, never unlocked since thread in signal handler, , not executing "normally".
c++ c linux shared-libraries signals
No comments:
Post a Comment