{"action":"opened","issue":{"url":"https://api.github.com/repos/jmc-88/tint3/issues/12","labels_url":"https://api.github.com/repos/jmc-88/tint3/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/jmc-88/tint3/issues/12/comments","events_url":"https://api.github.com/repos/jmc-88/tint3/issues/12/events","html_url":"https://github.com/jmc-88/tint3/issues/12","id":96378757,"number":12,"title":"Deadlock in signal handler","user":{"login":"o9000","id":12872785,"avatar_url":"https://avatars.githubusercontent.com/u/12872785?v=3","gravatar_id":"","url":"https://api.github.com/users/o9000","html_url":"https://github.com/o9000","followers_url":"https://api.github.com/users/o9000/followers","following_url":"https://api.github.com/users/o9000/following{/other_user}","gists_url":"https://api.github.com/users/o9000/gists{/gist_id}","starred_url":"https://api.github.com/users/o9000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/o9000/subscriptions","organizations_url":"https://api.github.com/users/o9000/orgs","repos_url":"https://api.github.com/users/o9000/repos","events_url":"https://api.github.com/users/o9000/events{/privacy}","received_events_url":"https://api.github.com/users/o9000/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-21T18:03:25Z","updated_at":"2015-07-21T18:03:25Z","closed_at":null,"body":"The startup notification code is calling the functions sn_launcher_context_complete() and sn_launcher_context_unref() (also util::log::Error() but not sure about that one). These functions call in turn other functions from Xlib, which may block.\r\n\r\nCalling any potentially blocking function from a signal handler is forbidden, as it may cause a deadlock.  Even if a deadlock does not happen, there might be races.\r\n\r\nThe solution is to only communicate the event from signal handler to the event loop, and run the handling code there. The event loop might be blocking in select() so it needs to be woken up.\r\n\r\nThis can be achieved by using a non-blocking pipe: the signal handler writes a byte into the pipe, while the event loop selects on both the X11 socket and the pipe.\r\n\r\nReference: http://cr.yp.to/docs/selfpipe.html\r\n\r\nHere is a fix: https://gitlab.com/o9000/tint3/commit/d3205e7ab534752ae4a87d2ad9a675ac016f301b\r\n\r\nThe only thing I'm not sure of is in which file to define SigchldHandler(). src/util/x11.cc might not be the best place."}}