Use system-wide mutex when using log for a session
Build fixes for X11 and OS X