title: CTRL + C doesn't kill C script
body: <p>I'm reading <a href="https://pages.cs.wisc.edu/%7Eremzi/OSTEP/" rel="nofollow noreferrer">Operating Systems: Three Easy Pieces</a> and I'm finding a problem is not mentioned in the book.</p>
  <p>This is the C script:</p>
  <pre><code>#include &lt;unistd.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  /*#include &quot;common.h&quot;*/
  #include &lt;unistd.h&gt;
  #include &lt;assert.h&gt;
  
  
  int
  main(int argc, char *argv[])
  {
      int *p = malloc(sizeof(int));
      assert(p != NULL);
      printf(&quot;(%d address pointed to by p: %p\n&quot;,
              getpid(), p);
              *p = 0;
              while (1) {
                  sleep(1);
                  *p = *p +1;
                  printf(&quot;(%d) p: %d\n&quot;, getpid(), *p);
              }
              return 0;
  }
  </code></pre>
  <p>It allocates some memory, prints out the address memory, puts the number 0 into it and finally loops to increment the value.</p>
  <p>I compile it through <code>gcc -o mem mem.c -Wall</code> and I have no problem running it with <code>./mem</code>, if I press CRTL+C it will stop:</p>
  <p><a href="https://i.stack.imgur.com/DGDbJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DGDbJ.png" alt="enter image description here" /></a></p>
  <p>But then problems come when I run the script twice in parallel with the command <code>./mem &amp; ./mem</code>, look at the GIF:</p>
  <p><a href="https://i.stack.imgur.com/Cu6JV.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cu6JV.gif" alt="enter image description here" /></a></p>
  <p>No matter how many times I try to kill the process the scripts keeps hammering.</p>
  <p>How to kill my C which project?</p>