title: How do I stop a signal from killing my Bash script?
body: <p>I want an infinite loop to keep on running, and only temporarily be interrupted by a kill signal. I've tried SIGINT, SIGUSR1, SIGUSR2. All of them seem to halt the loop. I even tried SIGINFO, but that wasn't supported by Linux.</p>
  
  <pre><code>#!/bin/bash
  echo $$ &gt; /tmp/pid  # Save the pid
  
  function do_something {
      echo "I am doing stuff" #let's do this now, and go back to doing the thing that is to be done over and over again.
  #exit
  }
  
  
  while :
  do
      echo "This should be done over and over again, but always wait for someething else to be done in between"
  
      trap do_something SIGINT
      while `true`
      do
              sleep 1 #so we're waiting for that other thing.
      done
  
  done
  </code></pre>
  
  <p>My code runs the function once, after getting a INT signal from another script, but then never again. It halts.</p>
  
  <p><strong>EDIT: Although I accidentally put en exit at the end of the function, here on Stack Overflow, I didn't in the actual code I used. Either way, it made no difference. The solution is SIGTERM as described by Tiago.</strong></p>