<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Concurrency on random thoughts</title><link>https://riad.run/tags/concurrency/</link><description>Recent content in Concurrency on random thoughts</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sat, 11 Mar 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://riad.run/tags/concurrency/feed.xml" rel="self" type="application/rss+xml"/><item><title>Signal Handling and Graceful Shutdown in Go</title><link>https://riad.run/posts/go-signals-and-graceful-shutdown/</link><pubDate>Sat, 11 Mar 2023 00:00:00 +0000</pubDate><guid>https://riad.run/posts/go-signals-and-graceful-shutdown/</guid><description>&lt;p&gt;&lt;strong&gt;All the code samples used in this post are available&lt;/strong&gt; &lt;a href="https://github.com/riadafridishibly/go-graceful-shutdown" rel="external noopener"&gt;&lt;em&gt;here.&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;&#10;&#10;&lt;h2 id="graceful-shutdown"&gt;Graceful Shutdown&lt;a class="heading-anchor" href="#graceful-shutdown" aria-label="Link to this section"&gt;#&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;When a process is running for a long time, sometimes we want to quit the running program. If it&amp;rsquo;s a CLI process we press &lt;code&gt;CTRL+C&lt;/code&gt; or send specific kill signals. For GUI applications we quit from the menu or if the process becomes nonresponsive we find the &lt;code&gt;PID&lt;/code&gt; of the process and then run &lt;code&gt;kill -9 &amp;lt;PID&amp;gt;&lt;/code&gt;. These actions trigger an event and the event is sent to the specific process which sometimes causes the process to exit. In a stateful program, we want to save the states or perform cleanups before exiting the process. This safe exit process is called graceful shutdown.&lt;/p&gt;</description></item></channel></rss>