Gauging interest for MT async signals utility

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Behaviour of standard signal.h / csignal is known to be different on windows and posix platforms. While on posix typically there is no provision for the thread context the signal handler will run, on windows the operating system delivers signals into a separate dedicated thread. This makes it possible e.g. to use locking primitives without risk for deadlock. I wrote a little utility that mimics that behavior on posix platforms by blocking all signals during application startup and launching a dedicated thread that has signal handling turned on. Since every other thread (that has been started after main) inherits the all-blocking sigmask, there is only one thread to handle the signals. The utility also allows a boost function pointer for the signal handler. I would be interested if there is believe such a utility would be worth including to boost. Also I would be interested on critics and opinions. A little usage example that would deadlock on posix when using std signal() instead of reset_signal(): boost::mutex mx; void foo(int sig) { std::cout << "foo attempting to lock" << std::endl; boost::mutex::scoped_lock lk(mx); std::cout << "foo got lock" << std::endl; } int main(int argc, char* argv[]) { reset_signal(SIGINT, foo); boost::mutex::scoped_lock lk(mx); std::cout << "main got lock, holding it now for 10 secs" << std::endl << "pressing ctrl-c triggers the handler" << std::endl ; sleep(10); lk.unlock(); std::cout << "unlocked, waiting another 10 secs" << std::endl; sleep(10); std::cout << "main ending" << std::endl; return 0; } - -- _________________________________________ _ _ | Roland Schwarz |_)(_ | aka. speedsnail | \__) | mailto:roland.schwarz@chello.at ________| http://www.blackspace.at -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHo1ENXW/dzA70DqARAqIUAJ4mhBCCYzWfDwJPfE6hQugtcm7bDgCePCQl 9J/vCHcpM6uplXk8VSpMVDg= =ldmb -----END PGP SIGNATURE-----
participants (1)
-
Roland Schwarz