Boost C++ Libraries: Ticket #2879: [asio] Handling of unix signals https://svn.boost.org/trac10/ticket/2879 <p> This proposal suggests adding to asio the ability to invoke a handler whenever a unix signal arrives. </p> <p> Motivation: </p> <ol><li>The extension lets the user have a unix signal handler of an arbitrary signature. </li></ol><ol start="2"><li>The extension also removes the "async-signal safe calls" restriction from a handler of a unix signal. </li></ol><p> The extension is supposed to be used like this: </p> <p> void on_signal(boost::system::error_code const&amp; error) { </p> <blockquote> <p> if (!error) </p> <blockquote> <p> cout &lt;&lt; "sigint received" &lt;&lt; endl; </p> </blockquote> </blockquote> <p> } </p> <p> int main(int argc, char const* argv[]) </p> <p> { </p> <blockquote> <p> boost::asio::io_service ios; boost::asio::posix::signal_handler&lt;SIGINT&gt; sigint(ios); while (true) { </p> <blockquote> <p> ios.reset(); sigint.async_wait(boost::bind(on_signal, _1)); ios.poll(); </p> </blockquote> <p> } </p> </blockquote> <p> } </p> <p> The original proposal on the mail list can be found here. <a class="ext-link" href="http://lists.boost.org/Archives/boost/2009/03/149890.php"><span class="icon">​</span>http://lists.boost.org/Archives/boost/2009/03/149890.php</a> </p> <p> Please find the implementation and examples in the attachments. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2879 Trac 1.4.3 dgoncharov@… Fri, 20 Mar 2009 17:36:17 GMT attachment set https://svn.boost.org/trac10/ticket/2879 https://svn.boost.org/trac10/ticket/2879 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">sighandler.cpp</span> </li> </ul> <p> an example </p> Ticket dgoncharov@… Fri, 20 Mar 2009 17:36:55 GMT attachment set https://svn.boost.org/trac10/ticket/2879 https://svn.boost.org/trac10/ticket/2879 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">signalfd.hpp</span> </li> </ul> <p> implementation </p> Ticket dgoncharov@… Fri, 20 Mar 2009 17:37:15 GMT attachment set https://svn.boost.org/trac10/ticket/2879 https://svn.boost.org/trac10/ticket/2879 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">signal_handler.hpp</span> </li> </ul> <p> implementation </p> Ticket dgoncharov@… Fri, 20 Mar 2009 17:37:33 GMT attachment set https://svn.boost.org/trac10/ticket/2879 https://svn.boost.org/trac10/ticket/2879 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">sigselect.cpp</span> </li> </ul> <p> an example </p> Ticket samjmill@… Tue, 15 Sep 2009 16:19:04 GMT cc set https://svn.boost.org/trac10/ticket/2879#comment:1 https://svn.boost.org/trac10/ticket/2879#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">samjmill@…</span> added </li> </ul> <p> adding myself, this is exactly what I've been looking for. Any chance this feature can make it into the next version of asio? </p> Ticket kyle.tarplee@… Wed, 16 Sep 2009 18:36:41 GMT <link>https://svn.boost.org/trac10/ticket/2879#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2879#comment:2</guid> <description> <p> I would like this as well. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 18 Sep 2009 15:31:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2879#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2879#comment:3</guid> <description> <p> There was also interest aside from the mail list. So, i made a small library out of this proposal. The library can be found here <a class="ext-link" href="http://github.com/dgoncharov/libunixsignal/"><span class="icon">​</span>http://github.com/dgoncharov/libunixsignal/</a>. The library uses autotools. So, basically all you need to do is to type ./configure; make install. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 18 Sep 2009 15:33:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2879#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2879#comment:4</guid> <description> <p> Forgot to subscribe the previous comment. dgoncharov at unison.com </p> </description> <category>Ticket</category> </item> <item> <author>boris@…</author> <pubDate>Sun, 18 Oct 2009 21:41:55 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/2879 https://svn.boost.org/trac10/ticket/2879 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">signal_handler.zip</span> </li> </ul> <p> Signal handler based on Boost.Asio design guidelines </p> Ticket anonymous Tue, 26 Jan 2010 16:15:46 GMT <link>https://svn.boost.org/trac10/ticket/2879#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2879#comment:5</guid> <description> <p> The implementation proposed in the last comment is incorrect. It uses async-signal-unsafe syscalls like locking a mutex inside a signal handler. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>bschaeling</dc:creator> <pubDate>Sat, 27 Mar 2010 17:41:44 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/2879 https://svn.boost.org/trac10/ticket/2879 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">signal_handler.2.zip</span> </li> </ul> <p> Updated signal handler (based on Boost.Asio design patterns) </p> Ticket bschaeling Sat, 27 Mar 2010 17:43:19 GMT <link>https://svn.boost.org/trac10/ticket/2879#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2879#comment:6</guid> <description> <p> I've updated the signal handler's implementation. Can you (who you are anonymous :-) please check the new version? It uses a pipe now (there is only write() called in the signal handler function). The tests are still all passed. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Mon, 06 Jun 2011 01:56:34 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2879#comment:7 https://svn.boost.org/trac10/ticket/2879#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> As of <a class="changeset" href="https://svn.boost.org/trac10/changeset/72428" title="Merge asio from trunk.">[72428]</a>, the release branch contains the new signal_set class. </p> Ticket