jekyll build from Action 36ff4172b994bc4ce24e6efca7dc2245ddfb3231
This commit is contained in:
parent
09744b9b34
commit
c525098b35
@ -456,7 +456,9 @@ kill_childs<span class="o">(){</span> <span class="c"># wow, this sounded wild</
|
||||
<span class="k">for </span>pid <span class="k">in</span> <span class="s2">"</span><span class="k">${</span><span class="nv">pids</span><span class="p">[@]</span><span class="k">}</span><span class="s2">"</span>
|
||||
<span class="k">do
|
||||
</span><span class="nb">echo </span>killing <span class="s2">"</span><span class="nv">$pid</span><span class="s2">"</span>
|
||||
<span class="nb">kill</span> <span class="s2">"</span><span class="nv">$pid</span><span class="s2">"</span>
|
||||
<span class="c"># -P: kill all the processes whose parent process is 'pid'</span>
|
||||
<span class="c"># see how we are creating processes below</span>
|
||||
pkill <span class="nt">-P</span> <span class="s2">"</span><span class="nv">$pid</span><span class="s2">"</span>
|
||||
<span class="k">done
|
||||
</span><span class="nv">pids</span><span class="o">=()</span>
|
||||
<span class="o">}</span>
|
||||
@ -470,8 +472,8 @@ restart_scripts<span class="o">(){</span>
|
||||
<span class="c"># Run the script and store its pid.</span>
|
||||
<span class="c"># note the '&' at the end of command. Without it the script will</span>
|
||||
<span class="c"># block until its execution is finished. Also we are putting it</span>
|
||||
<span class="c"># into braces because we want to create a process group so that</span>
|
||||
<span class="c"># killing this pid will end all the grandchilds.</span>
|
||||
<span class="c"># into braces because we want to create a "process group" so that</span>
|
||||
<span class="c"># we can kill all its children later by specifying parent pid</span>
|
||||
<span class="c"># (useful if you have pipes (|) or other &'s in your script!)</span>
|
||||
<span class="o">(</span><span class="nv">$script</span><span class="o">)</span> &
|
||||
pids+<span class="o">=(</span><span class="s2">"</span><span class="nv">$!</span><span class="s2">"</span><span class="o">)</span>
|
||||
|
File diff suppressed because one or more lines are too long
10
feed.xml
10
feed.xml
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.1">Jekyll</generator><link href="https://sahinakkaya.dev/feed.xml" rel="self" type="application/atom+xml" /><link href="https://sahinakkaya.dev/" rel="alternate" type="text/html" /><updated>2023-01-16T17:58:56+00:00</updated><id>https://sahinakkaya.dev/feed.xml</id><title type="html">Şahin Akkaya’s Personal Page</title><subtitle>Şahin Akkaya's personal blog - a perfectionist who likes to tinker everything until it is just right. Get ready to find some sweet tips that will boost your productivity and make you fall in love with your computer.</subtitle><author><name>Şahin Akkaya</name></author><entry><title type="html">Hot-Reload Long Running Shell Scripts (feat. trap / kill)</title><link href="https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill.html" rel="alternate" type="text/html" title="Hot-Reload Long Running Shell Scripts (feat. trap / kill)" /><published>2023-01-15T21:48:08+00:00</published><updated>2023-01-15T21:48:08+00:00</updated><id>https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill</id><content type="html" xml:base="https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill.html"><h2 id="trap-them-and-kill-them"><code class="language-plaintext highlighter-rouge">trap</code> them and <code class="language-plaintext highlighter-rouge">kill</code> them!</h2>
|
||||
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.1">Jekyll</generator><link href="https://sahinakkaya.dev/feed.xml" rel="self" type="application/atom+xml" /><link href="https://sahinakkaya.dev/" rel="alternate" type="text/html" /><updated>2023-01-16T18:20:39+00:00</updated><id>https://sahinakkaya.dev/feed.xml</id><title type="html">Şahin Akkaya’s Personal Page</title><subtitle>Şahin Akkaya's personal blog - a perfectionist who likes to tinker everything until it is just right. Get ready to find some sweet tips that will boost your productivity and make you fall in love with your computer.</subtitle><author><name>Şahin Akkaya</name></author><entry><title type="html">Hot-Reload Long Running Shell Scripts (feat. trap / kill)</title><link href="https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill.html" rel="alternate" type="text/html" title="Hot-Reload Long Running Shell Scripts (feat. trap / kill)" /><published>2023-01-15T21:48:08+00:00</published><updated>2023-01-15T21:48:08+00:00</updated><id>https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill</id><content type="html" xml:base="https://sahinakkaya.dev/2023/01/15/hot-reloading-with-trap-and-kill.html"><h2 id="trap-them-and-kill-them"><code class="language-plaintext highlighter-rouge">trap</code> them and <code class="language-plaintext highlighter-rouge">kill</code> them!</h2>
|
||||
<p>There is a beautiful command in Linux called <a href="https://man7.org/linux/man-pages/man1/trap.1p.html"><code class="language-plaintext highlighter-rouge">trap</code></a> which <em>trap</em>s signals and let you run specific commands when they invoked. There is also good ol’ <a href="https://man7.org/linux/man-pages/man1/kill.1.html"><code class="language-plaintext highlighter-rouge">kill</code></a> command which not only kills processes but allows you to specify a signal to send. By combining these two, you can run specific functions from your scripts any time!</p>
|
||||
|
||||
<h3 id="basic-example">Basic Example</h3>
|
||||
@ -135,7 +135,9 @@ kill_childs<span class="o">(){</span> <span class="
|
||||
<span class="k">for </span>pid <span class="k">in</span> <span class="s2">"</span><span class="k">${</span><span class="nv">pids</span><span class="p">[@]</span><span class="k">}</span><span class="s2">"</span>
|
||||
<span class="k">do
|
||||
</span><span class="nb">echo </span>killing <span class="s2">"</span><span class="nv">$pid</span><span class="s2">"</span>
|
||||
<span class="nb">kill</span> <span class="s2">"</span><span class="nv">$pid</span><span class="s2">"</span>
|
||||
<span class="c"># -P: kill all the processes whose parent process is 'pid'</span>
|
||||
<span class="c"># see how we are creating processes below</span>
|
||||
pkill <span class="nt">-P</span> <span class="s2">"</span><span class="nv">$pid</span><span class="s2">"</span>
|
||||
<span class="k">done
|
||||
</span><span class="nv">pids</span><span class="o">=()</span>
|
||||
<span class="o">}</span>
|
||||
@ -149,8 +151,8 @@ restart_scripts<span class="o">(){</span>
|
||||
<span class="c"># Run the script and store its pid.</span>
|
||||
<span class="c"># note the '&amp;' at the end of command. Without it the script will</span>
|
||||
<span class="c"># block until its execution is finished. Also we are putting it</span>
|
||||
<span class="c"># into braces because we want to create a process group so that</span>
|
||||
<span class="c"># killing this pid will end all the grandchilds.</span>
|
||||
<span class="c"># into braces because we want to create a "process group" so that</span>
|
||||
<span class="c"># we can kill all its children later by specifying parent pid</span>
|
||||
<span class="c"># (useful if you have pipes (|) or other &amp;'s in your script!)</span>
|
||||
<span class="o">(</span><span class="nv">$script</span><span class="o">)</span> &amp;
|
||||
pids+<span class="o">=(</span><span class="s2">"</span><span class="nv">$!</span><span class="s2">"</span><span class="o">)</span>
|
||||
|
@ -55,6 +55,6 @@
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://sahinakkaya.dev/assets/docs/resume.pdf</loc>
|
||||
<lastmod>2023-01-16T17:58:49+00:00</lastmod>
|
||||
<lastmod>2023-01-16T18:20:30+00:00</lastmod>
|
||||
</url>
|
||||
</urlset>
|
||||
|
Loading…
Reference in New Issue
Block a user