title: Why Linux always output "^C" upon pressing of Ctrl+C?
body: <p>I have been studying signals in Linux. And I've done a test program to capture SIGINT.</p>
  <pre><code>#include &lt;unistd.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;iostream&gt;
  void signal_handler(int signal_no);
  int main() {
    signal(SIGINT, signal_handler);
    for (int i = 0; i &lt; 10; ++i) {
    std::cout &lt;&lt; &quot;I'm sleeping...&quot; &lt;&lt; std::endl;
    unsigned int one_ms = 1000;
    usleep(200* one_ms);
    }
    return 0;
  }
  void signal_handler(int signal_no) {
    if (signal_no == SIGINT)
      std::cout &lt;&lt; &quot;Oops, you pressed Ctrl+C!\n&quot;;
    return;
  }
  </code></pre>
  <p>While the output looks like this:</p>
  <pre><code>I'm sleeping...
  I'm sleeping...
  ^COops, you pressed Ctrl+C!
  I'm sleeping...
  I'm sleeping...
  ^COops, you pressed Ctrl+C!
  I'm sleeping...
  ^COops, you pressed Ctrl+C!
  I'm sleeping...
  ^COops, you pressed Ctrl+C!
  I'm sleeping...
  ^COops, you pressed Ctrl+C!
  I'm sleeping...
  I'm sleeping...
  I'm sleeping...
  </code></pre>
  <p>I understand that when pressing Ctrl+C, processes in foreground process group all receives a SIGINT(if no process chooses to ignore it).</p>
  <p>So is it that the shell(bash) AND the instance of the above program both received the signal? Where does the &quot;^C&quot; before each &quot;Oops&quot; come from?</p>
  <p>The OS is CentOS, and the shell is bash.</p>