title: Get the id of the thread who throw a signal
body: <p>I want to know if there is an easy way to catch the id of the thread who crash without using intermediates signal_handlers</p>
  
  <p>I have the following code</p>
  
  <pre><code>void signal_handler(int signal)
  {
    std::cout &lt;&lt; "Caught the signal:" &lt;&lt; signal &lt;&lt; std::endl;
  }
  
  void    handler_t1(int signal)
  {
    std::signal(SIGSEGV, signal_handler);
    std::cout &lt;&lt; "Thread 1 have received the signal: " &lt;&lt; signal &lt;&lt; std::endl;
    std::raise(SIGSEGV);
  }
  
  void    f1()
  {
    std::signal(SIGSEGV, handler_t1);
    std::cout &lt;&lt; "Begin thread 1" &lt;&lt; std::endl;
    std::this_thread::sleep_for(std::chrono::seconds(1));
    std::raise(SIGSEGV);
    std::cout &lt;&lt; "end thread1" &lt;&lt; std::endl;
  }
  
  void    f2()
  {
    std::cout &lt;&lt; "Begin thread 2" &lt;&lt; std::endl;
    std::this_thread::sleep_for(std::chrono::seconds(3));
    std::cout &lt;&lt; "end thread2" &lt;&lt; std::endl;
  }
  
  int     main()
  {
    std::thread t1(f1);
    std::thread t2(f2);
  
    t1.join();
    t2.join();
  }
  </code></pre>
  
  <p>So I get the </p>
  
  <pre><code>Begin thread 1Begin thread 2
  Thread 1 have received the signal: 11
  Caught the signal:11
  end thread1
  end thread2
  </code></pre>
  
  <p>But if I have 5 threads, can I avoid to create 5 handler ?</p>
  
  <p><strong><em>edit</em></strong> my includes are</p>
  
  <pre><code>#include &lt;thread&gt;
  #include &lt;chrono&gt;
  #include &lt;iostream&gt;
  #include &lt;csignal&gt;
  </code></pre>
  
  <p><strong><em>edit</em></strong>
  I think I was looking something like I found <a href="https://stackoverflow.com/a/16259324/2380470">https://stackoverflow.com/a/16259324/2380470</a>
  but since this thing doesn't exist yet, I must find something else </p>